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
Class for group of model items
-
Field Summary
Fields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManager
Fields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR
-
Constructor Summary
ConstructorDescriptionDefault constructor.ModelItemGroup
(String name, ModelItem... children) Constructor used to create simple models and items -
Method Summary
Modifier and TypeMethodDescription_toJSON
(DefinitionContext context) Converts the model item in a JSON map_toJSON
(DefinitionContext context, boolean includeChildren) Converts the model item group in a JSON mapvoid
Add a child in the groupvoid
Add a child in the groupRetrieves the list of children model itemsgetChildren
(boolean withSwitch) Retrieves the list of children model items, with or without the switcherRetrieves all the model items of this accessorRetrieves the switcher element definitiongetType()
Retrieves the type.static ModelItemGroup
Creates aModelItemGroup
void
Sets the model of the elementvoid
setType
(ModelItemType type) Set the type.toJSON
(DefinitionContext context, boolean includeChildren) Converts the model item group in a JSON mapvoid
toSAX
(ContentHandler contentHandler, DefinitionContext context) Generates SAX events for the model itemMethods 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 Details
-
DEFAULT_TYPE_ID
Id for model item group types- See Also:
-
-
Constructor Details
-
ModelItemGroup
public ModelItemGroup()Default constructor. -
ModelItemGroup
Constructor used to create simple models and items- Parameters:
name
- the name of the definitionchildren
- the group's children
-
-
Method Details
-
getModelItems
Description copied from interface:ModelItemAccessor
Retrieves all the model items of this accessor- Specified by:
getModelItems
in interfaceModelItemAccessor
- Returns:
- the model items
-
getChildren
Retrieves the list of children model items- Returns:
- the children
-
getChildren
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
Add a child in the group- Parameters:
child
- the item to add
-
addChild
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
Retrieves the switcher element definition- Returns:
- the switcher
-
setModel
Description copied from interface:ModelItem
Sets the model of the element- Specified by:
setModel
in interfaceModelItem
- Overrides:
setModel
in classAbstractModelItem
- Parameters:
model
- the model to set
-
getType
Description copied from interface:ModelItem
Retrieves the type. -
setType
Description copied from interface:ModelItem
Set the type. -
_toJSON
Description copied from class:AbstractModelItem
Converts the model item in a JSON map- Overrides:
_toJSON
in 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
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:
toSAX
in interfaceModelItem
- Overrides:
toSAX
in classAbstractModelItem
- 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
-
of
Creates aModelItemGroup
- Parameters:
name
- the group's namechildren
- the group's children- Returns:
- the created
ModelItemGroup
-