KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > xpdl > elements > Transition


1 package org.enhydra.shark.xpdl.elements;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import org.enhydra.shark.xpdl.XMLAttribute;
7 import org.enhydra.shark.xpdl.XMLCollectionElement;
8
9 /**
10  * Represents coresponding element from XPDL schema.
11  *
12  * @author Sasa Bojanic
13  */

14 public class Transition extends XMLCollectionElement {
15
16    protected transient Activity toActivity;
17    protected transient Activity fromActivity;
18    
19    public Transition (Transitions parent) {
20       super(parent, true);
21    }
22
23    protected void fillStructure () {
24       XMLAttribute attrFrom=new XMLAttribute(this,"From", true); //required
25
XMLAttribute attrTo=new XMLAttribute(this,"To", true); //required
26
XMLAttribute attrName=new XMLAttribute(this,"Name", false);
27       Condition refCondition=new Condition(this); // min==0
28
Description refDescription=new Description(this); // min=0
29
ExtendedAttributes refExtendedAttributes=new ExtendedAttributes(this); // min=0
30

31
32       super.fillStructure();
33       add(attrName);
34       add(attrFrom);
35       add(attrTo);
36       add(refCondition);
37       add(refDescription);
38       add(refExtendedAttributes);
39    }
40
41    public void initCaches () {
42       super.initCaches();
43       Activities acts;
44       if (getParent().getParent() instanceof WorkflowProcess) {
45          acts=((WorkflowProcess)getParent().getParent()).getActivities();
46       } else {
47          acts=((ActivitySet)getParent().getParent()).getActivities();
48       }
49       toActivity=acts.getActivity(getTo());
50       fromActivity=acts.getActivity(getFrom());
51    }
52    
53    public void clearCaches () {
54       toActivity=null;
55       fromActivity=null;
56       super.clearCaches();
57    }
58    
59    public Activity getToActivity () {
60       if (!isReadOnly) {
61          throw new RuntimeException JavaDoc("This method can be used only in read-only mode!");
62       }
63       return toActivity;
64    }
65       
66    public Activity getFromActivity () {
67       if (!isReadOnly) {
68          throw new RuntimeException JavaDoc("This method can be used only in read-only mode!");
69       }
70       return fromActivity;
71    }
72
73    public String JavaDoc getFrom() {
74       return get("From").toValue();
75    }
76    public void setFrom(String JavaDoc from) {
77       set("From",from);
78    }
79    public String JavaDoc getTo() {
80       return get("To").toValue();
81    }
82    public void setTo(String JavaDoc to) {
83       set("To",to);
84    }
85    public String JavaDoc getName() {
86       return get("Name").toValue();
87    }
88    public void setName(String JavaDoc name) {
89       set("Name",name);
90    }
91    public String JavaDoc getDescription() {
92       return get("Description").toValue();
93    }
94    public void setDescription(String JavaDoc description) {
95       set("Description",description);
96    }
97    public Condition getCondition() {
98       return (Condition)get("Condition");
99    }
100    public ExtendedAttributes getExtendedAttributes() {
101       return (ExtendedAttributes)get("ExtendedAttributes");
102    }
103 }
104
Popular Tags