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
Modifier and TypeFieldDescriptionprotected ContentHelper
The content helperprotected ContentTypeExtensionPoint
The content types extension pointprotected ContentTypesHelper
The content type helperprotected ContentWorkflowHelper
The content workflow helperprotected AmetysObjectResolver
The Ametys object resolverFields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConvert attribute definitions to JSON objectConvert an attribute definition to JSONprotected 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_findCompatibleAttributes
(List<? extends Content> contentsToReference, List<? extends Content> contentsToEdit) Find the list of compatible attribute definitionsResolve content by their identifiersResolve content by their identifiersprotected 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 'contentsToEdit' with value 'contentIdsToReference'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) 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'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 Details
-
_resolver
The Ametys object resolver -
_contentTypesHelper
The content type helper -
_contentTypeExtensionPoint
The content types extension point -
_contentWorkflowHelper
The content workflow helper -
_contentHelper
The content helper
-
-
Constructor Details
-
SetContentAttributeClientSideElement
public SetContentAttributeClientSideElement()
-
-
Method Details
-
service
- 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
Convert attribute definitions to JSON object- Parameters:
attributeDefinitions
- The attribute definitions- Returns:
- the JSON object
-
_convert
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
-
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
-
_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 'contentsToEdit' 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
-
_resolve
Resolve content by their identifiers- Parameters:
contentIds
- The id of contents to resolve- Returns:
- the contents
-
_resolve
Resolve content by their identifiers- Parameters:
contentIds
- The id of contents to resolve- Returns:
- the contents
-