XPDL process definitions

(You can easily create XPDLs by using our XPDL editor JaWE.)

How to write deadline expressions for activities?

In shark deadline expressions along with all process variables, you can use special variables. The Java type of these variables is java.util.Date, and here is their description:

  • PROCESS_STARTED_TIME - the time when the process is started

  • ACTIVITY_ACTIVATED_TIME - the time when process flow comes to activity and assignments for the activity are created

  • ACTIVITY_ACCEPTED_TIME - the time when the first assignment for the activity is accepted

Note

If activity is being rejected after its acceptance, or it is not accepted at all, the ACTIVITY_ACCEPTED_TIME is set to some maximum value in the future.

Here are some rules when creating deadline expressions:

  • Deadline expressions has to result in java.util.Date

  • If shark is setup not to re-evaluate deadlines, but to initially evaluate deadline limit times, ACTIVITY_ACCEPTED_TIME should not be used in expressions because it will contain some maximum time in the future

  • There shouldn't be process variables (DataField or FormalParameter entities from XPDL) that have the same Id as the one of previously listed.

Here are few examples of deadline expressions:

// Deadline limit is set to 15 secunds after accepting activity
var d=new java.util.Date();
d.setTime(ACTIVITY_ACCEPTED_TIME.getTime()+15000);
d;


// Deadline limit is set to 5 minutes after activity is started (activated)
var d=new java.util.Date();
d.setTime(ACTIVITY_ACTIVATED_TIME.getTime()+300000);
d;


// Deadline limit is set to 1 hour after process is started
var d=new java.util.Date();
d.setTime(PROCESS_STARTED_TIME.getTime()+3600000);
d;

How to write extended attributes to be able to update/view activity variables in shark's admin application

In order to update activity variable (defined by XPDL) in shark admin application(s), XPDL activity definition must contain some predefined extended attributes.

Suppose that XPDL process definition contains variable (XPDL DataField tag) called "x", and variable (XPDL FormalParameter type) called "input_var".

If while executing activity you would like admin user only to be able to view those variables, you should define following Activity's extended attributes:

<ExtendedAttribute Name="VariableToProcess_VIEW" Value="x"/>
<ExtendedAttribute Name="VariableToProcess_VIEW" Value="input_var"/>

If you would like user to update the same variables, you should define following Activity's extended attributes:

<ExtendedAttribute Name="VariableToProcess_UPDATE" Value="x"/>
<ExtendedAttribute Name="VariableToProcess_UPDATE" Value="input_var"/>

How to write XPDL to use custom Java classes as variables in Shark

To be able to do that, you should define variable as XPDLs external reference, and set its location attribute to be the full name of the Java class you want to use. I.e., it should look like:

...
<DataField Id="participants" IsArray="FALSE">
   <DataType>
      <ExternalReference location="org.enhydra.shark.wrd.Participants"/>
   </DataType>
</DataField>
...
...
<FormalParameter Id="participantGroup" Mode="INOUT">
   <DataType>
      <ExternalReference location="org.enhydra.shark.wrd.Participants"/>
   </DataType>
</FormalParameter>
...

Maybe the better approach is to define TypeDeclaration element that would be of that type. In that case you can use it everywhere (you do not need time to define appropriate DataType when creating Application's/SubFlow's FormalParameters):

...
<TypeDeclaration Id="participants_type">
   <ExternalReference location="org.enhydra.shark.wrd.Participants"/>
</TypeDeclaration>
...

and than define DataField or FormalParameter as follows:

...
<DataField Id="participants" IsArray="FALSE">
   <DataType>
      <DeclaredType Id="participants_type"/>
   </DataType>
</DataField>
...
<FormalParameter Id="participantGroup" Mode="INOUT">
   <DataType>
      <DeclaredType Id="participants_type"/>
   </DataType>
</FormalParameter>
...

The classes specified by ExternalReference element must be in shark's classpath.

How to define in XPDL that initial value of some variable should be 'null'

You should simply write "null" for InitialValue element of DataField:

<DataField Id="participants" IsArray="FALSE">
   <DataType>
      <DeclaredType Id="participants_type"/>
   </DataType>
   <InitialValue>null</InitialValue>
</DataField>

This enables you to use interfaces or abstract java classes as workflow variables. Concrete implementation of these variables can be created by some tool agent.

How to specify scripting language

Shark currently supports three script interpreters: JavaScript, BeanShell and Python (the last one is not fully tested). To tell shark which scripting language is used for writting conditional expressions (i.e. in Transition conditions), you should specify Package's script element:

# if you want to use java-like syntax (interpreted by BeanShell), specify:

<Script Type="text/java"/>

# if you want to use java script syntax, specify:

<Script Type="text/javascript"/>

# if you want to use python syntax, specify:

<Script Type="text/pythonscript"/>

Shark will complain if you do not specify Script, or if you specify value not supported by shark.

How to use XPDL to directly map Application definition to particular ToolAgent (no need for Application mapping in runtime)

If you would like to specify directly in XPDL what particular ToolAgent will be executed by Tool activity, you should define some extended attributes for XPDL Application definition.

The main extended attribute that should be defined by each Application definition that tends to be mapped to ToolAgent has name "ToolAgentClass", and its value should be full name of the class representing tool agent to be executed, i.e.:

<ExtendedAttribute Name="ToolAgentClass" Value="org.enhydra.shark.toolagent.JavaScriptToolAgent"/>

This attribute is read by Default tool shark's tool agent, and he executes specified ToolAgent based on the value of this attribute.

Other extended attributes are specific to implementation of the tool agent, and are read by them. I.e., JavaScript and BeanShell tool agent specify extended attribute named "Script", and its content is the script to be executed by this tool agent at the runtime. In this case, you are actually using XPDL for programming, i.e.:

<ExtendedAttribute Name="Script" Value="java.lang.System.out.println(&quot;I'm going to perform operation c=&quot;+a+&quot;*&quot;+b);&#10;c=a*b;&#10;java.lang.System.out.println(&quot;The result is c=&quot;+c);"/>

This script performs multiplication of variable "a" and "b", and stores it in "c" (those variables are formal parameters of XPDL Application definition).