Package org.ametys.cms.contenttype
Class GetCommonAttributesAction
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.acting.AbstractAction
-
- org.apache.cocoon.acting.ServiceableAction
-
- org.ametys.cms.contenttype.GetCommonAttributesAction
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,Action
- Direct Known Subclasses:
GetCommonAttributesAction
public class GetCommonAttributesAction extends ServiceableAction
Get the common attributes between given content types and/or among given contents
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
__ALLOW_ENUMERATED
Allow enumerated attributesprotected static String
__ALLOW_NOT_ENUMERATED
Allow not enumerated attributesprotected static String[]
__NOT_SORTABLE_TYPE_IDS
Not sortable attribute typesprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content type EPprotected ContentTypesHelper
_contentTypesHelper
The content types Helperprotected I18nUtils
_i18nUtils
I18n utils-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description GetCommonAttributesAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,List<String>>
_getAcceptedTypesWithProperties(List<String> acceptedTypes)
Get the map of accepted types with its propertiesprotected boolean
_isInARepeater(ModelItem modelItem)
Checks if the given model item has a parent that is a repeaterprotected boolean
_modelItemPassesConditions(ModelItem modelItem, List<String> acceptedTypes, boolean onlySortable, boolean includeCompositeAndRepeaters, boolean includeSubRepeaters)
Indicates if the attribute should be retrieved or filtered out given the optionsprotected boolean
_passesAcceptedTypesCondition(List<String> acceptedTypes, ModelItem modelItem)
Checks if the model item passes conditions from accepted typesMap
act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
protected Set<String>
getAllAvailablesContentTypes(Request request, boolean publicOnly, boolean withResources)
Get all the available content typesprotected List<Map<String,Object>>
getCommonModelItemsInfo(Collection<String> contentTypeIds, String viewName, List<String> acceptedTypes, boolean onlySortable, boolean includeCompositesAndRepeaters, boolean withFullLabel, boolean hasResources, boolean includeSubRepeaters)
Retrieve model items information for a list of content typesprotected Set<String>
getContentTypes(Request request, boolean withResources)
Get the content types id to search forprotected String
getModelItemFullLabel(ModelItem modelItem)
Get the user friendly full label for the given model itemprotected Map<String,Object>
getModelItemInfo(ModelItem modelItem, boolean withFullLabel)
Get the model item's informationprotected void
handleSpecificInfo(List<Map<String,Object>> commonModelItemsInfo, boolean withLastModified, boolean withLastValidation, boolean withCreationDate, boolean hasResources, boolean withFullLabel)
Handle specific information, such as adding system properties into the model listvoid
service(ServiceManager smanager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__NOT_SORTABLE_TYPE_IDS
protected static final String[] __NOT_SORTABLE_TYPE_IDS
Not sortable attribute types
-
__ALLOW_ENUMERATED
protected static final String __ALLOW_ENUMERATED
Allow enumerated attributes- See Also:
- Constant Field Values
-
__ALLOW_NOT_ENUMERATED
protected static final String __ALLOW_NOT_ENUMERATED
Allow not enumerated attributes- See Also:
- Constant Field Values
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content type EP
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content types Helper
-
_i18nUtils
protected I18nUtils _i18nUtils
I18n utils
-
-
Constructor Detail
-
GetCommonAttributesAction
public GetCommonAttributesAction()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
- Throws:
Exception
-
getCommonModelItemsInfo
protected List<Map<String,Object>> getCommonModelItemsInfo(Collection<String> contentTypeIds, String viewName, List<String> acceptedTypes, boolean onlySortable, boolean includeCompositesAndRepeaters, boolean withFullLabel, boolean hasResources, boolean includeSubRepeaters)
Retrieve model items information for a list of content types- Parameters:
contentTypeIds
- the identifiers of the content typesviewName
- The view name to list model itemsacceptedTypes
- The types to accept. All types accepted if null or empty.onlySortable
- true to only accept sortable model items.includeCompositesAndRepeaters
- true to include the composites and repeaters as wellwithFullLabel
- true to use the full label of the model items, false otherwisehasResources
- true if there is at least one content type that is a resource, false otherwise.includeSubRepeaters
- true to include the children of repeaters as well- Returns:
- The list of common model items properties (each set of properties is a map representing the model item)
-
_modelItemPassesConditions
protected boolean _modelItemPassesConditions(ModelItem modelItem, List<String> acceptedTypes, boolean onlySortable, boolean includeCompositeAndRepeaters, boolean includeSubRepeaters)
Indicates if the attribute should be retrieved or filtered out given the options- Parameters:
modelItem
- the attribute definitionacceptedTypes
- The types to accept. All types accepted if null or empty.onlySortable
- true to only accept sortable attributes.includeCompositeAndRepeaters
- true to include the composites and repeaters as wellincludeSubRepeaters
- true to include the children of repeaters as well- Returns:
- true if the model item passes the conditions
-
_passesAcceptedTypesCondition
protected boolean _passesAcceptedTypesCondition(List<String> acceptedTypes, ModelItem modelItem)
Checks if the model item passes conditions from accepted types- Parameters:
acceptedTypes
- the accepted typesmodelItem
- the model item to check- Returns:
- true if the model item passes conditions
-
_getAcceptedTypesWithProperties
protected Map<String,List<String>> _getAcceptedTypesWithProperties(List<String> acceptedTypes)
Get the map of accepted types with its properties- Parameters:
acceptedTypes
- the accepted types configuration- Returns:
- the map of accepted type with its properties
-
_isInARepeater
protected boolean _isInARepeater(ModelItem modelItem)
Checks if the given model item has a parent that is a repeater- Parameters:
modelItem
- the model item to check- Returns:
true
if the given model item has a parent that is a repeater,false
otherwise
-
getModelItemInfo
protected Map<String,Object> getModelItemInfo(ModelItem modelItem, boolean withFullLabel)
Get the model item's information- Parameters:
modelItem
- the model itemwithFullLabel
- true to use the full label of the model item, false otherwise- Returns:
- Model item's information as a map of properties
-
getModelItemFullLabel
protected String getModelItemFullLabel(ModelItem modelItem)
Get the user friendly full label for the given model item- Parameters:
modelItem
- the model items- Returns:
- The full label of the model item
-
handleSpecificInfo
protected void handleSpecificInfo(List<Map<String,Object>> commonModelItemsInfo, boolean withLastModified, boolean withLastValidation, boolean withCreationDate, boolean hasResources, boolean withFullLabel)
Handle specific information, such as adding system properties into the model list- Parameters:
commonModelItemsInfo
- the mapping of model items' propertieswithLastModified
- true to add the last modification date to the model item's infowithLastValidation
- true to add the last validation date to the model item's infowithCreationDate
- true to add the creation date to the model item's infohasResources
- true if there is at least one content type that is a resource, false otherwise.withFullLabel
- true to use the full label of the model items, false otherwise
-
getContentTypes
protected Set<String> getContentTypes(Request request, boolean withResources)
Get the content types id to search for- Parameters:
request
- the requestwithResources
- is there at least one resource ?- Returns:
- the content types
-
getAllAvailablesContentTypes
protected Set<String> getAllAvailablesContentTypes(Request request, boolean publicOnly, boolean withResources)
Get all the available content types- Parameters:
request
- the requestpublicOnly
- Only the non private content types will be returnedwithResources
- True to add the resources to the list (which is not a content type)- Returns:
- all the available content types
-
-