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
__serviceManager
The 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 widgetvoid
addItemChecker(ItemCheckerDescriptor itemChecker)
Add an item checker to the groupint
compareTo(ModelItem item)
boolean
equals(Object obj)
I18nizableText
getDescription()
Retrieves the description.DisableConditions
getDisableConditions()
Retrieves the disable condition.Set<ItemCheckerDescriptor>
getItemCheckers()
Returns theItemCheckerDescriptor
s associated with this group.I18nizableText
getLabel()
Retrieves the label.Model
getModel()
Retrieves the model of the itemString
getName()
Get the name.ModelItemGroup
getParent()
Retrieves the parent of the itemString
getPath()
Retrieves the path of the model itemString
getPluginName()
Retrieves the name of the plugin declaring this element.String
getWidget()
Retrieves the widget to use for rendering.Map<String,I18nizableText>
getWidgetParameters()
Get the widget's parametersint
hashCode()
void
setDescription(I18nizableText description)
Set the description.void
setDisableConditions(DisableConditions disableConditions)
Sets the disable condition.void
setLabel(I18nizableText label)
Set the label.void
setModel(Model model)
Sets the model of the elementvoid
setName(String name)
Set the name.void
setParent(ModelItemGroup parent)
Sets the parent of the itemvoid
setPluginName(String pluginName)
Set the name of the plugin declaring this element.static void
setServiceManager(ServiceManager manager)
Set the service manager TheServiceManager
is used in the model items creation methods to get the model item type.void
setWidget(String widget)
Set the widget.void
setWidgetParameters(Map<String,I18nizableText> params)
Set the widget's parametersMap<String,Object>
toJSON(DefinitionContext context)
Converts the model item in a JSON mapvoid
toSAX(ContentHandler contentHandler, DefinitionContext context)
Generates SAX events for the model itemString
toString()
-
-
-
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
- TheAbstractModelItem
to copy
-
-
Method Detail
-
setName
public void setName(String name)
Description copied from interface:ModifiableLabelable
Set the name.- Specified by:
setName
in interfaceModifiableLabelable
- Parameters:
name
- the name.
-
getPluginName
public String getPluginName()
Description copied from interface:ModelItem
Retrieves the name of the plugin declaring this element.- Specified by:
getPluginName
in interfaceModelItem
- Returns:
- the plugin name.
-
setPluginName
public void setPluginName(String pluginName)
Description copied from interface:ModelItem
Set the name of the plugin declaring this element.- Specified by:
setPluginName
in interfaceModelItem
- Parameters:
pluginName
- the plugin name.
-
getLabel
public I18nizableText getLabel()
Description copied from interface:Labelable
Retrieves the label.
-
setLabel
public void setLabel(I18nizableText label)
Description copied from interface:ModifiableLabelable
Set the label.- Specified by:
setLabel
in interfaceModifiableLabelable
- Parameters:
label
- the label.
-
getDescription
public I18nizableText getDescription()
Description copied from interface:Labelable
Retrieves the description.- Specified by:
getDescription
in interfaceLabelable
- Returns:
- the description.
-
setDescription
public void setDescription(I18nizableText description)
Description copied from interface:ModifiableLabelable
Set the description.- Specified by:
setDescription
in interfaceModifiableLabelable
- Parameters:
description
- the description.
-
addItemChecker
public void addItemChecker(ItemCheckerDescriptor itemChecker)
Description copied from interface:ModelItem
Add an item checker to the group- Specified by:
addItemChecker
in interfaceModelItem
- Parameters:
itemChecker
- the item checker to add
-
getItemCheckers
public Set<ItemCheckerDescriptor> getItemCheckers()
Description copied from interface:ModelItem
Returns theItemCheckerDescriptor
s associated with this group.- Specified by:
getItemCheckers
in interfaceModelItem
- Returns:
- the
ItemCheckerDescriptor
s associated with this group.
-
getWidget
public String getWidget()
Description copied from interface:ModelItem
Retrieves the widget to use for rendering.
-
setWidget
public void setWidget(String widget)
Description copied from interface:ModelItem
Set the widget.
-
getWidgetParameters
public Map<String,I18nizableText> getWidgetParameters()
Description copied from interface:ModelItem
Get the widget's parameters- Specified by:
getWidgetParameters
in interfaceModelItem
- Returns:
- the widget's parameters
-
setWidgetParameters
public void setWidgetParameters(Map<String,I18nizableText> params)
Description copied from interface:ModelItem
Set the widget's parameters- Specified by:
setWidgetParameters
in interfaceModelItem
- Parameters:
params
- the parameters to set
-
getDisableConditions
public DisableConditions getDisableConditions()
Description copied from interface:ModelItem
Retrieves the disable condition.- Specified by:
getDisableConditions
in interfaceModelItem
- Returns:
- the disable condition or
null
if none is defined.
-
setDisableConditions
public void setDisableConditions(DisableConditions disableConditions)
Description copied from interface:ModelItem
Sets the disable condition.- Specified by:
setDisableConditions
in interfaceModelItem
- Parameters:
disableConditions
- the disable condition.
-
getPath
public String getPath()
Description copied from interface:ModelItem
Retrieves the path of the model item
-
getModel
public Model getModel()
Description copied from interface:ModelItem
Retrieves the model of the item
-
setModel
public void setModel(Model model)
Description copied from interface:ModelItem
Sets the model of the element
-
getParent
public ModelItemGroup getParent()
Description copied from interface:ModelItem
Retrieves the parent of the item
-
setParent
public void setParent(ModelItemGroup parent)
Description copied from interface:ModelItem
Sets the parent of the item
-
toJSON
public Map<String,Object> toJSON(DefinitionContext context) throws ProcessingException
Description copied from interface:ModelItem
Converts the model item in a JSON map- Specified by:
toJSON
in 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:
true
if the JSON conversion should return an empty map,false
otherwise
-
toSAX
public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
Description copied from interface:ModelItem
Generates SAX events for the model item- Specified by:
toSAX
in interfaceModelItem
- Parameters:
contentHandler
- theContentHandler
that 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
- theContentHandler
that 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
- theContentHandler
that 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:
compareTo
in interfaceComparable<ModelItem>
-
setServiceManager
public static void setServiceManager(ServiceManager manager)
Set the service manager TheServiceManager
is used in the model items creation methods to get the model item type.ModelItem
is not aComponent
and can't have aServiceManager
itself. AnotherComponent
has to set it- Parameters:
manager
- the service manager to set
-
-