KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > graph > BlockActivityGraph


1 /* BlockActivityGraph.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.graph;
12
13 import org.enhydra.jawe.*;
14 import org.enhydra.jawe.xml.*;
15 import org.enhydra.jawe.xml.elements.*;
16 import org.jgraph.graph.*;
17
18 import java.util.*;
19 import javax.swing.*;
20
21 /**
22  * Implementation of block activity graph.
23  */

24 public class BlockActivityGraph extends ProcessGraph {
25
26    private BlockActivity myBlockActivity;
27    /**
28     * Written only to override original method.
29     * Newer supposed to be created this way.
30     */

31    public BlockActivityGraph() {
32       this((GraphModel)null,null);
33    }
34
35    /**
36     * Constructs block activity graph based on a given model.
37     */

38    public BlockActivityGraph(GraphModel model,BlockActivityEditor pe) {
39       super(model,pe);
40    }
41
42    public void setMyBlockActivity (BlockActivity ba) {
43       myBlockActivity=ba;
44    }
45
46    public BlockActivity getMyBlockActivity () {
47       return myBlockActivity;
48    }
49
50    protected void updateXMLObjectsBeforeChecking () {
51       // first update extended attributes for start and end for all block activities
52
Set blockActs=getWorkflowManager().getBlockActivities(true);
53       // add its block activity
54
blockActs.add(myBlockActivity);
55       Iterator itBas=blockActs.iterator();
56       while (itBas.hasNext()) {
57          BlockActivity ba=(BlockActivity)itBas.next();
58          ProcessEditor bwe=ba.getImplementationEditor();
59          org.enhydra.jawe.xml.elements.Activity bap=
60             (org.enhydra.jawe.xml.elements.Activity)
61             ba.getUserObject();
62          bap.setStartDescriptions(Utils.getStartDescriptions(bwe));
63          bap.setEndDescriptions(Utils.getEndDescriptions(bwe));
64       }
65    }
66
67    public boolean checkLogic (boolean fullCheck) {
68       PackageValidator pv=new PackageValidator(getXMLPackage(),true,true,false,false,
69                                                JaWEConfig.getInstance().getAllowUndefinedStartActivity(),
70                                                JaWEConfig.getInstance().getAllowUndefinedEndActivity(),
71                                                JaWEConfig.getInstance().getEncoding());
72       boolean isLogical=pv.checkActivitySet((ActivitySet)getXPDLObject(),fullCheck);
73       basicLogicError=pv.getBasicLogicError((ActivitySet)getXPDLObject());
74       logicErrors=pv.getLogicErrors((ActivitySet)getXPDLObject());
75       return isLogical;
76    }
77
78    /**
79     * Gets an XPDL object (DTDElement).
80     */

81    public XMLElement getXPDLObject () {
82       try {
83          String JavaDoc ID=myBlockActivity.getBlockID();
84          ActivitySet as=((ActivitySets)((WorkflowProcess)xmlObject).
85                             get("ActivitySets")).getActivitySet(ID);
86          return as;
87       } catch (Exception JavaDoc ex) {
88          return null;
89       }
90    }
91
92 }
93
94 /* End of BlockActivityGraph.java */
95
Popular Tags