001: package org.enhydra.shark.xpdl.elements;
002:
003: import org.enhydra.shark.xpdl.XMLAttribute;
004: import org.enhydra.shark.xpdl.XMLCollectionElement;
005:
006: /**
007: * Represents coresponding element from XPDL schema.
008: *
009: * @author Sasa Bojanic
010: */
011: public class Transition extends XMLCollectionElement {
012:
013: protected transient Activity toActivity;
014: protected transient Activity fromActivity;
015:
016: public Transition(Transitions parent) {
017: super (parent, true);
018: }
019:
020: protected void fillStructure() {
021: XMLAttribute attrFrom = new XMLAttribute(this , "From", true); //required
022: XMLAttribute attrTo = new XMLAttribute(this , "To", true); //required
023: XMLAttribute attrName = new XMLAttribute(this , "Name", false);
024: Condition refCondition = new Condition(this ); // min==0
025: Description refDescription = new Description(this ); // min=0
026: ExtendedAttributes refExtendedAttributes = new ExtendedAttributes(
027: this ); // min=0
028:
029: super .fillStructure();
030: add(attrName);
031: add(attrFrom);
032: add(attrTo);
033: add(refCondition);
034: add(refDescription);
035: add(refExtendedAttributes);
036: }
037:
038: public void initCaches() {
039: super .initCaches();
040: Activities acts;
041: if (getParent().getParent() instanceof WorkflowProcess) {
042: acts = ((WorkflowProcess) getParent().getParent())
043: .getActivities();
044: } else {
045: acts = ((ActivitySet) getParent().getParent())
046: .getActivities();
047: }
048: toActivity = acts.getActivity(getTo());
049: fromActivity = acts.getActivity(getFrom());
050: }
051:
052: public void clearCaches() {
053: toActivity = null;
054: fromActivity = null;
055: super .clearCaches();
056: }
057:
058: public Activity getToActivity() {
059: if (!isReadOnly) {
060: throw new RuntimeException(
061: "This method can be used only in read-only mode!");
062: }
063: return toActivity;
064: }
065:
066: public Activity getFromActivity() {
067: if (!isReadOnly) {
068: throw new RuntimeException(
069: "This method can be used only in read-only mode!");
070: }
071: return fromActivity;
072: }
073:
074: public String getFrom() {
075: return get("From").toValue();
076: }
077:
078: public void setFrom(String from) {
079: set("From", from);
080: }
081:
082: public String getTo() {
083: return get("To").toValue();
084: }
085:
086: public void setTo(String to) {
087: set("To", to);
088: }
089:
090: public String getName() {
091: return get("Name").toValue();
092: }
093:
094: public void setName(String name) {
095: set("Name", name);
096: }
097:
098: public String getDescription() {
099: return get("Description").toValue();
100: }
101:
102: public void setDescription(String description) {
103: set("Description", description);
104: }
105:
106: public Condition getCondition() {
107: return (Condition) get("Condition");
108: }
109:
110: public ExtendedAttributes getExtendedAttributes() {
111: return (ExtendedAttributes) get("ExtendedAttributes");
112: }
113: }
|