Package org.ametys.cms.contenttype
Class ContentTypeViewParser
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.contenttype.ContentTypeViewParser
-
- All Implemented Interfaces:
ViewParser
,Component
,LogEnabled
,Serviceable
public class ContentTypeViewParser extends AbstractLogEnabled implements ViewParser, Component, Serviceable
Component that parses the configuration of a content type's view
-
-
Field Summary
Fields Modifier and Type Field Description protected String
_attributeRefTagName
The tag name for attribute referencesprotected ContentType
_contentType
The content type containing viewprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content type extension pointprotected ContentTypesHelper
_contentTypesHelper
The content types helperprotected ContentTypesParserHelper
_contentTypesParserHelper
The content types parser helperprotected String
_groupTagName
The tag name for simple groupsprotected SourceResolver
_srcResolver
The source resolverprotected boolean
_supportsNestedAttributes
Determine if this parser supports attribute nested in an attribute of type contentstatic String
DEFAULT_ATTRIBUTE_REF_TAG_NAME
Default tag name for references to attributes-
Fields inherited from interface org.ametys.runtime.model.ViewParser
ALL_ITEMS_REFERENCE, DEFAULT_GROUP_TAG_NAME, DEFAULT_ITEM_REF_TAG_NAME
-
-
Constructor Summary
Constructors Constructor Description ContentTypeViewParser(ContentType contentType)
Creates a view parser for content typesContentTypeViewParser(ContentType contentType, Optional<String> groupTagName, Optional<String> attributeRefTagName, boolean supportsNestedAttributes)
Creates a view parser for content types
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_fillViewItems(Configuration viewConfiguration, View view)
Fill the items of the given viewprotected View
_getViewToInclude(Configuration itemConfiguration, String viewName)
Retrieves the view included by the given configurationprotected ViewElement
_parseContentAttributeViewItem(Configuration itemConfiguration, ContentAttributeDefinition definition, String path, View referenceView)
Parses the view item referencing an attribute of type contentprotected ModelViewItemGroup
_parseDublinCoreViewItems()
Parses the DublinCore view items.protected ModelViewItem
_parseModelViewItem(Configuration itemConfiguration, String parentPath, View referenceView)
Parses a model view itemprotected SimpleViewItemGroup
_parseSimpleViewItemGroup(Configuration itemConfiguration, String parentPath, String role, View referenceView)
Parses a simple view item groupprotected void
_parseViewItemAccessorChildren(Configuration itemConfiguration, ViewItemAccessor viewItemAccessor, String modelItemPath, View referenceView)
Parses the items of the givenViewItemAccessor
protected boolean
_shouldInsertAllAccessorItems(Configuration accessorConfiguration)
Checks if all the items of the current accessor should be inserted in the viewView
parseView(Configuration viewConfiguration)
Parses a view configuration to create aView
object.void
service(ServiceManager manager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
DEFAULT_ATTRIBUTE_REF_TAG_NAME
public static final String DEFAULT_ATTRIBUTE_REF_TAG_NAME
Default tag name for references to attributes- See Also:
- Constant Field Values
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content type extension point
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content types helper
-
_contentTypesParserHelper
protected ContentTypesParserHelper _contentTypesParserHelper
The content types parser helper
-
_srcResolver
protected SourceResolver _srcResolver
The source resolver
-
_contentType
protected ContentType _contentType
The content type containing view
-
_groupTagName
protected String _groupTagName
The tag name for simple groups
-
_attributeRefTagName
protected String _attributeRefTagName
The tag name for attribute references
-
_supportsNestedAttributes
protected boolean _supportsNestedAttributes
Determine if this parser supports attribute nested in an attribute of type content
-
-
Constructor Detail
-
ContentTypeViewParser
public ContentTypeViewParser(ContentType contentType)
Creates a view parser for content types- Parameters:
contentType
- the content type containing the view
-
ContentTypeViewParser
public ContentTypeViewParser(ContentType contentType, Optional<String> groupTagName, Optional<String> attributeRefTagName, boolean supportsNestedAttributes)
Creates a view parser for content types- Parameters:
contentType
- the content type containing the viewgroupTagName
- the tag name for simple groupsattributeRefTagName
- the tag name for attribute referencessupportsNestedAttributes
-false
to avoid this parser to support nested attributes
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
parseView
public View parseView(Configuration 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.
-
_fillViewItems
protected void _fillViewItems(Configuration viewConfiguration, View view) throws ConfigurationException
Fill the items of the given view- Parameters:
viewConfiguration
- the configuration of the view to fillview
- the view to fill- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseModelViewItem
protected ModelViewItem _parseModelViewItem(Configuration itemConfiguration, String parentPath, View referenceView) throws ConfigurationException
Parses a model view item- Parameters:
itemConfiguration
- configuration of the model view itemparentPath
- path of the parent of the model view itemreferenceView
- view that references the item- Returns:
- the model view item
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_parseContentAttributeViewItem
protected ViewElement _parseContentAttributeViewItem(Configuration itemConfiguration, ContentAttributeDefinition definition, String path, View referenceView) throws ConfigurationException
Parses the view item referencing an attribute of type content- Parameters:
itemConfiguration
- configuration of the view itemdefinition
- definition of the attributepath
- path of the item in the viewreferenceView
- view that references the item- Returns:
- the view item
- Throws:
ConfigurationException
- if the configuration is not valid
-
_shouldInsertAllAccessorItems
protected boolean _shouldInsertAllAccessorItems(Configuration accessorConfiguration) throws ConfigurationException
Checks if all the items of the current accessor should be inserted in the view- Parameters:
accessorConfiguration
- configuration of the current accessor- Returns:
true
if all items of the current accessor should be inserted in the view,false
otherwise- Throws:
ConfigurationException
- if the configuration is not valid
-
_parseViewItemAccessorChildren
protected void _parseViewItemAccessorChildren(Configuration itemConfiguration, ViewItemAccessor viewItemAccessor, String modelItemPath, View referenceView) throws ConfigurationException
Parses the items of the givenViewItemAccessor
- Parameters:
itemConfiguration
- configuration of the model view itemviewItemAccessor
- theViewItemAccessor
that will access to the parsed itemsmodelItemPath
- path of the model view item.referenceView
- The view that references the item- Throws:
ConfigurationException
- if the configuration is not valid
-
_parseSimpleViewItemGroup
protected SimpleViewItemGroup _parseSimpleViewItemGroup(Configuration itemConfiguration, String parentPath, String role, View referenceView) throws ConfigurationException
Parses a simple view item group- Parameters:
itemConfiguration
- configuration of the simple view item groupparentPath
- path of the model item parent of the group.role
- role of the view groupreferenceView
- the reference view for includes- Returns:
- the simple view item group
- Throws:
ConfigurationException
- if the configuration is not valid.
-
_getViewToInclude
protected View _getViewToInclude(Configuration itemConfiguration, String viewName) throws ConfigurationException
Retrieves the view included by the given configuration- Parameters:
itemConfiguration
- configuration of the item that includes the viewviewName
- name of the view containing the item. (the item can be the view itself or a simple view item group inside the view)- Returns:
- the view included by the given configuration
- Throws:
ConfigurationException
- if the configuration is not valid
-
_parseDublinCoreViewItems
protected ModelViewItemGroup _parseDublinCoreViewItems() throws ConfigurationException
Parses the DublinCore view items.- Returns:
- the group containing the dublin core view items
- Throws:
ConfigurationException
- if the configuration is not valid.
-
-