KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > elements > WorkflowProcess


1 /* WorkflowProcess.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.xml.elements;
12
13 import org.enhydra.jawe.xml.ToNameMutableTreeNode;
14 import org.enhydra.jawe.xml.*;
15 import org.enhydra.jawe.xml.panels.*;
16
17 import javax.swing.*;
18 import java.util.*;
19 import java.awt.*;
20 import javax.swing.tree.*;
21 import javax.swing.*;
22
23 import org.w3c.dom.*;
24
25 /**
26  * Represents a WfMC DTD element that has the similar name.
27  */

28 public class WorkflowProcess extends XMLCollectionElement {
29    private ProcessHeader refProcessHeader=new ProcessHeader();
30    private RedefinableHeader refRedefinableHeader=new RedefinableHeader(this); // min=0
31
private FormalParameters refFormalParameters;
32    private DataFields refDataFields=new DataFields(this); // min=0
33
private Participants refParticipants; // min=0
34
private Applications refApplications=new Applications(this); // min=0
35
private ActivitySets refActivitySets=new ActivitySets(this); // min=0
36
private Activities refActivities=new Activities(this); // min=0
37
private Transitions refTransitions=new Transitions(this); // min=0
38
private ExtendedAttributes refExtendedAttributes=new ExtendedAttributes(this); // min=0
39

40
41    private XMLAttribute attrName=new XMLAttribute("Name");
42    private XMLAttribute attrAccessLevel=new XMLAttribute("AccessLevel",
43                                                          new String JavaDoc[] {
44             "",
45                "PUBLIC",
46                "PRIVATE"
47          },1);
48
49
50    /** The container for all processes. */
51    private Package JavaDoc myPackage=null;
52
53    /**
54     * Used to hold the visual order of participants
55     * within workflow process graph. Set and valid only
56     * immediatelly after exporting to or immediatelly
57     * after importing from an XML file.
58     */

59    private String JavaDoc visuallySortedParticipantIDs="";
60
61    /*
62     * The set of strings where extended attribute information for description
63     * of visual properties for starts of workflow process are held. This
64     * information is valid only immediatelly after exporting to or immediatelly
65     * after importing from an XML file.
66     */

67    private Set startDescriptions=new HashSet();
68    /*
69     * The set of strings where extended attribute information for description
70     * of visual properties for ends of workflow process are held. Set and valid
71     * only immediatelly after exporting to or immediatelly after
72     * importing from an XML file.
73     */

74    private Set endDescriptions=new HashSet();
75
76    /** Enables canceling of changes to the extended attributes collection. */
77    private ExtendedAttributes clonedEAs;
78
79
80    // Ids for activities and transitions must be unique, no matter if they
81
// are defined inside ActivitySet or directly inside WorkflowProcess
82
private transient long nextActivityId=0;
83    private transient long nextTransitionId=0;
84
85    /**
86     * Creates a new instance of the class.
87     *
88     * @param wps The reference to collection of workflow processes where
89     * this instance will be put into.
90     * @param p The container for all processes.
91     */

92    public WorkflowProcess (WorkflowProcesses wps,Package JavaDoc p) {
93       super(wps);
94       this.myPackage=p;
95       // must be defined here because somewhere else in code
96
// (Participants constructor) is checked for a JaWE
97
refParticipants=new Participants(this); // min=0
98
refFormalParameters=new FormalParameters(this,myPackage); // min=0
99

100       try {
101          setIDPrefixForCollections();
102       } catch (Exception JavaDoc ex) {}
103
104       fillStructure();
105
106       // inherit redefinable header values from package
107
// NOTE: MUST BE DEFINED AFTER fillStructure
108
try {
109          RedefinableHeader prh=(RedefinableHeader)p.get("RedefinableHeader");
110          refRedefinableHeader.set("Author",prh.get("Author").toString());
111          refRedefinableHeader.set("Version",prh.get("Version").toString());
112          refRedefinableHeader.set("Codepage",prh.get("Codepage").toString());
113          refRedefinableHeader.set("Countrykey",prh.get("Countrykey").toString());
114          refRedefinableHeader.set("PublicationStatus",
115                                      ((XMLAttribute)prh.get("PublicationStatus")).getChoosen());
116          Responsibles rwp=(Responsibles)refRedefinableHeader.get("Responsibles");
117          Responsibles rpkg=(Responsibles)prh.get("Responsibles");
118          Iterator it=rpkg.toCollection().iterator();
119          while (it.hasNext()) {
120             Responsible r=(Responsible)it.next();
121             Responsible rNew=(Responsible)rwp.generateNewElement();
122             rNew.setValue(r.toValue());
123             rwp.add(rNew);
124          }
125       } catch (Exception JavaDoc ex) {}
126
127    }
128
129    /**
130     * Defines the super-class method. Read the explanation for
131     * this method within XMLComplexElement class.
132     */

133    protected void fillStructure () {
134       super.fillStructure();
135       complexStructure.add(attrName);
136       attributes.add(attrName);
137       complexStructure.add(attrAccessLevel);
138       attributes.add(attrAccessLevel);
139       refProcessHeader.setRequired(true);
140       complexStructure.add(refProcessHeader);
141       complexStructure.add(refRedefinableHeader);
142       complexStructure.add(refFormalParameters);
143       complexStructure.add(refDataFields);
144       complexStructure.add(refParticipants);
145       complexStructure.add(refApplications);
146       complexStructure.add(refActivitySets);
147       complexStructure.add(refActivities);
148       complexStructure.add(refTransitions);
149       complexStructure.add(refExtendedAttributes);
150    }
151
152    /**
153     * Returns the package that is container for process.
154     *
155     * @return The package of workflow process.
156     */

157    public Package JavaDoc getPackage () {
158       return myPackage;
159    }
160
161    /**
162     * Returns set of entities to be inserted for given object. The
163     * object can be workflow process or block activity.
164     */

165    public java.util.List JavaDoc getEntitiesToInsert (Object JavaDoc forObject) {
166       java.util.List JavaDoc lhs=new ArrayList();
167       boolean isMine=myPackage.isMadeByJaWE();
168       Collection acts=null;
169       Collection parts=null;
170       Collection trans=null;
171       if (forObject instanceof WorkflowProcess) {
172          acts=refActivities.toCollection();
173          trans=refTransitions.toCollection();
174       } else if (forObject instanceof Activity) {
175          Activity act=(Activity)forObject;
176          BlockActivity ba=act.getBlockActivity();
177          String JavaDoc baID="";
178          if (ba!=null) {
179             baID=ba.get("BlockId").toValue().toString();
180          }
181          ActivitySet as=refActivitySets.getActivitySet(baID);
182          if (as!=null) {
183             acts=((Activities)as.get("Activities")).toCollection();
184             trans=((Transitions)as.get("Transitions")).toCollection();
185          }
186       }
187
188       try {
189          parts=gatherParticipants(forObject,acts,isMine);
190          lhs.addAll(acts);
191          lhs.addAll(parts);
192          lhs.addAll(trans);
193       } catch (Exception JavaDoc ex) {}
194
195       //displayContent(lhs,forObject);
196
return lhs;
197    }
198
199    // *************** DEBUG
200
private void displayContent (HashSet hs,Object JavaDoc forObject) {
201       Iterator it=hs.iterator();
202       System.out.println("Entities inside "+forObject+":");
203       while (it.hasNext()) {
204          Object JavaDoc nxt=it.next();
205          if (nxt instanceof Transition) {
206             System.out.println("----------> "+((Transition)nxt).get("Name"));
207          }
208          else {
209             System.out.println("----------> "+nxt+", instance of"+nxt.getClass());
210          }
211       }
212    }
213
214    /*
215     * Returns extended attribute information for description
216     * of visual properties for all starts of workflow process. Valid only
217     * after importing from an XML.
218     *
219     * @return The specific set of descriptions of Start objects attributes.
220     */

221    public Set getStartDescriptions () {
222       return startDescriptions;
223    }
224
225    /*
226     * Sets extended attribute information for description
227     * of visual properties for all starts of workflow process.
228     *
229     * @param sd The specific set of descriptions of Start objects attributes.
230     */

231    public void setStartDescriptions (Set sd) {
232       startDescriptions=sd;
233    }
234
235    /*
236     * Returns extended attribute information for description
237     * of visual properties for all ends of workflow process after.
238     * Valid only after importing from an XML.
239     *
240     * @return The specific set of descriptions of End objects attributes.
241     */

242    public Set getEndDescriptions () {
243       return endDescriptions;
244    }
245
246    /*
247     * Sets extended attribute information for description
248     * of visual properties for all ends of workflow process.
249     *
250     * @param eds The specific set of descriptions of End objects attributes.
251     */

252    public void setEndDescriptions (Set eds) {
253       endDescriptions=eds;
254    }
255
256    /**
257     * Used to get the visual order of participant visual
258     * objects contained within a WorkflowProcess graph.
259     * <p>NOTE: This order is valid only immediately after
260     * import of WorkflowProcess or it's export to XML file, also,
261     * this order is an ExtendedAttribute in a WfMC DTD sence, so
262     * it is valid only for XMLs saved by this version of the
263     * JaWE application.
264     *
265     * @return String representation of visually sorted participant ID's.
266     */

267    public String JavaDoc getVisuallySortedParticipantIDs () {
268       return visuallySortedParticipantIDs;
269    }
270
271    /**
272     * Used to set the visual order of participant visual
273     * objects contained within a WorkflowProcess graph.
274     *
275     * @param vsPID String representation of visually sorted participant ID's.
276     */

277    public void setVisuallySortedParticipantIDs (String JavaDoc vsPID) {
278       visuallySortedParticipantIDs=vsPID;
279    }
280
281    /**
282     * Gets the tooltip for participant. The tooltip consists of
283     * property names and values.
284     *
285     * @return The tooltip to be displayed when user holds the
286     * mouse above participant's graph object.
287     */

288    public String JavaDoc getTooltip () {
289       return XMLUtil.makeTooltip(new XMLElement[] {attrId,attrName,attrAccessLevel,
290                   refProcessHeader.get("Created"),refProcessHeader.get("Description"),
291                   refProcessHeader.get("Priority"),refProcessHeader.get("Limit"),
292                   refProcessHeader.get("ValidFrom"),refProcessHeader.get("ValidTo"),
293                   refRedefinableHeader.get("Author"),refRedefinableHeader.get("Version"),
294                   refRedefinableHeader.get("Codepage"),refRedefinableHeader.get("Countrykey"),
295                   refRedefinableHeader.get("PublicationStatus")});
296    }
297
298
299    /**
300     * Overrides super-class method to realize this class specific
301     * writting to XML file.
302     *
303     * @return The string for a WfMC DTD WorkflowProcess element tag.
304     */

305    public void toXML (Node parent) throws DOMException {
306       ExtendedAttribute ea;
307       Iterator it;
308
309       // remove all internally used ext. attribs
310
Set easToRemove=new HashSet();
311       if (visuallySortedParticipantIDs.length()>0) {
312          ea=new ExtendedAttribute(refExtendedAttributes);
313          ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea);
314          ea.set("Name","ParticipantVisualOrder");
315          ea.set("Value",visuallySortedParticipantIDs);
316          easToRemove.add(ea);
317       }
318
319       // ************** writting start and end activities
320
if (endDescriptions.size()>0) {
321          it=endDescriptions.iterator();
322          while (it.hasNext()) {
323             ea=new ExtendedAttribute(refExtendedAttributes);
324             ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea);
325             ea.set("Name","EndOfWorkflow");
326             ea.set("Value",(String JavaDoc)it.next());
327             easToRemove.add(ea);
328          }
329       }
330       if (startDescriptions.size()>0) {
331          it=startDescriptions.iterator();
332          while (it.hasNext()) {
333             ea=new ExtendedAttribute(refExtendedAttributes);
334             ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea);
335             ea.set("Name","StartOfWorkflow");
336             ea.set("Value",(String JavaDoc)it.next());
337             easToRemove.add(ea);
338          }
339       }
340       if (parent.getOwnerDocument()!=null) {
341          super.toXML(parent);
342          // this happens when user wants to view XPDL presentation of the graph
343
} else {
344          Node node = ((Document) parent).createElement(name);
345          super.toXML(node);
346          parent.appendChild(node);
347       }
348
349       //removing internally used ext. attribs - otherwise, it would be duplicated
350
refExtendedAttributes.toCollection().removeAll(easToRemove);
351    }
352
353    /**
354     * Called by Package object after importing of XML file to determine
355     * correct block activites and loop activities, and after that
356     * to determine the activities to insert at the workflow process graph.
357     */

