Java Reference
In-Depth Information
any information. Its constructor simply adds an outgoing and an incoming
link to the relevant activities.
package ProcessDefinition;
import org.w3c.dom.*;
import java.util.Map;
public class WfTransitionInformation {
static final String TAG # "TRANSITION";
WfTransitionInformation(Element transition,
Map activities){
// get the object corresponding to the ends of the
// transition
WfActivityDefinition to # (WfActivityDefinition)
activities.get(transition.getAttribute("TO"));
WfActivityDefinition from # (WfActivityDefinition)
activities.get(transition.getAttribute("FROM"));
// add an incoming link to the destination
to.addInput(from);
// add an outgoing link to the source
from.addOutput(to);
}
The other classes in the ProcessDefinition package are similar to (and
usually simpler than) the WfProcessDefinition class. They all have a con-
structor that loads the information from the XML DOM tree and a toXML()
method that generate the XPDL representation of the process.
21.4.4
Test
To test the functionalities of the process definition classes we read a process
model from an XML file and write it back to another XML file. The test
succeeds if the contents of the two files are the same, except for the order of
the tags. The test file is the one shown in Figure 21.7.
package ProcessDefinition;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.File;
import org.apache.crimson.tree.XmlDocument;
public class TestClasses {
public static void main(String[] args) throws Exception {
// create an XML parser
DocumentBuilder parser #
DocumentBuilderFactory.newInstance().newDocumentBuilder();
// parse the document and obtain a dom tree for the
// document
 
Search WWH ::




Custom Search