Class AbstractSourceType
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.question.sources.AbstractSourceType
- All Implemented Interfaces:
LazyEnumerator<ChoiceOption>
,ChoiceSourceType
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
ManualSourceType
,ManualWithCostsSourceType
,TableRefSourceType
,UsersSourceType
public abstract class AbstractSourceType
extends AbstractLogEnabled
implements ChoiceSourceType, Serviceable, Configurable, PluginAware
Static class for creating
ChoiceSourceType
from xml congig-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
Id of source typeprotected JSONUtils
JSON helperprotected I18nizableText
Label of source typeprotected String
Formsstatic final String
The question param keyFields inherited from interface org.ametys.plugins.forms.enumerators.LazyEnumerator
LANG_PARAMETER_KEY, PATTERN_PARAMETER_KEY, SORT_PARAMETER_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
_getComputedComplexValue
(Object valueToJSONForClient, FormQuestion question, FormEntry entry) Get computed complex value as user or content for choice listprotected Object
_getComputedStringValue
(Object valueToJSONForClient, FormQuestion question, FormEntry entry) Get computed string value for choice listprotected FormQuestion
_getQuestionFromParam
(Map<String, Object> params) Get question from paramsvoid
configure
(Configuration configuration) Get field to disable if form is publishedgetId()
Get the type idGet the js converter for the choice listGet the js renderer for the choice listgetLabel()
Get the type labelgetStorageType
(FormQuestion question) Get the storage type of the source typeremoveEmptyOrOtherValue
(Object value) Remove the empty values or values equal to '__interval_other' from received valuevoid
service
(ServiceManager manager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.valueToJSONForClient
(Object value, FormQuestion question, FormEntry entry, ModelItem modelItem) Convert the entry value into a JSON object to use client sideMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.forms.question.sources.ChoiceSourceType
getModelItems, getViewItems, remoteData
Methods inherited from interface org.ametys.plugins.forms.enumerators.LazyEnumerator
getEntry, getTypedEntries, searchEntries
-
Field Details
-
QUESTION_PARAM_KEY
The question param key- See Also:
-
_jsonUtils
JSON helper -
_pluginName
Forms -
_id
Id of source type -
_label
Label of source type
-
-
Constructor Details
-
AbstractSourceType
public AbstractSourceType()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
getId
Description copied from interface:ChoiceSourceType
Get the type id- Specified by:
getId
in interfaceChoiceSourceType
- Returns:
- the id
-
getLabel
Description copied from interface:ChoiceSourceType
Get the type label- Specified by:
getLabel
in interfaceChoiceSourceType
- Returns:
- the label
-
getFieldToDisableIfFormPublished
Description copied from interface:ChoiceSourceType
Get field to disable if form is published- Specified by:
getFieldToDisableIfFormPublished
in interfaceChoiceSourceType
- Returns:
- the list of field name
-
getStorageType
Description copied from interface:ChoiceSourceType
Get the storage type of the source type- Specified by:
getStorageType
in interfaceChoiceSourceType
- Parameters:
question
- the question- Returns:
- the storage type
-
getJSRenderer
Description copied from interface:ChoiceSourceType
Get the js renderer for the choice list- Specified by:
getJSRenderer
in interfaceChoiceSourceType
- Returns:
- the js renderer
-
getJSConverter
Description copied from interface:ChoiceSourceType
Get the js converter for the choice list- Specified by:
getJSConverter
in interfaceChoiceSourceType
- Returns:
- the js converter
-
removeEmptyOrOtherValue
Description copied from interface:ChoiceSourceType
Remove the empty values or values equal to '__interval_other' from received value- Specified by:
removeEmptyOrOtherValue
in interfaceChoiceSourceType
- Parameters:
value
- the receive value- Returns:
- the value without empty sub-values or without '__interval_other' if the other option is chosen. If the value is empty or equal to the other value, it returns null.
-
_getQuestionFromParam
Get question from params- Parameters:
params
- the params- Returns:
- the form question
-
valueToJSONForClient
public Object valueToJSONForClient(Object value, FormQuestion question, FormEntry entry, ModelItem modelItem) throws Exception Description copied from interface:ChoiceSourceType
Convert the entry value into a JSON object to use client side- Specified by:
valueToJSONForClient
in interfaceChoiceSourceType
- Parameters:
value
- the value to convertquestion
- the form questionentry
- the form entrymodelItem
- the model item- Returns:
- The value as JSON
- Throws:
Exception
- if an error occurred
-
_getComputedStringValue
protected Object _getComputedStringValue(Object valueToJSONForClient, FormQuestion question, FormEntry entry) throws Exception Get computed string value for choice list- Parameters:
valueToJSONForClient
- the value for this questionquestion
- the questionentry
- the entry- Returns:
- the computed value
- Throws:
Exception
- if an error occurred during computing
-
_getComputedComplexValue
protected Object _getComputedComplexValue(Object valueToJSONForClient, FormQuestion question, FormEntry entry) throws Exception Get computed complex value as user or content for choice list- Parameters:
valueToJSONForClient
- the value for this questionquestion
- the questionentry
- the entry- Returns:
- the computed value
- Throws:
Exception
- if an error occurred
-