358    protected void afterImporting () {
359       // checking if package is made by our PE, and depending on
360
// that information, collects InlineBlock, Loop and main
361
// graph information, and sorts them properly
362
boolean isMine=myPackage.isMadeByJaWE();
363
364       // remove all internally used ext. attribs
365
Set easToRemove=new HashSet();
366
367       if (isMine) {
368          Iterator it=refExtendedAttributes.toCollection().iterator();
369          String JavaDoc nm="";
370          String JavaDoc val="";
371          while (it.hasNext()) {
372             ExtendedAttribute ea=(ExtendedAttribute)it.next();
373             nm=ea.get("Name").toValue().toString();
374             val=ea.get("Value").toValue().toString();
375             if (nm.equals("ParticipantVisualOrder") && visuallySortedParticipantIDs.length()==0) {
376                visuallySortedParticipantIDs=val;
377                easToRemove.add(ea);
378             }
379             if (nm.equals("StartOfWorkflow")) {
380                if (XMLUtil.howManyStringsWithinString(val,";")==4) {
381                   startDescriptions.add(val);
382                   easToRemove.add(ea);
383                }
384             }
385             if (nm.equals("EndOfWorkflow")) {
386                if (XMLUtil.howManyStringsWithinString(val,";")==4) {
387                   endDescriptions.add(val);
388                   easToRemove.add(ea);
389                }
390             }
391          }
392       }
393       //removing internally used ext. attribs - otherwise, it would
394
// be shown within ea list
395
refExtendedAttributes.toCollection().removeAll(easToRemove);
396
397       // Setting the responsibles
398
refRedefinableHeader.afterImporting();
399       // Adjusting neccessary activities
400
// Adjusting neccessary activities
401
refActivitySets.afterImporting();
402       refActivities.afterImporting();
403       refTransitions.afterImporting();
404       refActivities.fillOutgoingTransitions();
405    }
406
407    /**
408     * Returns the sorted set of participants for given object.
409     * The object can be block activity or workflow process.
410     */

