Class Workflow

java.lang.Object
com.jalios.jcms.Workflow
All Implemented Interfaces:
JcmsConstants, WorkflowConstants, JaliosConstants, Comparable

public class Workflow extends Object implements WorkflowConstants, JcmsConstants, Comparable
This class represents a Workflow.
Since:
jcms-2.1
Author:
Olivier Dedieu
  • Constructor Details

    • Workflow

      public Workflow(String id, String type, Map<String,String> labelMap, boolean createInitState)
      Creates a new empty workflow with the given label and id.
      Parameters:
      id - the id of the workflow
      type - the type of the workflow
      labelMap - localized label map
      createInitState - if true creates a new state and uses it as initState
      Since:
      jcms-5.5.0
    • Workflow

      public Workflow(Workflow wf)
      Clones a workflow from a given workflow (clone workflow type, states, actions, roles and transitions). The workflow's id is automaticaly generated.
      Parameters:
      wf - the workflow to clone
      Since:
      jcms-5.7.0
    • Workflow

      public Workflow(Map<String,String> labelMap, Workflow wf, boolean clone)
      Creates a workflow from a given workflow (clone workflow type, states, actions, roles and transitions). The workflow's id is automaticaly generated.
      Parameters:
      labelMap - localized label map
      wf - the workflow to clone
      clone - if true do generate a new id nor new wfrole id
      Since:
      jcms-5.5.0
    • Workflow

      public Workflow(org.jdom.Element elt)
      Create a workflow from a JDOM Element
      Parameters:
      elt - the Element
      Since:
      jcms-5.7.0
  • Method Details

    • convertToPublishWorkflow

      public void convertToPublishWorkflow()
      Convert this (process) workflow to a publish workflow.
      Since:
      jcms-5.5.0
    • convertToProcessWorkflow

      public void convertToProcessWorkflow()
      Convert this (publish) workflow to a process workflow.
      Since:
      jcms-5.5.0
    • reloadI18N

      public void reloadI18N()
      Reload all I18N informations for this workflow. This includes : label, states label & description, roles label and description
      Since:
      jcms-8.0.2
    • getLabel

      public String getLabel(String lang)
      Returns a localized label.
      Parameters:
      lang - the language
      Returns:
      a localized label.
      Since:
      jcms-5.7.0
    • toXml

      public String toXml()
      Returns the XML representation for this workflow.
      Returns:
      the XML representation for this workflow.
      Since:
      jcms-5.7.0
    • toXml

      public String toXml(boolean includeXmlHeader)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()
      Check if the workflow is empty. A workflow is empty if it contains none transition.
      Returns:
      true if workflow is empty, false otherwise
      Since:
      jcms-2.1
    • isPublishWorkflow

      public boolean isPublishWorkflow()
      Returns true if this workflow is a publish workflow.
      Returns:
      true if this workflow is a publish workflow.
      Since:
      jcms-5.5.0
    • isProcessWorkflow

      public boolean isProcessWorkflow()
      Returns true if this workflow is a process workflow.
      Returns:
      true if this workflow is a process workflow.
      Since:
      jcms-5.5.0
    • isRoleInvolved

      public boolean isRoleInvolved(WFRole role)
      Returns true if the given role is involved in this Workflow
      Parameters:
      role - the tested Role
      Returns:
      true if the given role is involved in this Workflow
      Since:
      JCMS 4.0.2
    • compareTo

      public int compareTo(Object obj)
      Specified by:
      compareTo in interface Comparable
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getId

      public String getId()
    • setId

      public void setId(String id)
    • getLabelMap

      public Map<String,String> getLabelMap()
    • setLabelMap

      public void setLabelMap(Map<String,String> labelMap)
    • getType

      public String getType()
    • setType

      public void setType(String type)
    • getInitState

      public WFState getInitState()
    • setInitState

      public void setInitState(WFState v)
    • getVersion

      public int getVersion()
    • setVersion

      public void setVersion(int version)
    • getMdate

      public Date getMdate()
      Returns:
      the last modification date of this workflow
      Since:
      jcms-10.0.7
    • setMdate

      public void setMdate(Date mdate)
      Parameters:
      mdate - the last modification date of this workflow.
      Since:
      jcms-10.0.7
    • getTransitionSet

      public Set<WFTransition> getTransitionSet()
    • getStateSet

      public Set<WFState> getStateSet()
      Returns the state set of this workflow
      Returns:
      the state set of this workflow.
      Since:
      jcms-2.1
    • getState

      public WFState getState(int pstatus)
      Returns the WFState bound to the given pstatus
      Parameters:
      pstatus - the pstatus of the searched WFState
      Returns:
      a WFState
      Since:
      jcms-2.1
    • getStateLabel

      public String getStateLabel(int pstatus, String lang)
      This convenient returns the label of WFState bound to the given pstatus
      Parameters:
      pstatus - the pstatus of the searched WFState
      lang - the language code in which to retrieve the label
      Returns:
      the String of the lable of the WFState bound to the current pstatus or "???" if unknown state.
      Since:
      jcms-4.0
    • getWorkStateSet

      public Set<WFState> getWorkStateSet(Publication pub, Member member)
      Returns all the state a member can work in, for all Workspace.
      Parameters:
      pub - the publication to work on
      member - the member
      Returns:
      a set of WFState
      Since:
      jcms-2.1
    • getWorkStateSet

      public Set<WFState> getWorkStateSet(Publication pub, Member member, Workspace workspace)
      Returns all the state a member can work in, for given Workspace.
      Parameters:
      pub - the publication to work on
      member - the member
      workspace - the Workspace in which to retrieve state
      Returns:
      a set of WFState
    • getWorkStateSet

      public Set<WFState> getWorkStateSet(Group group, Workspace workspace)
      Returns all the state a group can work in, for given Workspace.
      Parameters:
      group - the group
      workspace - the Workspace in which to retrieve state
      Returns:
      a set of WFState
    • getWorkStateSet

      public Set<WFState> getWorkStateSet(WFRole role)
      Returns all the states bound to a given WFRole.
      Parameters:
      role - the role
      Returns:
      all the state bound to a given WFRole.
    • canWorkInState

      public boolean canWorkInState(Publication pub, Member member, WFState state)
      Checks if a given member can work in a given state
      Parameters:
      pub - the publication to work on
      member - the member
      state - the state
      Returns:
      true if this member can work in this state (always true if state is the init state or member is admin).
      Since:
      jcms-2.1
    • canWorkInState

      public boolean canWorkInState(Publication pub, Member member, WFState state, Member newAuthor)
      Checks if a given member can work in a given state
      Parameters:
      pub - the publication to work on
      member - the member
      state - the state
      newAuthor - member used as author to execute the check (can be null, in this case original author is kept). This parameter is used to check rights before creating a copy of a publication with a different author.
      Returns:
      true if this member can work in this state (always true if state is the init state or member is admin).
      Since:
      jcms-9.0.4
    • canChangeState

      public boolean canChangeState(WFRole role, WFState source, WFState target)
      Checks if a given role can move from a given state in a given state
      Parameters:
      role - the role
      source - the source state
      target - the target state
      Returns:
      true if the change can be performed
      Since:
      jcms-4.0.2
    • canChangeState

      public boolean canChangeState(Member member, Publication pub, WFState target)
      Checks if a given member can move a given publication in a given state. If the publication is null, check from the init state.
      Parameters:
      member - the member
      pub - the publication
      target - the target state
      Returns:
      true if the change can be performed
      Since:
      jcms-2.1
    • canChangeState

      public boolean canChangeState(Member member, Publication pub, WFState source, WFState target)
      Checks if a given member can move from a given state in a given state
      Parameters:
      member - the member
      pub - the publication
      source - the source state
      target - the target state
      Returns:
      true if the change can be performed
      Since:
      jcms-2.1
    • getNextStateSet

      public Set<WFState> getNextStateSet(Publication pub, Member member)
      Returns all the states a given member can reach for a given publication. If the publication is null, return all the states reachable from the init state.
      Parameters:
      pub - the publication
      member - the member
      Returns:
      a set of WFState
      Since:
      jcms-2.1
    • getNextStateSet

      public Set<WFState> getNextStateSet(Publication pub, Member member, WFState state, Workspace ws)
      Returns all the states a given member can reach from a given state
      Parameters:
      pub - the publication to work on
      member - the member
      state - the source state
      ws - the current workspace
      Returns:
      a set of WFState
      Since:
      jcms-2.1
    • addState

      public void addState(WFState state)
      Adds a state in this workflow
      Parameters:
      state - the state to add
      Since:
      jcms-2.1
    • removeState

      public void removeState(WFState state)
      Removes a state in this workflow
      Parameters:
      state - the state to remove
      Since:
      jcms-2.1
    • addTransition

      public void addTransition(WFState source, WFState target, WFRole role)
      Adds a transition in this workflow
      Parameters:
      source - the source state
      target - the target state
      role - the role
      Since:
      jcms-2.1
    • removeAllTransitions

      public void removeAllTransitions()
      Removes all the transition of this workflow
      Since:
      jcms-2.1
    • getIncomingTransitionSet

      public Set<WFTransition> getIncomingTransitionSet(WFState state)
      Returns all the transition the given state is the target.
      Parameters:
      state - the state
      Returns:
      an (never null) set of WFTransition
      Since:
      jcms-2.1
    • cloneStates

      public void cloneStates(Workflow other)
      Clones all the states of another workflow in this one. Clones are created with WFState.clone() method (i.e. only label and pstatus are cloned).
      Parameters:
      other - the other workflow to clone the state
      Since:
      jcms-2.1
    • getRole

      public WFRole getRole(String roleUid)
      Returns a WFRole from its unique id (eg "basic-validators").
      Parameters:
      roleUid - the role unique id
      Returns:
      the WFRole bound to the given unique id or null if it doesn't exist
      Since:
      jcms-4.0.2
    • getRoleByRoleId

      public WFRole getRoleByRoleId(String roleId)
      Returns a WFRole from its role id (eg "validators").
      Parameters:
      roleId - the role id
      Returns:
      the WFRole bound to the given id or null if it doesn't exist
      Since:
      jcms-4.0.2
    • getRoleSet

      public Set<WFRole> getRoleSet()
      Gets the role set for this workflow
      Returns:
      the role set for this workflow
    • addRole

      public void addRole(WFRole role)
      Adds a WFRole to the workflow
      Parameters:
      role - the role to be added
      Since:
      jcms-4.0.2
    • addRole

      public void addRole(WFRole role, boolean register)
      Adds a WFRole to the workflow
      Parameters:
      role - the role to be added
      register - should register role to channel
      Since:
      jcms-5.5.0
    • deleteRole

      public void deleteRole(WFRole wfRole, Member member)
      Deletes the given WFRole
      Parameters:
      wfRole - the WFRole to be deleted
      member - the member which perform this action
      Since:
      jcms-4.0.2
    • isNew

      public boolean isNew()
      Returns:
      Returns the isNew.
      Since:
      jcms-5.5.0
    • setNew

      public void setNew(boolean isNew)
      Parameters:
      isNew - The isNew to set.
      Since:
      jcms-5.5.0
    • isUpdated

      public boolean isUpdated()
      Returns:
      Returns the isUpdated.
      Since:
      jcms-5.5.0
    • setUpdated

      public void setUpdated(boolean isUpdated)
      Parameters:
      isUpdated - The isUpdated to set.
      Since:
      jcms-5.5.0
    • getPlugin

      public Plugin getPlugin()
      Returns the plugin providing this Workflow.
      Returns:
      the plugin providing this Workflow.
      Since:
      jcms-10.0.0
    • isActive

      public boolean isActive()