blob: 10f67789530c3f7a6570b360ba0eb9f7fc7c5c85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
package com.c2kernel.lifecycle;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.graph.model.Vertex;
import com.c2kernel.graph.traversal.GraphTraversal;
import com.c2kernel.lifecycle.instance.Activity;
import com.c2kernel.lifecycle.instance.WfVertex;
import com.c2kernel.utils.KeyValuePair;
import com.c2kernel.utils.LocalObjectLoader;
/**
* @version $Revision: 1.46 $ $Date: 2005/10/05 07:39:36 $
* @author $Author: abranson $
*/
public class ActivitySlotDef extends WfVertexDef
{
private String activityDef;
/**
* Method setActivityDef.
*
* @param oActivityDef
*/
public void setActivityDef(String oActivityDef)
{
activityDef = oActivityDef;
}
/**
* Method getActivityDef.
*
* @return String
*/
public String getActivityDef()
{
return activityDef;
}
/**
* @see java.lang.Object#Object()
*/
public ActivitySlotDef()
{
getProperties().put("Name", "");
getProperties().put("Version", "last");
}
public ActivityDef getTheActivityDef() throws ObjectNotFoundException, InvalidDataException
{
ActivityDef actDef = LocalObjectLoader.getActDef(getActivityDef(), getActVersion());
if (actDef instanceof CompositeActivityDef)
mIsComposite = true;
return actDef;
}
/**
* @see com.c2kernel.lifecycle.WfVertexDef#verify()
*/
/** launch the verification of the ActivityDef */
public boolean verify()
{
mErrors.removeAllElements();
boolean err = true;
int nbInEdgres = getInEdges().length;
int nbOutEdges = getOutEdges().length;
if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId())
{
mErrors.add("Unreachable");
err = false;
}
else if (nbInEdgres > 1)
{
mErrors.add("Bad nb of previous");
err = false;
}
else if (nbOutEdges > 1)
{
mErrors.add("too many next");
err = false;
}
else if (nbOutEdges == 0)
{
if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity())
{
mErrors.add("too many endpoints");
err = false;
}
}
else
{
Vertex[] outV = getOutGraphables();
Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
boolean errInLoop = false;
for (int i = 0; i < outV.length; i++)
{
for (int j = 0; j < anteVertices.length; j++)
if (!loop() && outV[i].getID() == anteVertices[j].getID())
errInLoop = true;
}
if (errInLoop)
{
mErrors.add("Problem in Loop");
err = false;
}
}
return err;
}
/**
* Method getNextWfVertices.
*
* @return WfVertexDef[]
*/
public WfVertexDef[] getNextWfVertices()
{
return (WfVertexDef[]) getOutGraphables();
}
/**
* @see com.c2kernel.graph.model.GraphableVertex#isLayoutable()
*/
/**
* @see com.c2kernel.graph.model.GraphableVertex#getIsLayoutable()
*/
public boolean isLayoutable()
{
return true;
}
/**
* Method getInfo.
*
* @return CastorHashMap
*/
public void configureInstance(Activity act)
{
KeyValuePair[] k = getProperties().getKeyValuePairs();
for (int i = 0; i < k.length; i++)
act.getProperties().put(k[i].getKey(), k[i].getValue());
act.setCentrePoint(getCentrePoint());
act.setOutlinePoints(getOutlinePoints());
act.setInEdgeIds(getInEdgeIds());
act.setOutEdgeIds(getOutEdgeIds());
act.setName(getActName());
act.setID(getID());
}
public String getActName()
{
return (String) getProperties().get("Name");
}
public String getActVersion()
{
return (String) getProperties().get("Version");
}
public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException {
Activity newActivity = (Activity)getTheActivityDef().instantiate();
configureInstance(newActivity);
return newActivity;
}
}
|