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
FieldsFields inherited from class org.ametys.runtime.model.AbstractModelItem
__serviceManagerFields inherited from interface org.ametys.runtime.model.ModelItem
ITEM_PATH_SEPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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 mapvoidAdd a child in the groupvoidAdd 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 ModelItemGroupCreates aModelItemGroupvoidSets the model of the elementvoidsetType(ModelItemType type) Set the type.toJSON(DefinitionContext context, boolean includeChildren) Converts the model item group in a JSON mapvoidtoSAX(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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ametys.runtime.model.ModelItem
getCriterionWidget, getCriterionWidgetParametersMethods 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:ModelItemAccessorRetrieves all the model items of this accessor- Specified by:
getModelItemsin 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:ModelItemSets the model of the element- Specified by:
setModelin interfaceModelItem- Overrides:
setModelin classAbstractModelItem- Parameters:
model- the model to set
-
getType
Description copied from interface:ModelItemRetrieves the type. -
setType
Description copied from interface:ModelItemSet the type. -
_toJSON
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
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
Creates aModelItemGroup- Parameters:
name- the group's namechildren- the group's children- Returns:
- the created
ModelItemGroup
-