First, Osworkflow two important concepts:
Steps: Steps
Actions: Actions
Initial-actions: Initialization steps
1. Steps step: Describe where a workflow is located
2. Actions: Specifies a change that may occur within the step, a step contains multiple actions, an action consists of two parts: the condition to perform this condition and the result after performing this action
3, Initial-actions: Initialization step, is a special step to start the workflow
Second, the attribute:
Old_status: Used to indicate what state is after the current step is completed
Status: Indicate the condition conditions that need to be checked, currently there are underway in Osworkflow, queued wait for processing, finished complete three kinds of states
Conditon: Similar logical judgment, can contain "and", "or" logic
Result: Results after executing action, in two types, conditional-result conditional result, unconditional-result unconditional result
Split, join: Process slicing/merging, split can provide multiple result,join to provide a result based on the status of multiple step
Three, Function:
Caller:osworkflow provides a built-in function that gets the user who is currently invoking the workflow and puts it into a character variable named Caller
Four: Run:
1, the first need to define the following several files:
Osworkflow.xml:
<?xml version= "1.0" encoding= "UTF-8"?>
<osworkflow>
<factory class= "Com.opensymphony.workflow.loader.XMLWorkflowFactory" >
<property key= "Resource" value= "Workflows.xml"/>
</factory>
</osworkflow>
<osworkflow> has a property: <persistence class= "Com.opensymphony.workflow.spi.memory.MemoryWorkflowStore"/> represents using memory to store process data
Xmlworkflowfactory: Manage process definition files, including the ability to read definition files and modify definition files, resource specify where to read the definition files
Workflows.xml:
<?xml version= "1.0" encoding= "UTF-8"?>
<workflows>
<workflow name= "Vc_audit" type= "resource" location= "Osworkflow/vc_audit.xml" ></workflow>
</workflows>
2. The following steps are performed (reference)
For simplicity's sake, we use Basicworkflow to create a single user pattern that avoids the hassle of writing other methods of getting users.
So let's create a ' testuser ' call to the workflow:
Workflow Workflow = new Basicworkflow ("TestUser");
The next step is to provide the configuration file, which in most cases simply passes a defaultconfiguration instance:
defaultconfiguration config = new defaultconfiguration ();
Workflow.setconfiguration (config);
Now that we've created and configured a workflow, it's time to start calling it.
Start and work on a workflow
First we need to call the Initialize method to start a workflow, which has 3 parameters, workflow name (defined in Workflows.xml, handled by Workflow Factory), Action ID (We want to invoke the ID of the initialization action), and initialize the variable. Because there is no need to initialize variables in the example, we just pass a null,
Long WorkflowId = Workflow.initialize ("MyTest", 1, NULL);
Now that we have a workflow instance, the returned WorkflowId can represent this instance in a subsequent operation. This parameter is used in most methods of workflow interface.
Inspection Workflow
Now let's verify that the workflow instances that are started are running as we expect. Based on the process definition, the current step we expect is the first step, and you should be able to perform the first action (start writing a draft).
Collection currentsteps = workflow.getcurrentsteps
(WORKFLOWID);
Verify that there is only one current step
Assertequals ("Unexpected number of current steps",
1, Currentsteps.size ());
Verify that this step is 1
Step Currentstep = (step) currentsteps.iterator (). Next ();
Assertequals ("Unexpected Current Step", 1,
Currentstep.getstepid ());
int[] Availableactions =
Workflow.getavailableactions (WORKFLOWID);
Verify that there is only one executable action
Assertequals ("Unexpected number of available actions", 1,
Availableactions.length);
Verify that this step is 1
Assertequals ("Unexpected Available action", 1, availableactions[0]);
Perform actions
Now that you've verified the workflow instance, as we expected in the first step, let's start with the first action:
Workflow.doaction (WorkflowId, 1, NULL);
It is simple to invoke the first action, the workflow engine changes the state to ' underway ' according to the specified conditions, and remains in the current step.
Now we can call the 2nd action in a similar way, and the conditions that are required are already satisfied.
After the 2nd action is called, there is no action available according to the process definition, and getavailableactions will return an empty array.
Five, Property set
1. PropertySet: Sometimes it may be necessary to persist a small amount of data at any point in the workflow, which is the PropertySet function, a type safety map that can be persisted, You can add any type of data to PropertySet (a workflow instance corresponds to a propertyset) and read the data in a later process using the following:
<function type= "BeanShell" >
<arg name= "Script" >propertyset.setstring ("foo", "Bar") </arg>
</function>
This allows us to add a persisted property "Foo", whose value is "bar". So in a later process, we can get this value.
2. Transient map: Temp variable
Valid only in the context of the current workflow invocation, Workflow.doaction (WORKFLOWID, 1, NULL), or stored in a temporary variable if the pass-in is not NULL
3. Register Register:
A global variable of a workflow, similar to PropertySet, can be obtained anywhere in the workflow instance, unlike PropertySet, where it is a non-persisted data that requires recalculation of the data for each invocation and the value of the register stored in the temporary variable transient Map, the Register interface must be implemented and before the initialization action
Six
Structural Analysis of Osworkflow table
1. os_wfentry Workflow Main Table, storing workflow name and status
Field Name Data type description
ID number auto-numbering
Name VARCHAR2 (20) workflow names
State number Workflow Status
2, Os_currentstep the current step table, storing the data currently in progress
Field Name Data type description
ID number auto-numbering
entry_id Number Workflow Numbers
step_id Number Step numbers
ACTION_ID Number Action ID
Owners of owner VARCHAR2 (20) steps
Start_date Date Start time
Finish_date Date End Time
Due_date Date Authorization Time
Status VARCHAR2 (20) state
CALLER VARCHAR2 (20) operator's account name
3, Os_currentstep_prev the previous step table, storing the current step and the previous step of the associated data
Field Name Data type description
ID Number Current Step No.
PREVIOUS number before step numbering
Preliminary study on Osworkflow