Package org.ametys.runtime.model
Class AbstractModelItem
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItem
-
- All Implemented Interfaces:
Comparable<ModelItem>,ModelItem,Labelable,ModifiableLabelable
- Direct Known Subclasses:
ElementDefinition,ModelItemGroup
public abstract class AbstractModelItem extends Object implements ModelItem
Abstract class for model items
-
-
Field Summary
Fields Modifier and Type Field Description protected static ServiceManager__serviceManagerThe service manager-
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description AbstractModelItem()Default constructor.AbstractModelItem(String name)Constructor used to create simple models and itemsAbstractModelItem(AbstractModelItem modelItemToCopy)Constructor by copying an existingAbstractModelItem.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean_shouldJSONBeEmpty(DefinitionContext context)Checks if the current definition JSON conversion should return an empty mapprotected Map<String,Object>_toJSON(DefinitionContext context)Converts the model item in a JSON mapprotected void_widgetParameterToSAX(ContentHandler contentHandler, String parameterName, I18nizableText parameterValue, DefinitionContext context)Generates SAX events for the given widget parameterprotected void_widgetToSAX(ContentHandler contentHandler, DefinitionContext context)Generates SAX events for the model item's widgetvoidaddItemChecker(ItemCheckerDescriptor itemChecker)Add an item checker to the groupintcompareTo(ModelItem item)booleanequals(Object obj)I18nizableTextgetDescription()Retrieves the description.DisableConditionsgetDisableConditions()Retrieves the disable condition.Set<ItemCheckerDescriptor>getItemCheckers()Returns theItemCheckerDescriptors associated with this group.I18nizableTextgetLabel()Retrieves the label.ModelgetModel()Retrieves the model of the itemStringgetName()Get the name.ModelItemGroupgetParent()Retrieves the parent of the itemStringgetPath()Retrieves the path of the model itemStringgetPluginName()Retrieves the name of the plugin declaring this element.StringgetWidget()Retrieves the widget to use for rendering.Map<String,I18nizableText>getWidgetParameters()Get the widget's parametersinthashCode()voidsetDescription(I18nizableText description)Set the description.voidsetDisableConditions(DisableConditions disableConditions)Sets the disable condition.voidsetLabel(I18nizableText label)Set the label.voidsetModel(Model model)Sets the model of the elementvoidsetName(String name)Set the name.voidsetParent(ModelItemGroup parent)Sets the parent of the itemvoidsetPluginName(String pluginName)Set the name of the plugin declaring this element.static voidsetServiceManager(ServiceManager manager)Set the service manager TheServiceManageris used in the model items creation methods to get the model item type.voidsetWidget(String widget)Set the widget.voidsetWidgetParameters(Map<String,I18nizableText> params)Set the widget's parametersMap<String,Object>toJSON(DefinitionContext context)Converts the model item in a JSON mapvoidtoSAX(ContentHandler contentHandler, DefinitionContext context)Generates SAX events for the model itemStringtoString()
-
-
-
Field Detail
-
__serviceManager
protected static ServiceManager __serviceManager
The service manager
-
-
Constructor Detail
-
AbstractModelItem
public AbstractModelItem()
Default constructor.
-
AbstractModelItem
public AbstractModelItem(String name)
Constructor used to create simple models and items- Parameters:
name- the name of the item
-
AbstractModelItem
public AbstractModelItem(AbstractModelItem modelItemToCopy)
Constructor by copying an existingAbstractModelItem.- Parameters:
modelItemToCopy- TheAbstractModelItemto copy
-
-
Method Detail
-
setName
public void setName(String name)
Description copied from interface:ModifiableLabelableSet the name.- Specified by:
setNamein interfaceModifiableLabelable- Parameters:
name- the name.
-
getPluginName
public String getPluginName()
Description copied from interface:ModelItemRetrieves the name of the plugin declaring this element.- Specified by:
getPluginNamein interfaceModelItem- Returns:
- the plugin name.
-
setPluginName
public void setPluginName(String pluginName)
Description copied from interface:ModelItemSet the name of the plugin declaring this element.- Specified by:
setPluginNamein interfaceModelItem- Parameters:
pluginName- the plugin name.
-
getLabel
public I18nizableText getLabel()
Description copied from interface:LabelableRetrieves the label.
-
setLabel
public void setLabel(I18nizableText label)
Description copied from interface:ModifiableLabelableSet the label.- Specified by:
setLabelin interfaceModifiableLabelable- Parameters:
label- the label.
-
getDescription
public I18nizableText getDescription()
Description copied from interface:LabelableRetrieves the description.- Specified by:
getDescriptionin interfaceLabelable- Returns:
- the description.
-
setDescription
public void setDescription(I18nizableText description)
Description copied from interface:ModifiableLabelableSet the description.- Specified by:
setDescriptionin interfaceModifiableLabelable- Parameters:
description- the description.
-
addItemChecker
public void addItemChecker(ItemCheckerDescriptor itemChecker)
Description copied from interface:ModelItemAdd an item checker to the group- Specified by:
addItemCheckerin interfaceModelItem- Parameters:
itemChecker- the item checker to add
-
getItemCheckers
public Set<ItemCheckerDescriptor> getItemCheckers()
Description copied from interface:ModelItemReturns theItemCheckerDescriptors associated with this group.- Specified by:
getItemCheckersin interfaceModelItem- Returns:
- the
ItemCheckerDescriptors associated with this group.
-
getWidget
public String getWidget()
Description copied from interface:ModelItemRetrieves the widget to use for rendering.
-
setWidget
public void setWidget(String widget)
Description copied from interface:ModelItemSet the widget.
-
getWidgetParameters
public Map<String,I18nizableText> getWidgetParameters()
Description copied from interface:ModelItemGet the widget's parameters- Specified by:
getWidgetParametersin interfaceModelItem- Returns:
- the widget's parameters
-
setWidgetParameters
public void setWidgetParameters(Map<String,I18nizableText> params)
Description copied from interface:ModelItemSet the widget's parameters- Specified by:
setWidgetParametersin interfaceModelItem- Parameters:
params- the parameters to set
-
getDisableConditions
public DisableConditions getDisableConditions()
Description copied from interface:ModelItemRetrieves the disable condition.- Specified by:
getDisableConditionsin interfaceModelItem- Returns:
- the disable condition or
nullif none is defined.
-
setDisableConditions
public void setDisableConditions(DisableConditions disableConditions)
Description copied from interface:ModelItemSets the disable condition.- Specified by:
setDisableConditionsin interfaceModelItem- Parameters:
disableConditions- the disable condition.
-
getPath
public String getPath()
Description copied from interface:ModelItemRetrieves the path of the model item
-
getModel
public Model getModel()
Description copied from interface:ModelItemRetrieves the model of the item
-
setModel
public void setModel(Model model)
Description copied from interface:ModelItemSets the model of the element
-
getParent
public ModelItemGroup getParent()
Description copied from interface:ModelItemRetrieves the parent of the item
-
setParent
public void setParent(ModelItemGroup parent)
Description copied from interface:ModelItemSets the parent of the item
-
toJSON
public Map<String,Object> toJSON(DefinitionContext context) throws ProcessingException
Description copied from interface:ModelItemConverts the model item in a JSON map- Specified by:
toJSONin interfaceModelItem- Parameters:
context- the context of the definition- Returns:
- The model item as a JSON map, or an empty map
- Throws:
ProcessingException- If an error occurs when converting the model item
-
_toJSON
protected Map<String,Object> _toJSON(DefinitionContext context) throws ProcessingException
Converts the model item in a JSON map- Parameters:
context- the context of the definition- Returns:
- The model item as a JSON map
- Throws:
ProcessingException- If an error occurs when converting the model item
-
_shouldJSONBeEmpty
protected boolean _shouldJSONBeEmpty(DefinitionContext context)
Checks if the current definition JSON conversion should return an empty map- Parameters:
context- the context of the definition- Returns:
trueif the JSON conversion should return an empty map,falseotherwise
-
toSAX
public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
Description copied from interface:ModelItemGenerates SAX events for the model item- Specified by:
toSAXin interfaceModelItem- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventscontext- the context of the definition- Throws:
SAXException- if an error occurs during the SAX events generation
-
_widgetToSAX
protected void _widgetToSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
Generates SAX events for the model item's widget- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventscontext- the context of the definition- Throws:
SAXException- if an error occurs during the SAX events generation
-
_widgetParameterToSAX
protected void _widgetParameterToSAX(ContentHandler contentHandler, String parameterName, I18nizableText parameterValue, DefinitionContext context) throws SAXException
Generates SAX events for the given widget parameter- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsparameterName- the name of the parameterparameterValue- the value of the parametercontext- the context of the definition- Throws:
SAXException- if an error occurs during the SAX events generation
-
compareTo
public int compareTo(ModelItem item)
- Specified by:
compareToin interfaceComparable<ModelItem>
-
setServiceManager
public static void setServiceManager(ServiceManager manager)
Set the service manager TheServiceManageris used in the model items creation methods to get the model item type.ModelItemis not aComponentand can't have aServiceManageritself. AnotherComponenthas to set it- Parameters:
manager- the service manager to set
-
-