411    private java.util.List JavaDoc gatherParticipants (Object JavaDoc forObject,
412                                               Collection ownedActivities,boolean isMine) {
413
414       java.util.List JavaDoc gatherInto=new ArrayList();
415
416       String JavaDoc vsIDs="";
417       String JavaDoc[] vIDs=null;
418
419       if (isMine) {
420          String JavaDoc delimiterSign=";";
421          // if this is a block activity
422
if (forObject instanceof Activity) {
423             Activity block=(Activity)forObject;
424             vsIDs=block.getVisuallySortedParticipantIDs();
425             // it is a main graph of workflow process
426
} else {
427             vsIDs=getVisuallySortedParticipantIDs();
428          }
429          vIDs=XMLUtil.tokenize(vsIDs,delimiterSign);
430          // case when importing XML from other vendors
431
} else {
432          if (ownedActivities.size()>0) {
433             Set partIDs=new HashSet();
434             Iterator it=ownedActivities.iterator();
435             Activity a;
436
437             String JavaDoc ID;
438             while (it.hasNext()) {
439                Object JavaDoc nextObj=it.next();
440                if (nextObj instanceof Activity) {
441                   a=(Activity)nextObj;
442                   Object JavaDoc p=a.get("Performer").toValue();
443                   if (p!=null) {
444                      if (p instanceof Participant) {
445                         ID=((Participant)p).getID();
446                      } else {
447                         ID=p.toString();
448                      }
449                      partIDs.add(ID);
450                   }
451                }
452             }
453             if (partIDs.size()>0) {
454                vIDs=new String JavaDoc[partIDs.size()];
455                partIDs.toArray(vIDs);
456             }
457          }
458       }
459
460       // inserting participants in ordered set
461
if (vIDs!=null && vIDs.length>0) {
462          Participant defaultP=Participant.getFreeTextExpressionParticipant();
463          for (int i=0; i<vIDs.length; i++) {
464             String JavaDoc pID=vIDs[i];
465             Participant p=refParticipants.getParticipant(pID);
466             if (p!=null) {
467                gatherInto.add(p);
468             } else {
469                if (!gatherInto.contains(defaultP)) {
470                   gatherInto.add(defaultP);
471                }
472             }
473          }
474       }
475       // if there is no known participant and it should be, add the
476
// default participant
477
if (gatherInto.size()==0 && ownedActivities.size()>0) {
478          gatherInto.add(Participant.getFreeTextExpressionParticipant());
479       }
480
481       return gatherInto;
482    }
483
484    /**
485     * Overrides super-class method to retreive the value
486     * of this class "Name" attribute, or if it does not exist,
487     * the value of "Id" attribute.
488     * This is used when displaying instance of this class
489     * within dialog.
490     *
491     * @return The "Name" attribute value of this class.
492     */

