Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Completed conversion of workflow.xml example to Spring form; small cleanups and clarifications

...

Main workflow configuration

Info

As of DSpace 7, the workflow.xml configuration file has been migrated to use Spring Bean syntax (instead of a custom XML format).  The structure of this XML has changed. If you need help migrating your old workflow.xml file (which started with a <wf<wf-config> config> tag) to the new format (using <bean> <bean> tags), an XSLT script is available: workflow-migration.xsl

...

Code Block
languagehtml/xml
<beans>
    <bean class="org.dspace.xmlworkflow.XmlWorkflowFactoryImpl">
        <property name="workflowMapping">
            <util:map>
                <entry key="defaultWorkflow" value-ref="defaultWorkflow"/>
<!--            <entry key="123456789/4" value-ref="selectSingleReviewer"/>-->
<!--            <entry key="123456789/5" value-ref="scoreReview"/>-->
            </util:map>
        </property>
    </bean>     
    
    <!--Standard DSpace workflow-->
    <bean name="defaultWorkflow" class="org.dspace.xmlworkflow.state.Workflow">
        <property name="firstStep" ref="reviewstep"/>
        <property name="steps">
            <util:list>
                <ref bean="reviewstep"/>
                <ref bean="editstep"/>
                <ref bean="finaleditstep"/>
            </util:list>
        </property>
    </bean> 

    <workflow<bean startid="{startworkflow.step.id}"
		 id class="{workflow.id}org.dspace.xmlworkflow.state.Workflow">
        <roles>
         	<!-- Roles used in the Another workflow configuration-->
        </roles>bean>

	<!-- Role beans.  See        <!-- Steps come here-->
            <step id="ExampleStep1" nextStep="ExampleStep2" userSelectionMethod="{UserSelectionActionId}">
            <!-- Step1 config-->
            </step>
        <step id="ExampleStep2" userSelectionMethod="{UserSelectionActionId}">

        </step>
    </workflow>
    <workflow start="{start.step.id2}" id="{workflow.id}">
     <!-- Another workflow configuration-->
    </workflow>
</wf-config>

...

below. -->

	<!-- Step beans.  See below. -->

</beans>

workflowFactory bean (org.dspace.xmlworkflow.XmlWorkflowFactoryImpl)

The workflow map contains a mapping between collections in DSpace and a workflow configuration, and is defined by the workflowMapping property of the workflow factory. Similar to the configuration of the submission process, the mapping can be done based on the handle of the collection. The mapping with "defaultWorkflow" as the value for the collection mapping, will be used for the collections not occurring in other mapping tags. Each mapping is defined by a "entry" tag element with two attributes:

  • key: can either be a collection handle or "defaultWorkflow"
  • value-ref: the value of this attribute points to one of the workflow configurations defined by the "Workflow" beans

...

The workflow bean is a repeatable XML element and the configuration between two "workflow" tags element and represents one workflow process. It requires the following:

  • "name" attribute: a unique name used for the identification of the workflow and used in the workflow to collection mapping
  • "firstStep" property: the identifier of the first step of the workflow, this .  This step will be the entry point of this workflow-process. When a new item has been committed to a collection that uses this workflow, the step configured in the "startfirstStep" attribute property will he the first step the item will go through.
  • "steps" property: a list of all steps within this workflow (in the order they will be processed).

...

Each workflow step has defined "role" property. A role represents one or more existing DSpace EPersons or Groups and can be used to assign them to one or more steps in the workflow process. One role is represented by one "role" bean and has the following:

  • "id" attribute: a unique identifier (in one workflow process) for the role
  • "description" property: optional attribute to describe the role
  • "scope" property: optional attribute that is used to find our group and must have one of the following values, which are defined as constant fields of org.dspace.xmlworkflow.Role.Scope:
    • COLLECTION: The collection value specifies that the group will be configured at the level of the collection. This type of groups is the same as the type that existed in the original workflow system.  In case no value is specified for the scope attribute, the workflow framework assumes the role is a collection role.
    • REPOSITORY: The repository scope uses groups that are defined at repository level in DSpace. The name attribute should exactly match the name of a group in DSpace.
    • ITEM: The item scope assumes that a different action in the workflow will assign a number of EPersons or Groups to a specific workflow-item in order to perform a step. These assignees can be different for each workflow item.
  • "name" property: The name specified in the name attribute of a role will be used to lookup an eperson group in DSpace. The lookup will depend on the scope specified in the "scope" attribute:
    • collectionCOLLECTION: The workflow framework will look for a group containing the name specified in the name attribute and the ID of the collection for which this role is used.
    • repositoryREPOSITORY: The workflow framework will look for a group with the same name as the name specified in the name attribute.
    • itemITEM: in case the item scope is selected, the name of the role attribute is not required.
Code Block
languagehtml/xml
<bean id="reviewer" class="org.dspace.xmlworkflow.Role">
    <property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).COLLECTION}"/>
    <property name="name" value="Reviewer"/>
    <property name="description" value="The people responsible for this step are able to edit the metadata of incoming submissions, and then accept or reject them."/>
</bean> 

...

