Package org.ametys.runtime.model
Class ModelItemGroup
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItem
-
- org.ametys.runtime.model.ModelItemGroup
-
- All Implemented Interfaces:
Comparable<ModelItem>,ModelItem,ModelItemAccessor,ModelItemContainer,Labelable,ModifiableLabelable
- Direct Known Subclasses:
CompositeDefinition,RepeaterDefinition
public class ModelItemGroup extends AbstractModelItem implements ModelItemContainer
Class for group of model items
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TYPE_IDId for model item group types-
Fields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManager
-
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description ModelItemGroup()Default constructor.ModelItemGroup(String name, ModelItem... children)Constructor used to create simple models and items
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>_toJSON(DefinitionContext context)Converts the model item in a JSON mapprotected Map<String,Object>_toJSON(DefinitionContext context, boolean includeChildren)Converts the model item group in a JSON mapvoidaddChild(ModelItem child)Add a child in the groupvoidaddChild(ModelItem child, boolean isGroupSwitch)Add a child in the groupList<ModelItem>getChildren()Retrieves the list of children model itemsList<ModelItem>getChildren(boolean withSwitch)Retrieves the list of children model items, with or without the switcherCollection<ModelItem>getModelItems()Retrieves all the model items of this accessorElementDefinition<Boolean>getSwitcher()Retrieves the switcher element definitionModelItemTypegetType()Retrieves the type.static ModelItemGroupof(String name, ModelItem... children)Creates aModelItemGroupvoidsetModel(Model model)Sets the model of the elementvoidsetType(ModelItemType type)Set the type.Map<String,Object>toJSON(DefinitionContext context, boolean includeChildren)Converts the model item group in a JSON mapvoidtoSAX(ContentHandler contentHandler, DefinitionContext context)Generates SAX events for the model item-
Methods inherited from class org.ametys.runtime.model.AbstractModelItem
_shouldJSONBeEmpty, _widgetParameterToSAX, _widgetToSAX, addItemChecker, compareTo, equals, getDescription, getDisableConditions, getItemCheckers, getLabel, getModel, getName, getParent, getPath, getPluginName, getWidget, getWidgetParameters, hashCode, setDescription, setDisableConditions, setLabel, setName, setParent, setPluginName, setServiceManager, setWidget, setWidgetParameters, toJSON, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.runtime.model.ModelItemAccessor
getChild, getModelItem, hasModelItem
-
-
-
-
Field Detail
-
DEFAULT_TYPE_ID
public static final String DEFAULT_TYPE_ID
Id for model item group types- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ModelItemGroup
public ModelItemGroup()
Default constructor.
-
ModelItemGroup
public ModelItemGroup(String name, ModelItem... children)
Constructor used to create simple models and items- Parameters:
name- the name of the definitionchildren- the group's children
-
-
Method Detail
-
getModelItems
public Collection<ModelItem> getModelItems()
Description copied from interface:ModelItemAccessorRetrieves all the model items of this accessor- Specified by:
getModelItemsin interfaceModelItemAccessor- Returns:
- the model items
-
getChildren
public List<ModelItem> getChildren()
Retrieves the list of children model items- Returns:
- the children
-
getChildren
public List<ModelItem> getChildren(boolean withSwitch)
Retrieves the list of children model items, with or without the switcher- Parameters:
withSwitch- true to retrieve the switcher with the other children- Returns:
- the children with or without the switcher
-
addChild
public void addChild(ModelItem child)
Add a child in the group- Parameters:
child- the item to add
-
addChild
public void addChild(ModelItem child, boolean isGroupSwitch)
Add a child in the group- Parameters:
child- the child to addisGroupSwitch- true if the child to add is the group switch, false otherwise
-
getSwitcher
public ElementDefinition<Boolean> getSwitcher()
Retrieves the switcher element definition- Returns:
- the switcher
-
setModel
public void setModel(Model model)
Description copied from interface:ModelItemSets the model of the element- Specified by:
setModelin interfaceModelItem- Overrides:
setModelin classAbstractModelItem- Parameters:
model- the model to set
-
getType
public ModelItemType getType()
Description copied from interface:ModelItemRetrieves the type.
-
setType
public void setType(ModelItemType type)
Description copied from interface:ModelItemSet the type.
-
_toJSON
protected Map<String,Object> _toJSON(DefinitionContext context) throws ProcessingException
Description copied from class:AbstractModelItemConverts the model item in a JSON map- Overrides:
_toJSONin classAbstractModelItem- 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
-
toJSON
public Map<String,Object> toJSON(DefinitionContext context, boolean includeChildren) throws ProcessingException
Converts the model item group in a JSON map- Parameters:
context- the context of the definitionincludeChildren- true to iterate and add children as elements in the returned JSON map, false otherwise- Returns:
- The model item as a JSON map
- Throws:
ProcessingException- If an error occurs when converting the model item group
-
_toJSON
protected Map<String,Object> _toJSON(DefinitionContext context, boolean includeChildren) throws ProcessingException
Converts the model item group in a JSON map- Parameters:
context- the context of the definitionincludeChildren- true to iterate and add children as elements in the returned JSON map, false otherwise- Returns:
- The model item as a JSON map
- Throws:
ProcessingException- If an error occurs when converting the model item group
-
toSAX
public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
Generates SAX events for the model item Do not generate SAX events for children. This method has been created to generate SAX events for views, the children are taken into account via view items children- Specified by:
toSAXin interfaceModelItem- Overrides:
toSAXin classAbstractModelItem- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventscontext- the context of the definition- Throws:
SAXException- if an error occurs during the SAX events generation
-
of
public static ModelItemGroup of(String name, ModelItem... children)
Creates aModelItemGroup- Parameters:
name- the group's namechildren- the group's children- Returns:
- the created
ModelItemGroup
-
-