493    public String JavaDoc toString() {
494       String JavaDoc disp=attrName.toString();
495       if (disp.trim().length()==0) {
496          disp=attrId.toString();
497       }
498       return disp;
499    }
500
501    /**
502     * Prepares the one of the group panels that contains some of
503     * this element editable fields.
504     *
505     * @param no The ordinal number of group panel to be shown.
506     * @return XMLPanel to be shown.
507     */

508    public XMLPanel getPanel (int no) {
509       XMLPanel p;
510       switch (no) {
511          case 1:
512             clonedEAs=(ExtendedAttributes)refExtendedAttributes.clone();
513             p=new XMLGroupPanel(this,
514                                 new XMLElement[] {
515                      attrId,
516                         attrName,
517                         attrAccessLevel,
518                         clonedEAs
519                   },XMLUtil.getLanguageDependentString("GeneralKey"));
520             break;
521          case 2:
522             p=refProcessHeader.getPanel();
523             break;
524          case 3:
525             p=refRedefinableHeader.getPanel();
526             break;
527          case 4:
528             p=refParticipants.getPanel();
529             break;
530          case 5:
531             p=refApplications.getPanel();
532             break;
533          case 6:
534             p=refDataFields.getPanel();
535             break;
536          case 7:
537             p=refFormalParameters.getPanel();
538             break;
539          case 8:
540             p=refActivities.getPanel();
541             break;
542          case 9:
543             p=refTransitions.getPanel();
544             break;
545          case 10:
546             p=refActivitySets.getPanel();
547             break;
548          default:
549             p=new XMLPanel();
550       }
551       return p;
552    }
553
554
555    /**
556     * Prepares the tabbed panel to show editable fields of WorkflowProcess.
557     * Panel consists of seven tabs that logically comprises the
558     * WorkflowProcesses elements to be edited.
559     * <p>NOTE: This method is never used, panels are retrieved one by one
560     * calling the method with the same name but with ordinal
561     * number of wanted panel as an argument.
562     *
563     * @return XMLPanel to be shown.
564     */