The step element represents one step in the workflow process. A step represents a number of actions that must be executed by one specified role. In case no role attribute is specified, the workflow framework assumes that the DSpace system is responsible for the execution of the step and that no user interface will be available for each of the actions in this step. The step element has the following in order to further configure it:

  • "name" attribute: The name attribute specifies a unique identifier for the step, this id .  This identifier will be used when configuring other steps in order to point to this step. This identifier can also be used when configuring the start step of the workflow item.
  • "userSelectionMethod" property: This attribute defines the UserSelectionAction that will be used to determine how to attache attach users to this step for a workflow-item. The value of this attribute must refer to the identifier of an action bean in the workflow-actions.xml. Examples of the user attachment to a step are the currently used system of a task pool or as an alternative directly assigning a user to a task.
  • "role" property: optional attribute that must point to the id attribute of a role element specified for the workflow. This role will be used to define the epersons and groups used by the userSelectionMethod.
  • RequiredUsers
Code Block
languagehtml/xml
<bean name="reviewstep" class="org.dspace.xmlworkflow.state.Step">
    <property name="userSelectionMethod" ref="claimaction"/>
    <property name="role" ref="reviewer"/>
    <property name="outcomes">
        <util:map>
            <entry key="#{ T(org.dspace.xmlworkflow.state.actions.ActionResult).OUTCOME_COMPLETE}"
                   value-ref="editstep"/>
        </util:map>
    </property>
    <property name="actions">
        <util:list>
            <ref bean="reviewaction"/>
        </util:list>
    </property>
</bean> 

...

There is also an optional subsection that can be defined for a step part called "outcomes". This can be used to define outcomes for the step that differ from the one specified in the nextStep attribute. Each action returns an integer depending on the result of the action. The default value is "0" and will make the workflow item proceed to the next action or to the end of the step.
In case an action returns a different outcome than the default "0", the alternative outcomes will be used to lookup the next step. The "outcomes" element contains a number of steps, each having a status attribute. This status attribute defines the return value of an action. The value of the element will be used to lookup the next step the workflow item will go through in case an action returns that specified status.

...

The workflow actions configuration is located in the [dspace]/config/spring/api/ directory and is named "workflow-actions.xml". This configuration file describes the different Action Java classes that are used by the workflow framework. Because the workflow framework uses Spring framework for loading these action classes, this configuration file contains Spring configuration.

This file contains the beans for the actions and user selection methods referred to in the workflow.xml. In order for the workflow framework to work properly, each of the required actions must be part of this configuration.

Code Block
languagehtml/xml
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

    <!-- At the top are our bean class identifiers --->
    <bean id="{action.api.id}" class="{class.path}" scope="prototype"/>
    <bean id="{action.api.id.2}" class="{class.path}" scope="prototype"/>

	 <!-- Below the class identifiers come the declarations for out actions/userSelectionMethods -->

	 <!-- Use class workflowActionConfig for an action -->
	 <bean id="{action.id}" class="oorg.dspace.xmlworkflow.state.actions.WorkflowActionConfig" scope="prototype">
	     <constructor-arg type="java.lang.String" value="{action.id}"/>

	     <property name="processingAction" ref="{action.api.id}"/>
	     <property name="requiresUI" value="{true/false}"/>
	 </bean>

	 <!-- Use class UserSelectionActionConfig for a user selection method -->
	 <!--User selection actions-->
	 <bean id="{action.api.id.2}" class="org.dspace.xmlworkflow.state.actions.UserSelectionActionConfig" scope="prototype">
	     <constructor-arg type="java.lang.String" value="{action.api.id.2}"/>

	     <property name="processingAction" ref="{user.selection.bean.id}"/>
	     <property name="requiresUI" value="{true/false}"/>
	 </bean>
</beans>

Two types of actions are configured in this Spring configuration file:

  • User selection action: This type of action is always the first action of a step and is responsible for the user selection process of that step. In case a step has no role attached, no user will be selected and the NoUserSelectionAction is used.
  • Processing action: This type of action is used for the actual processing of a step. Processing actions contain the logic required to execute the required operations in each step. Multiple processing actions can be defined in one step. These user and the workflow item will go through these actions in the order they are specified in the workflow configuration unless an alternative outcome is returned by one of them.

...

Each user selection action that is used in the workflow config configuration refers to a bean definition in this the workflow-actions.xml configuration file. In order to create define a new user selection action bean, the following XML code is used:

...

  • constructor-arg: This is a constructor argument containing the ID of the task. This is the same as the id attribute of the bean and is used by the workflow config configuration to refer to this action.
  • property processingAction: This tag refers the the ID of the API bean, responsible for the implementation of the API side of this action. This bean should also be configured in this XML.
  • property requiresUI: In case this property is true, the workflow framework will expect a user interface for the action. Otherwise the framework will automatically execute the action and proceed to the next one.

...

Processing actions are configured similar similarly to the user selection actions. The only difference is that these processing action beans are implementations of the WorkflowActionConfig class instead of the UserSelectionActionConfig class.

...

The configuration file for the workflow user interface actions is located in the [dspace]/config/spring/xmlui/ and is named "workflow-actions-xmlui.xml".  Each bean defined here has an id which is the action identifier and the class is a classpath which links to the xmlui class responsible for generating the User Interface side of the workflow action. Each of the class defined here must extend the org.dspace.app.xmlui.aspect.submission.workflow.AbstractXMLUIAction class, this class contains some basic settings for an action and has a method called addWorkflowItemInformation() which will render the given item with a show full link so you don't have to write the same code in each of your actions if you want to display the item. The id attribute used for the beans in the configuration must correspond to the id used in the workflow configuration. In case an action requires a User Interface class, the workflow framework will look for a UI class in this configuration file.

...