Class SetContentAttributeClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.core.ui.StaticClientSideRelation
-
- org.ametys.cms.clientsideelement.relations.SetContentAttributeClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,ClientSideRelation
,LogEnabled
,PluginAware
,Component
,Configurable
,Serviceable
- Direct Known Subclasses:
SetContentAttributeClientSideElement
,SetParentContentClientSideElement
public class SetContentAttributeClientSideElement extends StaticClientSideRelation implements Component
Set the attribute of type 'content' of a content, with another content
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper
_contentHelper
The content helperprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content types extension pointprotected ContentTypesHelper
_contentTypesHelper
The content type helperprotected ContentWorkflowHelper
_contentWorkflowHelper
The content workflow helperprotected AmetysObjectResolver
_resolver
The Ametys object resolver-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description SetContentAttributeClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_clean(List<Map<String,String>> contentsToEditToRemove, List<String> workflowActionIds, List<I18nizableText> errorMessages, List<String> errorIds)
protected List<Map<String,Object>>
_convert(Set<ModelItem> attributeDefinitions)
Convert attribute definitions to JSON objectprotected Map<String,Object>
_convert(ModelItem attributeDefinition)
Convert an attribute definition to JSONprivate void
_doAction(WorkflowAwareContent content, List<String> workflowActionIds, Map<String,Object> values, List<String> errorIds, List<I18nizableText> errorMessages)
protected Map<WorkflowAwareContent,Integer>
_filterContentsToEdit(Map<WorkflowAwareContent,Integer> contentsToEdit, List<String> contentIdsToReference, List<I18nizableText> errorMessages, List<String> errorIds, Map<String,Object> additionalParams)
Filter the list of contents to editprotected Set<ModelItem>
_findCompatibleAttributes(List<? extends Content> contentsToReference, List<? extends Content> contentsToEdit)
Find the list of compatible attribute definitionsprivate Set<ModelItem>
_findCompatibleAttributes(List<? extends Content> contentsToReference, List<? extends Content> contentsToEdit, String targetContentTypeId, ModelItem modelItem, boolean anyParentIsMultiple, Collection<String> compatibleContentTypes, boolean requiresMultiple)
private Collection<String>
_getContentTypesIntersection(Collection<? extends Content> contents)
private boolean
_hasRight(List<? extends Content> contentsToEdit, RestrictedModelItem<Content> modelItem)
private boolean
_isAttributeCompatible(List<? extends Content> contentsToEdit, String targetContentTypeId, ContentAttributeDefinition attributeDefinition, boolean anyParentIsMultiple, Collection<String> compatibleContentTypes, boolean requiresMultiple)
private List<String>
_reorder(List<String> currentElements, List<String> elementsToReorder, int newPosition)
protected List<? extends Content>
_resolve(List<String> contentIds)
Resolve content by their identifiersprotected Map<? extends Content,Integer>
_resolve(Map<String,Integer> contentIds)
Resolve content by their identifiersprivate Map<String,Object>
_returnValue(List<I18nizableText> errorMessages, List<String> errorIds)
protected void
_setContentAttribute(List<String> contentIdsToReference, Map<WorkflowAwareContent,Integer> contentsToEdit, ContentType contentType, String attributePath, List<String> workflowActionIds, List<I18nizableText> errorMessages, List<String> errorIds, Map<String,Object> additionalParams)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'List<Map<String,Object>>
getCompatibleAttributes(List<String> contentIdsToReference, List<String> contentIdsToEdit)
Find an attribute of type content in definition of 'contentIdsToReference' and set the attribute of contents 'contentIdsToEdit' with value 'contentIdsToReference'void
service(ServiceManager manager)
Map<String,Object>
setContentAttribute(List<String> contentIdsToReference, Map<String,Integer> contentIdsToEdit, List<Map<String,String>> contentsToEditToRemove, String attributePath, List<String> workflowActionIds)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'Map<String,Object>
setContentAttribute(List<String> contentIdsToReference, Map<String,Integer> contentIdsToEdit, List<Map<String,String>> contentsToEditToRemove, String attributePath, List<String> workflowActionIds, Map<String,Object> additionalParams)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'-
Methods inherited from class org.ametys.core.ui.StaticClientSideRelation
configure, getSourceRelationType, getTargetRelationType
-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureClass, _configureParameters, _configureScript, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, getDependencies, getId, getPluginName, getRights, getScripts, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.core.ui.ClientSideElement
getDependencies, getId, getPluginName, getRights, getScripts, getScripts
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content type helper
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content types extension point
-
_contentWorkflowHelper
protected ContentWorkflowHelper _contentWorkflowHelper
The content workflow helper
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
-
Constructor Detail
-
SetContentAttributeClientSideElement
public SetContentAttributeClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
getCompatibleAttributes
public List<Map<String,Object>> getCompatibleAttributes(List<String> contentIdsToReference, List<String> contentIdsToEdit)
Find an attribute of type content in definition of 'contentIdsToReference' and set the attribute of contents 'contentIdsToEdit' with value 'contentIdsToReference'- Parameters:
contentIdsToReference
- The list of content identifiers that will be added as values in the content fieldcontentIdsToEdit
- The list of content identifiers to edit and that will have an attribute of type content modified- Returns:
- the list of all compatible attribute definitions
-
_convert
protected List<Map<String,Object>> _convert(Set<ModelItem> attributeDefinitions)
Convert attribute definitions to JSON object- Parameters:
attributeDefinitions
- The attribute definitions- Returns:
- the JSON object
-
_convert
protected Map<String,Object> _convert(ModelItem attributeDefinition)
Convert an attribute definition to JSON- Parameters:
attributeDefinition
- the attribute definition- Returns:
- the JSON object
-
_findCompatibleAttributes
protected Set<ModelItem> _findCompatibleAttributes(List<? extends Content> contentsToReference, List<? extends Content> contentsToEdit)
Find the list of compatible attribute definitions- Parameters:
contentsToReference
- the contents to referencecontentsToEdit
- the contents to edit- Returns:
- the list of compatible attribute definitions
-
_findCompatibleAttributes
private Set<ModelItem> _findCompatibleAttributes(List<? extends Content> contentsToReference, List<? extends Content> contentsToEdit, String targetContentTypeId, ModelItem modelItem, boolean anyParentIsMultiple, Collection<String> compatibleContentTypes, boolean requiresMultiple)
-
_isAttributeCompatible
private boolean _isAttributeCompatible(List<? extends Content> contentsToEdit, String targetContentTypeId, ContentAttributeDefinition attributeDefinition, boolean anyParentIsMultiple, Collection<String> compatibleContentTypes, boolean requiresMultiple)
-
_hasRight
private boolean _hasRight(List<? extends Content> contentsToEdit, RestrictedModelItem<Content> modelItem)
-
setContentAttribute
public Map<String,Object> setContentAttribute(List<String> contentIdsToReference, Map<String,Integer> contentIdsToEdit, List<Map<String,String>> contentsToEditToRemove, String attributePath, List<String> workflowActionIds)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'- Parameters:
contentIdsToReference
- The list of content identifiers that will be added as values in the content fieldcontentIdsToEdit
- The map {key: content identifiers to edit and that will have an attribute of type content modified; value: the new position if attribute is multiple and it is a reorder of values. May be null or equals to -1 if it is not a reorder}contentsToEditToRemove
- The list of content to edit to remove currently referenced content. Keys are "contentId" and "valueToRemove"attributePath
- The attribute path selected to do modification in the contents to editworkflowActionIds
- The identifiers of workflow actions to use to edit the attribute. Actions will be tested in this order and first available action will be used- Returns:
- A map with key success: true or false. if false, it can be due to errors (list of error messages)
-
setContentAttribute
public Map<String,Object> setContentAttribute(List<String> contentIdsToReference, Map<String,Integer> contentIdsToEdit, List<Map<String,String>> contentsToEditToRemove, String attributePath, List<String> workflowActionIds, Map<String,Object> additionalParams)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'- Parameters:
contentIdsToReference
- The list of content identifiers that will be added as values in the content fieldcontentIdsToEdit
- The map {key: content identifiers to edit and that will have an attribute of type content modified; value: the new position if attribute is multiple and it is a reorder of values. May be null or equals to -1 if it is not a reorder}contentsToEditToRemove
- The list of content to edit to remove currently referenced content. Keys are "contentId" and "valueToRemove"attributePath
- The attribute path selected to do modification in the contents to editworkflowActionIds
- The identifiers of workflow actions to use to edit the attribute. Actions will be tested in this order and first available action will be usedadditionalParams
- the map of additional parameters- Returns:
- A map with key success: true or false. if false, it can be due to errors (list of error messages)
-
_filterContentsToEdit
protected Map<WorkflowAwareContent,Integer> _filterContentsToEdit(Map<WorkflowAwareContent,Integer> contentsToEdit, List<String> contentIdsToReference, List<I18nizableText> errorMessages, List<String> errorIds, Map<String,Object> additionalParams)
Filter the list of contents to edit- Parameters:
contentsToEdit
- the map of contents to editcontentIdsToReference
- The list of content ids that will be added as values in the content fielderrorMessages
- the error messageserrorIds
- the error content idsadditionalParams
- the map of additional parameters- Returns:
- the list of filtered contents
-
_returnValue
private Map<String,Object> _returnValue(List<I18nizableText> errorMessages, List<String> errorIds)
-
_clean
private void _clean(List<Map<String,String>> contentsToEditToRemove, List<String> workflowActionIds, List<I18nizableText> errorMessages, List<String> errorIds)
-
_setContentAttribute
protected void _setContentAttribute(List<String> contentIdsToReference, Map<WorkflowAwareContent,Integer> contentsToEdit, ContentType contentType, String attributePath, List<String> workflowActionIds, List<I18nizableText> errorMessages, List<String> errorIds, Map<String,Object> additionalParams)
Set the attribute at path 'attributePath' of contents 'contentIdsToEdit' with value 'contentIdsToReference'- Parameters:
contentIdsToReference
- The list of content identifiers that will be added as values in the content fieldcontentsToEdit
- The map {key: contents to edit and that will have an attribute of type content modified; value: the new position if attribute is multiple and it is a reorder of values. May be null or equals to -1 if it is not a reorder}contentType
- The content typeattributePath
- The attribute path selected to do modification in the contents to editworkflowActionIds
- The identifiers of workflow actions to use to edit the attribute. Actions will be tested in this order and first available action will be usederrorMessages
- The list that will be felt with error messages of content that had an issue during the operationerrorIds
- The list that will be felt with ids of content that had an issue during the operationadditionalParams
- the map of additional parameters
-
_reorder
private List<String> _reorder(List<String> currentElements, List<String> elementsToReorder, int newPosition)
-
_doAction
private void _doAction(WorkflowAwareContent content, List<String> workflowActionIds, Map<String,Object> values, List<String> errorIds, List<I18nizableText> errorMessages)
-
_resolve
protected List<? extends Content> _resolve(List<String> contentIds)
Resolve content by their identifiers- Parameters:
contentIds
- The id of contents to resolve- Returns:
- the contents
-
_resolve
protected Map<? extends Content,Integer> _resolve(Map<String,Integer> contentIds)
Resolve content by their identifiers- Parameters:
contentIds
- The id of contents to resolve- Returns:
- the contents
-
_getContentTypesIntersection
private Collection<String> _getContentTypesIntersection(Collection<? extends Content> contents)
-
-