565    public XMLPanel getPanel () {
566       XMLPanel[] p=new XMLPanel[10];
567       for (int i=0; i<10; i++) {
568          p[i]=getPanel(i+1);
569       }
570       XMLTabbedPanel tp=new XMLTabbedPanel(this,p);
571
572       return tp;
573    }
574
575    /** Sets proper ID prefix for all Id generators (XMLCollection class instances). */
576    protected void setIDPrefixForCollections () {
577       String JavaDoc colPref=getID()+this.ID_DELIMITER;
578       refApplications.setIDPrefix(colPref+"App");
579       refActivitySets.setIDPrefix(colPref+"Ase");
580       refActivities.setIDPrefix(colPref+"Act");
581       refDataFields.setIDPrefix(colPref+"Dat");
582       refFormalParameters.setIDPrefix(colPref+"For");
583       refParticipants.setIDPrefix(colPref+"Par");
584       refTransitions.setIDPrefix(colPref+"Tra");
585    }
586
587
588    public void fromXML(Node node) {
589       attrAccessLevel.setValue("");
590
591       // clearing redefinable header that is filled during creation of
592
// object with intention to inherit properties from package
593
refRedefinableHeader.set("Author","");
594       refRedefinableHeader.set("Version","");
595       refRedefinableHeader.set("Codepage","");
596       refRedefinableHeader.set("Countrykey","");
597       XMLAttribute ps=(XMLAttribute)refRedefinableHeader.get("PublicationStatus");
598       try {
599          ps.setValue(ps.getChoices()[0]);
600       } catch (Exception JavaDoc ex) {}
601       Responsibles rsp=(Responsibles)refRedefinableHeader.get("Responsibles");
602       rsp.clear();
603
604       processAttributes(node);
605
606       setIDPrefixForCollections();
607
608       processElements(node);
609
610       ((WorkflowProcesses)myCollection).updateID(getID());
611    }
612
613    public void readFromXML(Node node) {
614       // clearing redefinable header that is filled during creation of
615
// object with intention to inherit properties from package
616
refRedefinableHeader.set("Author","");
617       refRedefinableHeader.set("Version","");
618       refRedefinableHeader.set("Codepage","");
619       refRedefinableHeader.set("Countrykey","");
620       XMLAttribute ps=(XMLAttribute)refRedefinableHeader.get("PublicationStatus");
621       try {
622          ps.setValue(ps.getChoices()[0]);
623       } catch (Exception JavaDoc ex) {}
624       Responsibles rsp=(Responsibles)refRedefinableHeader.get("Responsibles");
625       rsp.clear();
626       super.fromXML(node);
627    }
628
629    /**
630     * Checks if an ID entered by the user is unique.
631     */

