Class WorkflowManager

    • Field Detail

      • DEFAULT_WORKFLOW

        public static Workflow DEFAULT_WORKFLOW
      • REPLICA_MESSAGE_WORKFLOW

        protected static final java.lang.String REPLICA_MESSAGE_WORKFLOW
        See Also:
        Constant Field Values
      • REPLICA_MESSAGE_WORKFLOW_DELETE

        protected static final java.lang.String REPLICA_MESSAGE_WORKFLOW_DELETE
        See Also:
        Constant Field Values
      • wfRoleMap

        protected final java.util.Map<java.lang.String,​WFRole> wfRoleMap
      • visiblePstatus

        protected int[] visiblePstatus
    • Method Detail

      • initReplicaMessageListener

        public void initReplicaMessageListener()
      • getSpecialStateMap

        public java.util.Map<java.lang.String,​WFState> getSpecialStateMap()
        Returns the map of special states (schedule, published, expired, archived).
        Returns:
        the map of special states (schedule, published, expired, archived).
        Since:
        jcms-9.0.0
      • convertFromVersion3

        public void convertFromVersion3()
                                 throws java.io.IOException,
                                        org.jdom.JDOMException
        Converts old JCMS (&lt;= 5.6) workflow.xml to new (>=5.7) workflow structure.
        Throws:
        java.io.IOException - If an I/O error occurs
        org.jdom.JDOMException - If an error occurs while parsing the DOM
        Since:
        jcms-5.7.0
      • parseAllWorkflows

        public java.util.Map<java.lang.String,​Workflow> parseAllWorkflows()
                                                                         throws org.jdom.JDOMException,
                                                                                java.io.IOException
        Parse all workflows contains in JCMS workflows directory.
        Returns:
        the Map {id, Workflow}
        Throws:
        java.io.IOException - If an I/O error occurs
        org.jdom.JDOMException - If an error occurs while parsing the DOM
        Since:
        jcms-5.7.0
      • initWorkflowAlarms

        public void initWorkflowAlarms()
      • getWorkflow

        public Workflow getWorkflow​(java.lang.String wfId)
        Return a Workflow from a given Id
        Parameters:
        wfId - the WOrkflow Id
        Returns:
        a Workflow
      • getWorkflowSet

        public java.util.Set<Workflow> getWorkflowSet()
        Return the set of workflow from the workflow Map
        Returns:
        the workflowSet
      • getWorkflowIdSet

        public java.util.Set<java.lang.String> getWorkflowIdSet()
        Return the set of Workflow id from the workflow Map
        Returns:
        the workflowSet of Workflow id
      • getWorkflowSet

        public java.util.Set<Workflow> getWorkflowSet​(java.lang.Class typeClass)
        Return the set of workflow from the workflow Map compatible with the typeClass
        Parameters:
        typeClass - the Class with wich the workflow should be compatible
        Returns:
        the workflowSet compatible with the typeClass
      • isCompatibleWorkflow

        public boolean isCompatibleWorkflow​(Workflow workflow,
                                            java.lang.Class typeClass)
        indicates if the Workflow is compatible with the type Class
        Parameters:
        workflow - the Workflow
        typeClass - the type Class
        Returns:
        true if the Workflow can be used with this type class, false otherwise (null parameter always return false)
      • getWorkflowIdSet

        public java.util.Set<java.lang.String> getWorkflowIdSet​(java.lang.Class typeClass)
        Return the set of workflow id from the workflow Map compatible with the typeClass
        Parameters:
        typeClass - the Class with wich the workflow should be compatible
        Returns:
        the Set of Workflow id compatible with the typeClass
      • getWorkflowMap

        public java.util.Map<java.lang.String,​Workflow> getWorkflowMap()
        Returns the workflow map. Keys are the workflow ids, values are the workflows.
        Returns:
        the workflow map
        Since:
        jcms-2.1
      • getCopyWorkflowMap

        public java.util.Map<java.lang.String,​Workflow> getCopyWorkflowMap()
        Returns the copy of the workflow map (used to perform changes with no effect until the workflows are saved)
        Returns:
        the copy of the workflow map
        Since:
        jcms-5.5.0
      • getWorkflowMap

        public java.util.Map<java.lang.String,​Workflow> getWorkflowMap​(boolean copy)
        Returns the workflow map or the copy of the workflow map (without the default workflow)
        Parameters:
        copy - if true returns the copy of the workflow map
        Returns:
        the workflow map or the copy of the workflow map
        Since:
        jcms-5.5.0
      • addWorkflow

        public void addWorkflow​(java.lang.String id,
                                Workflow wf)
        Binds a Workflow to a given class
        Parameters:
        id - the workflow id
        wf - the workflow
        Since:
        jcms-2.1
      • removeWorkflow

        public void removeWorkflow​(java.lang.String id)
        Unbinds a Workflow to a given wfId
        Parameters:
        id - the workflow id
        Since:
        jcms-2.1
      • getCopyWorkflow

        public Workflow getCopyWorkflow​(java.lang.String id)
        Returns the workflow bound to the given id in copyWorkflowMap
        Parameters:
        id - the workflow id
        Returns:
        the workflow bound to the given id in copyWorkflowMap
        Since:
        jcms-5.5.0
      • getWorkflow

        public Workflow getWorkflow​(Publication pub)
        Returns the workflow bound to a given publication (general workflow, not instance one if any is set. Publication.getWorkflow() will give it if any is set.
        Parameters:
        pub - the publication
        Returns:
        the bound Workflow (or null if none)
        Since:
        jcms-2.1
      • saveAllWorkflows

        public void saveAllWorkflows()
        Save the Workflow on disk
        Since:
        jcms-2.1
      • revertAllWorkflows

        public void revertAllWorkflows()
        Revert all the workflow
        Since:
        jcms-5.5.0
      • initWorkflow

        public void initWorkflow()
                          throws java.lang.Exception
        Initialize the workflows
        Throws:
        java.lang.Exception - if the initialization failed
        Since:
        jcms-5.5.0
      • getDefaultWorkflow

        public Workflow getDefaultWorkflow()
      • isUpdated

        public boolean isUpdated()
        Returns true if at least one workflow is new, has been updated or has been deleted.
        Returns:
        true if at least one workflow is new, has been updated or has been deleted.
        Since:
        jcms-5.5.0
      • addRole

        protected void addRole​(WFRole role)
      • removeRole

        protected void removeRole​(WFRole role)
      • getWFRoleIdSet

        public java.util.Set<java.lang.String> getWFRoleIdSet()
        Returns a Set of workflow role's ids (String). As defined by the tag <role... > in the workflow.xml file of this JCMS site.
        Returns:
        Set of String
      • getWFRole

        public WFRole getWFRole​(java.lang.String wfRoleId)
      • getWKRole

        public WKRole getWKRole​(java.lang.String wkRoleId)
      • getWKRoles

        public java.util.Set<WKRole> getWKRoles​(WFRole wfRole)
      • getWFStateStateLabel

        public java.lang.String getWFStateStateLabel​(Publication pub,
                                                     int pstatus,
                                                     java.lang.String userLang)
        Returns the label of the given pstatus.
        Parameters:
        pub - the publication to be used to get the workflow.
        pstatus - the pstatus
        userLang - the user language
        Returns:
        the label of the given pstatus.
        Since:
        jcms-5.7.0
      • getWFStateStateLabel

        public java.lang.String getWFStateStateLabel​(Workflow wf,
                                                     int pstatus,
                                                     java.lang.String userLang)
        Returns the label of the given pstatus.
        Parameters:
        wf - the workflow.
        pstatus - the pstatus
        userLang - the user language
        Returns:
        the label of the given pstatus.
        Since:
        jcms-5.7.0
      • getWFStateStateLabelHtml

        public java.lang.String getWFStateStateLabelHtml​(Publication pub,
                                                         int pstatus,
                                                         java.lang.String userLang)
        Returns the HTML code for the label of the given pstatus.
        Parameters:
        pub - the publication to be used to get the workflow.
        pstatus - the pstatus
        userLang - the user language
        Returns:
        the HTML code for the label of the given pstatus.
        Since:
        jcms-7.0.0
      • getWFStateStateLabelHtml

        public java.lang.String getWFStateStateLabelHtml​(Workflow wf,
                                                         int pstatus,
                                                         java.lang.String userLang)
        Returns the HTML code for the label of the given pstatus.
        Parameters:
        wf - the workflow.
        pstatus - the pstatus
        userLang - the user language
        Returns:
        the HTML code for the label of the given pstatus.
        Since:
        jcms-7.0.0
      • getUnknownWFStateLabel

        public java.lang.String getUnknownWFStateLabel​(int pstatus)
        Returns the label of an unknown pstatus.
        Parameters:
        pstatus - the pstatus
        Returns:
        the label of an unknown pstatus.
        Since:
        jcms-5.7.0
      • getWFNoteList

        public java.util.List<WFNote> getWFNoteList​(Publication pub)
        Returns the list of WFNote bound to the given publication.
        Parameters:
        pub - the publication
        Returns:
        the list of WFNote bound to the given publication.
        Since:
        jcms-6.0.0
      • getLastWFNote

        public WFNote getLastWFNote​(Publication pub)
        Returns the last WFNote created for this publication.
        Parameters:
        pub - the publication
        Returns:
        the last WFNote created for this publication.
        Since:
        jcms-6.0.0
      • hasAlreadyVoted

        public boolean hasAlreadyVoted​(Publication pub,
                                       Member mbr)
        Check if the given member has already voted for the given publication.
        Parameters:
        pub - the publication
        mbr - the member
        Returns:
        true if the given member has already voted (ie add a WFNote) in the workflow for the given publication.
        Since:
        jcms-6.0.0
      • removeAllWFNotes

        public void removeAllWFNotes​(Publication pub)
        Removes all the WFNote bound to the given publication.
        Parameters:
        pub - the publication
        Since:
        jcms-6.0.0
      • addWFReminderAlarm

        public void addWFReminderAlarm​(Publication pub)
        Adds a WFReminder alarm for the given publication (only for main leader replica).
        Parameters:
        pub - the publication
        Since:
        jcms-6.0.0
      • removeWFReminderAlarm

        public void removeWFReminderAlarm​(Publication pub)
        Removes the WFExpress alarm for the given publication.
        Parameters:
        pub - the publication
        Since:
        jcms-6.0.0
      • removeWFReminderAlarm

        public void removeWFReminderAlarm​(java.lang.String pubId)
        Removes the WFExpress alarm for the given publication.
        Parameters:
        pubId - the publication's ID
        Since:
        jcms-10.0.7
      • addWFExpressAlarm

        public void addWFExpressAlarm​(Publication pub)
        Adds a WFReminder alarm for the given publication (only for main leader replica).
        Parameters:
        pub - the publication
        Since:
        jcms-6.0.0
      • removeWFExpressAlarm

        public void removeWFExpressAlarm​(Publication pub)
        Removes the WFExpress alarm for the given publication.
        Parameters:
        pub - the publication
        Since:
        jcms-6.0.0
      • removeWFExpressAlarm

        public void removeWFExpressAlarm​(java.lang.String pubId)
        Removes the WFExpress alarm for the given publication.
        Parameters:
        pubId - the publication's ID
        Since:
        jcms-10.0.7
      • getAlphabeticalComparator

        public java.util.Comparator<Workflow> getAlphabeticalComparator()
      • getVisiblePstatus

        public int[] getVisiblePstatus()
        Returns the array of Workflow pstatus visible in front-office.
        Returns:
        the array of Workflow pstatus visible in front-office.
        Since:
        jcms-9.0.0
      • invalidateVisiblePstatus

        public void invalidateVisiblePstatus()
        Invalidate current visible pstatus (they will be computed again at the next call).
        Since:
        jcms-9.0.0
      • convertPstatus

        public int convertPstatus​(Workflow wf,
                                  int oldPstatus,
                                  int newPstatus,
                                  Member opAuthor)
        Converts publications in the given pstatus with the given workflow to a new pstatus. Associated WFNotes are also updated.
        Parameters:
        wf - the workflow
        oldPstatus - the current pstatus
        newPstatus - the new pstatus
        opAuthor - the author of the operation
        Returns:
        the count of publication converted
        Since:
        jcms-9.0.0
      • convertPstatus

        public boolean convertPstatus​(Publication pub,
                                      Workflow wf,
                                      int oldPstatus,
                                      int newPstatus,
                                      Member opAuthor)
        Converts a publication in the given pstatus with the given workflow to a new pstatus. Associated WFNotes are also updated.
        Parameters:
        pub - the publication
        wf - the workflow the publication must used to be converted
        oldPstatus - the current pstatus
        newPstatus - the new pstatus
        opAuthor - the author of the operation
        Returns:
        true if the publication has been converted
        Since:
        jcms-9.0.0
      • cleanUnprefixedRoleMap

        public void cleanUnprefixedRoleMap​(java.util.Map roleMap)
        This is a JCMS 9 migration method. It cleans the role id contains in the given roleMap. Unprefixed roles (eg. "writers") are replaced with WF prefixed role (eg. "basic-writers").
        Parameters:
        roleMap - the roleMap to be cleaned.
        Since:
        jcms-9.0.0
      • previewInFO

        public boolean previewInFO​(Publication pub)
        Returns true if the given publication must be previewed in front-office
        Parameters:
        pub - the publication
        Returns:
        true if the given publication must be previewed in front-office
        Since:
        jcms-9.0.0
      • getDefaultFileDocumentWorkflow

        public Workflow getDefaultFileDocumentWorkflow()
        Returns the Default Workflow associated with FileDocument
        Returns:
        Workflow the default workflow for FileDocuments
      • removeMemberFromAllWKRole

        public void removeMemberFromAllWKRole​(Member member)
        Remove a Member from all WKRole in which he's involved.
        Parameters:
        member - the Member to remove
      • getManager

        public Member getManager​(Publication pub)
        Returns the manager associated to this publication (ie the manager of the submitMember for Form and the manager of the author for other Publication)
        Parameters:
        pub - the publication
        Returns:
        the manager associated to this publication
        Since:
        jcms-10.0.4
      • getNextWfState

        public static java.util.Set<WFState> getNextWfState​(Publication pub,
                                                            Member mbr)
        Computes all states which can be reached by a member on a publication. Result Set cannot be empty as the initial state is always available.
        Parameters:
        pub - the publication
        mbr - The Member
        Returns:
        null if any parameters is null, a Set of WFState which can be reached
      • getNextWfState

        public static java.util.Set<WFState> getNextWfState​(java.lang.Class<? extends Publication> clazz,
                                                            Member mbr,
                                                            Workflow targetWorkflow,
                                                            Workspace targetWorkspace)
        Computes all states which can be reached by a member on a publication's class.
        Parameters:
        clazz - the publication's class
        mbr - The Member
        targetWorkflow - the Workflow to used instead of publication's class workflow
        targetWorkspace - the Workspace to used
        Returns:
        null if any parameters is null, a Set of WFState which can be reached
      • getNextWfState

        public static java.util.Set<WFState> getNextWfState​(Publication pub,
                                                            Member mbr,
                                                            Workflow targetWorkflow,
                                                            Workspace targetWorkspace)
        Computes all states which can be reached by a member on a publication.
        Parameters:
        pub - the publication
        mbr - The Member
        targetWorkflow - the Workflow to used instead of publication's workflow
        targetWorkspace - the Workspace to used instead of publication's workspace
        Returns:
        null if any parameters is null, a Set of WFState which can be reached
      • getAvailableWorkflowSet

        public static java.util.Set<Workflow> getAvailableWorkflowSet​(java.lang.Class<? extends Publication> pubClass,
                                                                      Workspace targetWorkspace)
        return Set of available workflow for this publication class
        Parameters:
        pubClass - the publication class
        targetWorkspace - the target Workspace of the publication
        Returns:
        null is any parameters are null, Set of available Workflow instead