Java Reference
In-Depth Information
returns the activities that have no predecessors, i.e. those to be executed
first.
The constructor receives a
org.w3c.dom.Element
object that contains the
parsed description of a business process. It invokes recursively the other
classes to build a representation of the process. The method
toXML()
does
the reverse job: it generates the DOM representation of a process.
package
ProcessDefinition;
import
org.w3c.dom.*;
import
java.util.Hashtable;
import
java.util.Iterator;
import
java.util.Collection;
import
java.util.Vector;
public class
WfProcessDefinition {
static final
String TAG
#
"WORKFLOW";
String id; // attribute id
String name; // attribute name
String description; // attribute description
String version; // attribute version
String category; // attribute category
Hashtable activities
#
new Hashtable();
// the activities of the process
Hashtable participants
#
new Hashtable();
// the process' participants
// getter methods for the attributes
public
String getName() {
return
name; }
public
String getDescription() {
return
description; }
public
String getVersion() {
return
version; }
public
String getCategory() {
return
category; }
// returns the initial activities
// i.e. those without a predecessor
public
Collection initialActivities(){
Iterator it
#
activities.values().iterator();
Vector result
#
new Vector();
while
(it.hasNext()){
WfActivityDefinition activity
#
(WfActivityDefinition)it.next();
if
(activity.isStart())
result.add(activity);
}
return
result;
}
// return a collection of all the definitions contained
// in a file
public static
Collection loadDefinitions(Document doc){
NodeList processes
#
doc.getElementsByTagName("WORKFLOW");
Collection definitions
#
new
Vector();