632    public boolean isIDUniqueAndValid (XMLPanel tabbedPanel) {
633       XMLGroupPanel groupPanel=(XMLGroupPanel)((XMLTabbedPanel)tabbedPanel).getTabbedPanel(0);
634       XMLTextPanel tp=(XMLTextPanel)groupPanel.getPanel(0);
635       String JavaDoc IDToCheck=tp.getText();
636       // if there is an element with given ID, return false
637
XMLComplexElement wp=getCollection().getCollectionElement(IDToCheck);
638       boolean isOK=true;
639       String JavaDoc message=null;
640       String JavaDoc dialogTitle=null;
641       if (wp!=null && wp!=this) {
642          message=XMLUtil.getLanguageDependentString("ErrorIDMustBeUnique");
643          dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotUnique");
644          isOK=false;
645       } else if (!XMLCollection.isIdValid(IDToCheck)) {
646          message=XMLUtil.getLanguageDependentString("ErrorIDMustBeValid");
647          dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotValid");
648          isOK=false;
649       }
650       if (!isOK) {
651          XMLPanel.errorMessage(groupPanel.getDialog(),dialogTitle,"",message);
652          ((JTextField)tp.getComponent(2)).requestFocus();
653       }
654       return isOK;
655    }
656
657
658    public boolean isValidEnter (XMLPanel p) {
659       refRedefinableHeader.isValidEnter(((XMLTabbedPanel)p).getTabbedPanel(2));
660       if (clonedEAs!=null) {
661          complexStructure.remove(refExtendedAttributes);
662          refExtendedAttributes=clonedEAs;
663          complexStructure.add(12,refExtendedAttributes);
664       }
665       return true;
666    }
667
668    /*
669     public void getProcessTree(DefaultMutableTreeNode parent) {
670     createActivityTree(parent);
671     createActivitySetTree(parent);
672     }
673
674     private void createActivityTree(DefaultMutableTreeNode parent) {
675     for( int i = 0; i < this.refActivities.size(); i++ ) {
676     DefaultMutableTreeNode node = new ToNameMutableTreeNode( ((Activity)this.refActivities.get(i)) );
677     parent.add(node);
678     }
679     }
680
681     private void createActivitySetTree(DefaultMutableTreeNode parent) {
682     for( int i = 0; i < this.refActivitySets.size(); i++ ) {
683     DefaultMutableTreeNode node = new ToNameMutableTreeNode( ((ActivitySet)this.refActivitySets.get(i)) );
684     ((ActivitySet)this.refActivitySets.get(i)).getActivityTree(node);
685     parent.add(node);
686     }
687     }
688     */

