Package org.ametys.runtime.model
Class AbstractViewParser
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.runtime.model.AbstractViewParser
- All Implemented Interfaces:
ViewParser
,LogEnabled
- Direct Known Subclasses:
AbstractContentTypeViewParser
Abstract component that parses view's configuration
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Pattern
The pattern to find view references in model item referencesprotected static final String
The regex to remove view references in model item referencesFields inherited from interface org.ametys.runtime.model.ViewParser
ADD_GROUP_TAG_NAME, ADD_ITEM_TAG_NAME, ALL_ITEMS_REFERENCE, ITEM_REFERENCE_ATTRIBUTE_NAME, REMOVE_ITEM_TAG_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_addItemToOverriddenView
(View view, ViewItem viewItem, Configuration itemConfiguration) Add the viewItem to the view or in a location inside the view (in a group or before/after another view item)protected void
_addItemToViewItemAccessor
(ViewItemAccessor viewItemAccessor, ViewItem viewItem, Configuration itemConfiguration, View referenceView, boolean override) Add an item to a view or to an overridden viewprotected ModelViewItem
_createModelViewItemInstance
(ModelItem modelItem) Creates an instance ofModelViewItem
due to the givenModelItem
protected ViewItemAccessor
_createViewItemAccessor
(Configuration itemConfiguration, String modelItemAccessorPath, ViewItemAccessor viewItemAccessor, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) Creates view items corresponding to the given path.protected void
_fillViewGeneralInformation
(ModelHelper.ConfigurationAndPluginName viewConfiguration, View view, View existingView, Collection<? extends Model> model) Fill the general information of the given view (label, description, ...)protected Configuration
_getAddItemChildConfiguration
(Configuration accessorConfiguration) Retrieves the child configuration to add items to the current accessorprotected abstract Collection<? extends Model>
Retrieves the model corresponding to the view to parseprotected ModelItem
_getModelItem
(ModelHelper.ConfigurationAndPluginName itemConfiguration, String modelItemName, Collection<? extends ModelItemAccessor> parents) Retrieves the model item with the given nameprotected String
_getModelItemReference
(Configuration itemConfiguration) Retrieves the model item reference from the given item configurationprotected void
_insertItemInViewItemAccessor
(ViewItemAccessor viewItemAccessor, ViewItem viewItem, Configuration itemConfiguration) Insert an item in the givenViewItemAccessor
protected boolean
_isAddingGroupConfiguration
(Configuration itemConfiguration) Checks if the given item configuration is an adding group configurationprotected boolean
_isAddingItemConfiguration
(Configuration itemConfiguration) Checks if the given item configuration is an adding item configurationprotected boolean
_isRemovingItemConfiguration
(Configuration itemConfiguration) Checks if the given item configuration is a removing item configurationprotected void
_parseModelViewItem
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor parentViewItemAccessor, Collection<? extends ModelItemAccessor> parentModelItemAccessors, View referenceView, boolean override) Parses a model view item and add it to its parent view item accessorprotected void
_parseSimpleViewItemGroup
(ModelHelper.ConfigurationAndPluginName itemConfiguration, String role, ViewItemAccessor parent, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) Parses a simple view item group and add it to its parentprotected void
_parseSimpleViewItemGroupChild
(ModelHelper.ConfigurationAndPluginName itemConfiguration, SimpleViewItemGroup group, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) Parses the item with the given configuration and add the item to the given groupprotected void
_parseViewChild
(ModelHelper.ConfigurationAndPluginName itemConfiguration, View view, Collection<? extends Model> model, boolean override) Parses the item with the given configuration and add the item to the given viewprotected ViewElement
_parseViewElement
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ElementDefinition definition, View referenceView, boolean override) Parses the view elementprotected void
_parseViewItemAccessorChild
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor viewItemAccessor, ModelItemAccessor modelItemAccessor, View referenceView, boolean override) Parses the item with the given configuration and add the item to the given view item accessorprotected String
_parseViewName
(ModelHelper.ConfigurationAndPluginName viewConfiguration) Parses the name of the viewprotected abstract void
_parseViewReference
(String viewName, ViewItemAccessor viewItemAccessor, ModelItemAccessor definition) Parses the view reference to add items of the view to the given item accessorprotected void
_removeViewItemFromView
(View view, Configuration itemConfiguration) Removes a view item from the viewprotected ModelViewItem
createModelViewItem
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ModelItem modelItem, View referenceView, boolean override) Creates the model view item corresponding to the given configurationprotected ModelViewItem
createModelViewItemForAllItemsReference
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ModelItem modelItem, View referenceView, boolean override) Creates the model view item corresponding to the given configuration, in cas of all items referencesoverrideView
(ModelHelper.ConfigurationAndPluginName viewConfiguration, View existingView) Parses a view configuration to override aView
object.protected void
parseAllModelViewItems
(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor parentViewItemAccessor, Collection<? extends ModelItemAccessor> parentModelItemAccessors, View referenceView, boolean override) Parses all the model view items of the given parentsparseView
(ModelHelper.ConfigurationAndPluginName viewConfiguration) Parses a view configuration to create aView
object.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
__VIEW_REFERENCE_REGEX
The regex to remove view references in model item references- See Also:
-
__VIEW_REFERENCE_PATTERN
The pattern to find view references in model item references
-
-
Constructor Details
-
AbstractViewParser
public AbstractViewParser()
-
-
Method Details
-
parseView
public View parseView(ModelHelper.ConfigurationAndPluginName viewConfiguration) throws ConfigurationException Description copied from interface:ViewParser
Parses a view configuration to create aView
object.- Specified by:
parseView
in interfaceViewParser
- Parameters:
viewConfiguration
- the configuration of the view to parse- Returns:
- the view
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseViewName
protected String _parseViewName(ModelHelper.ConfigurationAndPluginName viewConfiguration) throws ConfigurationException Parses the name of the view- Parameters:
viewConfiguration
- the view's configuration- Returns:
- the view's name
- Throws:
ConfigurationException
- if an error occurs while parsing the view's name
-
overrideView
public View overrideView(ModelHelper.ConfigurationAndPluginName viewConfiguration, View existingView) throws ConfigurationException Description copied from interface:ViewParser
Parses a view configuration to override aView
object.- Specified by:
overrideView
in interfaceViewParser
- Parameters:
viewConfiguration
- the configuration of the view to parseexistingView
- The view to override- Returns:
- the overridden view
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_getModel
Retrieves the model corresponding to the view to parse- Returns:
- the model
-
_fillViewGeneralInformation
protected void _fillViewGeneralInformation(ModelHelper.ConfigurationAndPluginName viewConfiguration, View view, View existingView, Collection<? extends Model> model) throws ConfigurationException Fill the general information of the given view (label, description, ...)- Parameters:
viewConfiguration
- the configuration of the view to fillview
- the view to fillexistingView
- the existing view, that may already contain general informationmodel
- The model of the view- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseViewChild
protected void _parseViewChild(ModelHelper.ConfigurationAndPluginName itemConfiguration, View view, Collection<? extends Model> model, boolean override) throws ConfigurationException Parses the item with the given configuration and add the item to the given view- Parameters:
itemConfiguration
- the configuration of the item to parseview
- the viewmodel
- The model containing the parsed itemoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid.
-
_isAddingItemConfiguration
Checks if the given item configuration is an adding item configuration- Parameters:
itemConfiguration
- the item configuration- Returns:
true
if the given item configuration is an adding item configuration,false
otherwise
-
_isRemovingItemConfiguration
Checks if the given item configuration is a removing item configuration- Parameters:
itemConfiguration
- the item configuration- Returns:
true
if the given item configuration is a removing item configuration,false
otherwise
-
_isAddingGroupConfiguration
Checks if the given item configuration is an adding group configuration- Parameters:
itemConfiguration
- the item configuration- Returns:
true
if the given item configuration is an adding group configuration,false
otherwise
-
_parseModelViewItem
protected void _parseModelViewItem(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor parentViewItemAccessor, Collection<? extends ModelItemAccessor> parentModelItemAccessors, View referenceView, boolean override) throws ConfigurationException Parses a model view item and add it to its parent view item accessor- Parameters:
itemConfiguration
- configuration of the model view itemparentViewItemAccessor
- the parent view item accessor of the model view item to parseparentModelItemAccessors
- the parents model item accessors of the model item corresponding to the model view item to parsereferenceView
- view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseViewReference
protected abstract void _parseViewReference(String viewName, ViewItemAccessor viewItemAccessor, ModelItemAccessor definition) throws ConfigurationException Parses the view reference to add items of the view to the given item accessor- Parameters:
viewName
- the name of the referenced viewviewItemAccessor
- the view item accessor referencing the viewdefinition
- the definition of the model item containing the referenced view- Throws:
ConfigurationException
- if the configuration is not valid
-
parseAllModelViewItems
protected void parseAllModelViewItems(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor parentViewItemAccessor, Collection<? extends ModelItemAccessor> parentModelItemAccessors, View referenceView, boolean override) throws ConfigurationException Parses all the model view items of the given parents- Parameters:
itemConfiguration
- the item configurationparentViewItemAccessor
- the parent view item accessorparentModelItemAccessors
- the parent model item accorssorsreferenceView
- view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid.
-
createModelViewItemForAllItemsReference
protected ModelViewItem createModelViewItemForAllItemsReference(ModelHelper.ConfigurationAndPluginName itemConfiguration, ModelItem modelItem, View referenceView, boolean override) throws ConfigurationException Creates the model view item corresponding to the given configuration, in cas of all items references- Parameters:
itemConfiguration
- configuration of the model view itemmodelItem
- the model itemreferenceView
- view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Returns:
- the created model view item
- Throws:
ConfigurationException
- if the configuration is not valid.
-
createModelViewItem
protected ModelViewItem createModelViewItem(ModelHelper.ConfigurationAndPluginName itemConfiguration, ModelItem modelItem, View referenceView, boolean override) throws ConfigurationException Creates the model view item corresponding to the given configuration- Parameters:
itemConfiguration
- configuration of the model view itemmodelItem
- the model itemreferenceView
- view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Returns:
- the created model view item
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_createViewItemAccessor
protected ViewItemAccessor _createViewItemAccessor(Configuration itemConfiguration, String modelItemAccessorPath, ViewItemAccessor viewItemAccessor, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) throws ConfigurationException Creates view items corresponding to the given path.- Parameters:
itemConfiguration
- the configuration containing the model item referencemodelItemAccessorPath
- The path of the model item accessor to retrieveviewItemAccessor
- the view item accessor relative to the given pathmodelItemAccessors
- the model item accessor relative to the given pathreferenceView
- the reference view for includesoverride
-true
if the configuration is an override,false
otherwise- Returns:
- the found or created view item accessor
- Throws:
ConfigurationException
- if the given path does not correspond to a model item accessor
-
_getModelItem
protected ModelItem _getModelItem(ModelHelper.ConfigurationAndPluginName itemConfiguration, String modelItemName, Collection<? extends ModelItemAccessor> parents) throws ConfigurationException Retrieves the model item with the given name- Parameters:
itemConfiguration
- configuration of the model view itemmodelItemName
- the model item nameparents
- the accessors containing the model item- Returns:
- the model item
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_getModelItemReference
protected String _getModelItemReference(Configuration itemConfiguration) throws ConfigurationException Retrieves the model item reference from the given item configuration- Parameters:
itemConfiguration
- the item configuration- Returns:
- the model item reference
- Throws:
ConfigurationException
- if an error occurs while parsing the model item reference
-
_getAddItemChildConfiguration
Retrieves the child configuration to add items to the current accessor- Parameters:
accessorConfiguration
- the accessor configuration- Returns:
- the child configuration to add items to the current accessor
-
_parseViewElement
protected ViewElement _parseViewElement(ModelHelper.ConfigurationAndPluginName itemConfiguration, ElementDefinition definition, View referenceView, boolean override) throws ConfigurationException Parses the view element- Parameters:
itemConfiguration
- configuration of the view itemdefinition
- definition of the elementreferenceView
- view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Returns:
- the view item
- Throws:
ConfigurationException
- if the configuration is not valid
-
_createModelViewItemInstance
Creates an instance ofModelViewItem
due to the givenModelItem
- Parameters:
modelItem
- the model item corresponding to the view item to create- Returns:
- the created view item
-
_parseViewItemAccessorChild
protected void _parseViewItemAccessorChild(ModelHelper.ConfigurationAndPluginName itemConfiguration, ViewItemAccessor viewItemAccessor, ModelItemAccessor modelItemAccessor, View referenceView, boolean override) throws ConfigurationException Parses the item with the given configuration and add the item to the given view item accessor- Parameters:
itemConfiguration
- the configuration of the item to parseviewItemAccessor
- theViewItemAccessor
that will access to the parsed itemsmodelItemAccessor
- theModelItemAccessor
corresponding to the given view item accessorreferenceView
- The view that references the itemoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid
-
_parseSimpleViewItemGroup
protected void _parseSimpleViewItemGroup(ModelHelper.ConfigurationAndPluginName itemConfiguration, String role, ViewItemAccessor parent, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) throws ConfigurationException Parses a simple view item group and add it to its parent- Parameters:
itemConfiguration
- configuration of the simple view item grouprole
- the role of the view groupparent
- the parent view item accessormodelItemAccessors
- the current parent model item accessorsreferenceView
- the reference view for includesoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseSimpleViewItemGroupChild
protected void _parseSimpleViewItemGroupChild(ModelHelper.ConfigurationAndPluginName itemConfiguration, SimpleViewItemGroup group, Collection<? extends ModelItemAccessor> modelItemAccessors, View referenceView, boolean override) throws ConfigurationException Parses the item with the given configuration and add the item to the given group- Parameters:
itemConfiguration
- configuration of the group's childgroup
- the simple view item groupmodelItemAccessors
- the current parent model item accessorsreferenceView
- the reference view for includesoverride
-true
if the configuration is an override,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid.
-
_addItemToViewItemAccessor
protected void _addItemToViewItemAccessor(ViewItemAccessor viewItemAccessor, ViewItem viewItem, Configuration itemConfiguration, View referenceView, boolean override) throws ConfigurationException Add an item to a view or to an overridden view- Parameters:
viewItemAccessor
- The viewviewItem
- The view item to additemConfiguration
- The item's configurationsreferenceView
- the reference view for includesoverride
-true
if the view is an override,false
otherwise- Throws:
ConfigurationException
- If an error occurs
-
_addItemToOverriddenView
protected void _addItemToOverriddenView(View view, ViewItem viewItem, Configuration itemConfiguration) throws ConfigurationException Add the viewItem to the view or in a location inside the view (in a group or before/after another view item)- Parameters:
view
- The view in which to insert the new ItemviewItem
- The viewItem to insertitemConfiguration
- The configuration of the viewItem- Throws:
ConfigurationException
- If an error occurs
-
_insertItemInViewItemAccessor
protected void _insertItemInViewItemAccessor(ViewItemAccessor viewItemAccessor, ViewItem viewItem, Configuration itemConfiguration) throws ConfigurationException Insert an item in the givenViewItemAccessor
- Parameters:
viewItemAccessor
- The view item accessor in which to insert the new ItemviewItem
- The viewItem to insertitemConfiguration
- The configuration of the viewItem- Throws:
ConfigurationException
- If an error occurs
-
_removeViewItemFromView
protected void _removeViewItemFromView(View view, Configuration itemConfiguration) throws ConfigurationException Removes a view item from the view- Parameters:
view
- The view from which we want to remove an itemitemConfiguration
- The configuration of the view item to remove- Throws:
ConfigurationException
- If there is an error whil parsing the item configuration
-