Class WorkflowManager

java.lang.Object
com.jalios.jcms.WorkflowManager
All Implemented Interfaces:
DBConstants, JcmsConstants, PluginComponent, ReplicaMessageListener, WorkflowConstants, JaliosConstants, JPropertiesListener

This class manages JCMS workflows.
Since:
jcms-5.5.0
Author:
Olivier Dedieu
  • Field Details

    • DEFAULT_WORKFLOW

      public static Workflow DEFAULT_WORKFLOW
    • MIGRATION_PREVIOUSLY_INHERITED_WORKFLOW_DONE

      public static final String MIGRATION_PREVIOUSLY_INHERITED_WORKFLOW_DONE
      See Also:
    • REPLICA_MESSAGE_WORKFLOW

      protected static final String REPLICA_MESSAGE_WORKFLOW
      See Also:
    • REPLICA_MESSAGE_WORKFLOW_DELETE

      protected static final String REPLICA_MESSAGE_WORKFLOW_DELETE
      See Also:
    • wfRoleMap

      protected final Map<String,WFRole> wfRoleMap
    • visiblePstatus

      protected int[] visiblePstatus
  • Method Details

    • getInstance

      public static WorkflowManager getInstance()
    • initReplicaMessageListener

      public void initReplicaMessageListener()
    • propertiesChange

      public void propertiesChange(JProperties properties)
      Description copied from interface: JPropertiesListener
      Invoked after properties have been modified in JCMS and save on disk.

      You cannot alter the value received in parameters.

      Note that properties parameter may be null, a limited set of site properties, or all site properties.

      To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

      Specified by:
      propertiesChange in interface JPropertiesListener
      Parameters:
      properties - the properties which have been submitted to change
    • getSpecialStateMap

      public Map<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 IOException, org.jdom.JDOMException
      Converts old JCMS (&lt;= 5.6) workflow.xml to new (>=5.7) workflow structure.
      Throws:
      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 Map<String,Workflow> parseAllWorkflows() throws org.jdom.JDOMException, IOException
      Parse all workflows contains in JCMS workflows directory.
      Returns:
      the Map {id, Workflow}
      Throws:
      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(String wfId)
      Return a Workflow from a given Id
      Parameters:
      wfId - the WOrkflow Id
      Returns:
      a Workflow
    • getWorkflowSet

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

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

      public Set<Workflow> getWorkflowSet(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, 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 Set<String> getWorkflowIdSet(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 Map<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 Map<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 Map<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(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(String id)
      Unbinds a Workflow to a given wfId
      Parameters:
      id - the workflow id
      Since:
      jcms-2.1
    • getCopyWorkflow

      public Workflow getCopyWorkflow(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 Exception
      Initialize the workflows
      Throws:
      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 Set<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(String wfRoleId)
    • getWKRole

      public WKRole getWKRole(String wkRoleId)
    • getWKRoles

      public Set<WKRole> getWKRoles(WFRole wfRole)
    • getWFStateStateLabel

      public String getWFStateStateLabel(Publication pub, int pstatus, 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 String getWFStateStateLabel(Workflow wf, int pstatus, 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 String getWFStateStateLabelHtml(Publication pub, int pstatus, 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 String getWFStateStateLabelHtml(Workflow wf, int pstatus, 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 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 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(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(String pubId)
      Removes the WFExpress alarm for the given publication.
      Parameters:
      pubId - the publication's ID
      Since:
      jcms-10.0.7
    • getAlphabeticalComparator

      public 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(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
    • processMessage

      public void processMessage(ReplicaMessage msg)
      Description copied from interface: ReplicaMessageListener
      Process the given ReplicaMessage.
      Specified by:
      processMessage in interface ReplicaMessageListener
      Parameters:
      msg - the ReplicaMessage to process
    • 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 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 Set<WFState> getNextWfState(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 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 Set<Workflow> getAvailableWorkflowSet(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
    • migratePreviouslyInheritedWorkflow

      public static void migratePreviouslyInheritedWorkflow()