689
690    public long getNextActivityId () {
691       return (++nextActivityId);
692    }
693
694    public long getCurrentActivityId () {
695       return nextActivityId;
696    }
697
698    public void setCurrentActivityId (long curId) {
699       nextActivityId=curId;
700    }
701
702    public void decrementActivityId () {
703       nextActivityId--;
704    }
705
706    public void resetActivityId () {
707       nextActivityId=0;
708    }
709
710    public Activity getActivity (String JavaDoc id) {
711       Activity ret=refActivities.getActivity(id);
712       if (ret==null) {
713          Iterator ass=refActivitySets.toCollection().iterator();
714          while (ass.hasNext()) {
715             ActivitySet as=(ActivitySet)ass.next();
716             ret=((Activities)as.get("Activities")).getActivity(id);
717             if (ret!=null) {
718                break;
719             }
720          }
721       }
722       return ret;
723    }
724
725    public boolean isActivityIdDuplicated (String JavaDoc id) {
726       int cnt=0;
727       cnt+=((refActivities.getActivity(id)==null) ? 0 : 1);
728       Iterator ass=refActivitySets.toCollection().iterator();
729       while (ass.hasNext()) {
730          ActivitySet as=(ActivitySet)ass.next();
731          cnt+=((((Activities)as.get("Activities")).getActivity(id)==null) ? 0 : 1);
732          if (cnt>1) {
733             break;
734          }
735       }
736       return (cnt>1);
737    }
738
739    public long getNextTransitionId () {
740       return (++nextTransitionId);
741    }
742
743    public long getCurrentTransitionId () {
744       return nextTransitionId;
745    }
746
747    public void setCurrentTransitionId (long curId) {
748       nextTransitionId=curId;
749    }
750
751    public void decrementTransitionId () {
752       nextTransitionId--;
753    }
754
755    public void resetTransitionId () {
756       nextTransitionId=0;
757    }
758
759    public Transition getTransition (String JavaDoc id) {
760       Transition ret=refTransitions.getTransition(id);
761       if (ret==null) {
762          Iterator ass=refActivitySets.toCollection().iterator();
763          while (ass.hasNext()) {
764             ActivitySet as=(ActivitySet)ass.next();
765             ret=((Transitions)as.get("Transitions")).getTransition(id);
766             if (ret!=null) {
767                break;
768             }
769          }
770       }
771       return ret;
772    }
773
774    public boolean isTransitionIdDuplicated (String JavaDoc id) {
775       int cnt=0;
776       cnt+=((refTransitions.getTransition(id)==null) ? 0 : 1);
777       Iterator ass=refActivitySets.toCollection().iterator();
778       while (ass.hasNext()) {
779          ActivitySet as=(ActivitySet)ass.next();
780          cnt+=((((Transitions)as.get("Transitions")).getTransition(id)==null) ? 0 : 1);
781          if (cnt>1) {
782             break;
783          }
784       }
785       return (cnt>1);
786    }
787
788
789 }
790
Popular Tags