Package org.ametys.odf.workflow.copy
Class CopyODFContentClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.cms.clientsideelement.SmartContentClientSideElement
-
- org.ametys.odf.workflow.copy.CopyODFContentClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
CopyODFPilotageContentClientSideElement
public class CopyODFContentClientSideElement extends SmartContentClientSideElement
Client side element for ODF content copy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CopyODFContentClientSideElement.DuplicationMode
Enumeration for the mode of duplication-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentWorkflowHelper
_contentWorkflowHelper
The content workflow helperprotected CopyContentClientInteraction
_copyClientSideInteraction
The client side element for copyprotected JSONUtils
_jsonUtils
JSON utilsprotected ObservationManager
_observationManager
The observation managerprotected ODFHelper
_odfHelper
The ODF helperprotected ShareableCourseHelper
_shareableCourseHelper
The shareable course helperprotected SolrIndexer
_solrIndexer
The solr indexerstatic String
DUPLICATION_MODE_KEY
The key to get the duplication modestatic String
KEEP_CREATION_TITLE_KEY
The key to tell if we keep the creation title-
Fields inherited from class org.ametys.cms.clientsideelement.SmartContentClientSideElement
_contentHelper, _resolver, _smartHelper
-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description CopyODFContentClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_addRelation(WorkflowAwareContent parentContent, WorkflowAwareContent childContent, String parentMetadataName, String childMetadataName, int actionId)
Add the relation parent-child relation on content.protected void
_applyChanges(WorkflowAwareContent content, int actionId)
Apply changes to the contentprotected void
_commitAllChanges()
Commit all changes in solrprotected Set<Course>
_getCourse(ProgramItem programItem)
Get all first courses in sub item of the program itemprotected void
_initializeShareableFields(String copiedContentId, String parentContentId)
Initialize shareable fields for the copied contentprotected void
_linkCopiedContentToParent(String copiedContentId, String parentContentId)
Check if we can add the copied content to the parent content and set the relationMap<String,Object>
canCopyTo(String copiedContentId, String targetContentId, Map<String,Object> contextualParameters)
Determines if a ODF content can be copied and linked to a target contentprotected boolean
checkBeforeDuplication(String programItemId, String parentContentId, CopyODFContentClientSideElement.DuplicationMode duplicationMode, Map<String,Object> results)
Check that duplication can be performed without blocking errorsMap<String,Object>
createContentByCopy(String baseContentId, String newContentTitle, String metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, String metadataSetTypeToCopy, int initActionId, int editActionId, String duplicationModeAsString, String parentContentId)
Creates a content by copy of another one.
Also handle the possible inner duplication depending on the duplication mode for each metadata of type "content".void
service(ServiceManager sManager)
protected void
setJCRReference(WorkflowAwareContent contentToEdit, Content refContent, String attributeName)
Add the jcr relation on content.-
Methods inherited from class org.ametys.cms.clientsideelement.SmartContentClientSideElement
_getAllRightDescription, _getIncorrectWorkflowStepDescription, _getLockedDescription, _getNoModifiableDescription, _getNoRightDescription, _getWorkflowActionUnvailableDescription, _hasRight, _isAllRight, _isLocked, _isModifiable, _isWorkflowStepCorrect, _workflowAction, getContentDefaultParameters, getStatus
-
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, configure, getDependencies, getId, getPluginName, getRights, getScripts, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
DUPLICATION_MODE_KEY
public static final String DUPLICATION_MODE_KEY
The key to get the duplication mode- See Also:
- Constant Field Values
-
KEEP_CREATION_TITLE_KEY
public static final String KEEP_CREATION_TITLE_KEY
The key to tell if we keep the creation title- See Also:
- Constant Field Values
-
_contentWorkflowHelper
protected ContentWorkflowHelper _contentWorkflowHelper
The content workflow helper
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_solrIndexer
protected SolrIndexer _solrIndexer
The solr indexer
-
_odfHelper
protected ODFHelper _odfHelper
The ODF helper
-
_copyClientSideInteraction
protected CopyContentClientInteraction _copyClientSideInteraction
The client side element for copy
-
_jsonUtils
protected JSONUtils _jsonUtils
JSON utils
-
_shareableCourseHelper
protected ShareableCourseHelper _shareableCourseHelper
The shareable course helper
-
-
Constructor Detail
-
CopyODFContentClientSideElement
public CopyODFContentClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager sManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classSmartContentClientSideElement
- Throws:
ServiceException
-
canCopyTo
public Map<String,Object> canCopyTo(String copiedContentId, String targetContentId, Map<String,Object> contextualParameters)
Determines if a ODF content can be copied and linked to a target content- Parameters:
copiedContentId
- The id of copied contenttargetContentId
- The id of target contentcontextualParameters
- the contextual parameters- Returns:
- the result with success to true if copy is available
-
createContentByCopy
public Map<String,Object> createContentByCopy(String baseContentId, String newContentTitle, String metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, String metadataSetTypeToCopy, int initActionId, int editActionId, String duplicationModeAsString, String parentContentId) throws Exception
Creates a content by copy of another one.
Also handle the possible inner duplication depending on the duplication mode for each metadata of type "content".- Parameters:
baseContentId
- The id of content to copynewContentTitle
- The title of content to createmetadataSetNameToCopy
- The metadata set name to copy. Can be nullfallbackMetadataSetNameToCopy
- The fallback metadata set name to use if 'metadataSetNameToCopy' does not exist. Can be nullmetadataSetTypeToCopy
- The metadata set type to copy. Can be nullinitActionId
- The init workflow action id for copyeditActionId
- The workflow action for editing contentduplicationModeAsString
- the duplication modeparentContentId
- the parent id under which the duplicated content will be created. Can be null- Returns:
- the copy result
- Throws:
Exception
- if an error occurred during copy
-
_initializeShareableFields
protected void _initializeShareableFields(String copiedContentId, String parentContentId)
Initialize shareable fields for the copied content- Parameters:
copiedContentId
- the copied content idparentContentId
- the parent content id
-
checkBeforeDuplication
protected boolean checkBeforeDuplication(String programItemId, String parentContentId, CopyODFContentClientSideElement.DuplicationMode duplicationMode, Map<String,Object> results)
Check that duplication can be performed without blocking errors- Parameters:
programItemId
- The program item id to copyparentContentId
- The parent content idduplicationMode
- The duplication moderesults
- the results map- Returns:
- true if the duplication can be performed
-
_getCourse
protected Set<Course> _getCourse(ProgramItem programItem)
Get all first courses in sub item of the program item- Parameters:
programItem
- the program item- Returns:
- a set of courses
-
_linkCopiedContentToParent
protected void _linkCopiedContentToParent(String copiedContentId, String parentContentId)
Check if we can add the copied content to the parent content and set the relation- Parameters:
copiedContentId
- the copied content idparentContentId
- the parent content id
-
_addRelation
protected boolean _addRelation(WorkflowAwareContent parentContent, WorkflowAwareContent childContent, String parentMetadataName, String childMetadataName, int actionId)
Add the relation parent-child relation on content.- Parameters:
parentContent
- The parent contentchildContent
- The child content to be added from parentContentparentMetadataName
- The name of the parent metadata holding the child relationshipchildMetadataName
- The name of the child metadata holding the parent relationshipactionId
- The id of workflow action to edit the relation- Returns:
- boolean true if add relation successfully
-
setJCRReference
protected void setJCRReference(WorkflowAwareContent contentToEdit, Content refContent, String attributeName)
Add the jcr relation on content.- Parameters:
contentToEdit
- The content editrefContent
- The referenced content to be addedattributeName
- The name of the attribute holding the relationship
-
_applyChanges
protected void _applyChanges(WorkflowAwareContent content, int actionId) throws com.opensymphony.workflow.WorkflowException
Apply changes to the content- Parameters:
content
- the content changedactionId
- the workflow action id- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurred
-
_commitAllChanges
protected void _commitAllChanges()
Commit all changes in solr
-
-