1
2
3
4
5
6
7
8
9 package bexee.model.process.impl;
10
11 import bexee.core.ProcessController;
12 import bexee.core.ProcessInstance;
13 import bexee.model.BPELElementVisitor;
14 import bexee.model.InvalidValueException;
15 import bexee.model.activity.Activity;
16 import bexee.model.activity.CompensationHandler;
17 import bexee.model.elements.CorrelationSets;
18 import bexee.model.elements.EventHandlers;
19 import bexee.model.elements.FaultHandlers;
20 import bexee.model.elements.PartnerLinks;
21 import bexee.model.elements.Partners;
22 import bexee.model.elements.Variables;
23 import bexee.model.process.Process;
24 import bexee.util.BooleanUtils;
25 import bexee.util.StringUtils;
26
27 /***
28 * A default implementation of a <code>Process</code>.
29 *
30 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:18 $
31 * @author Patric Fornasier
32 * @author Pawel Kowalski
33 */
34 public class ProcessImpl implements Process {
35
36 private String name;
37
38 private String targetNamespace;
39
40 private String queryLanguage;
41
42 private String expressionLanguage;
43
44 private boolean isSuppressJoinFailure;
45
46 private boolean isInstanceCompensable;
47
48 private boolean isAbstractProcess;
49
50 private PartnerLinks partnerLinks;
51
52 private Partners partners;
53
54 private Variables variables;
55
56 private CorrelationSets correlationSets;
57
58 private FaultHandlers faultHandlers;
59
60 private CompensationHandler compensationHandler;
61
62 private EventHandlers eventHandlers;
63
64 private Activity activity;
65
66 //***************************************************/
67
68 //***************************************************/
69
70 public ProcessImpl() {
71 this(null, null, null, null, null, null);
72 }
73
74 /***
75 * @param name2
76 * @param targetNamespace2
77 * @param queryLanguage2
78 * @param expressionLanguage2
79 * @param suppressJoinFailure2
80 * @param enableInstanceCompensation
81 */
82 public ProcessImpl(String name, String targetNamespace,
83 String queryLanguage, String expressionLanguage,
84 String suppressJoinFailure, String enableInstanceCompensation) {
85
86 this.name = name;
87 this.targetNamespace = targetNamespace;
88 this.queryLanguage = getValidValueOrDefault(queryLanguage,
89 DEFAULT_QUERY_LANGUAGE);
90 this.expressionLanguage = getValidValueOrDefault(expressionLanguage,
91 DEFAULT_EXPRESSION_LANGUAGE);
92 this.isSuppressJoinFailure = getValidValueOrDefault(
93 suppressJoinFailure, DEFAULT_SUPPRESS_JOIN_FAILURE);
94 this.isInstanceCompensable = getValidValueOrDefault(
95 enableInstanceCompensation,
96 DEFAULT_ENABLE_INSTANCE_COMPENSATION);
97 }
98
99 //***************************************************/
100
101 //***************************************************/
102
103 public void setName(String name) {
104 this.name = name;
105 }
106
107 public String getName() {
108 return name;
109 }
110
111 public void setTargetNamespace(String targetNamespace) {
112 this.targetNamespace = targetNamespace;
113 }
114
115 public String getTargetNamespace() {
116 return targetNamespace;
117 }
118
119 public void setQueryLanguage(String queryLanguage) {
120 this.queryLanguage = queryLanguage;
121 }
122
123 public String getQueryLanguage() {
124 return queryLanguage;
125 }
126
127 public void setExpressionLanguage(String expressionLanguage) {
128 this.expressionLanguage = expressionLanguage;
129 }
130
131 public String getExpressionLanguage() {
132 return expressionLanguage;
133 }
134
135 public void setSuppressJoinFailure(boolean suppressJoinFailure) {
136 this.isSuppressJoinFailure = suppressJoinFailure;
137 }
138
139 public boolean isSuppressJoinFailure() {
140 return isSuppressJoinFailure;
141 }
142
143 public void setEnableInstanceCompensation(boolean isInstanceCompensable) {
144 this.isInstanceCompensable = isInstanceCompensable;
145 }
146
147 public boolean isInstanceCompensable() {
148 return isInstanceCompensable;
149 }
150
151 public void setAbstractProcess(boolean isAbstractProcess) {
152 this.isAbstractProcess = isAbstractProcess;
153 }
154
155 public boolean isAbstractProcess() {
156 return isAbstractProcess;
157 }
158
159 public void setPartnerLinks(PartnerLinks partnerLinks) {
160 this.partnerLinks = partnerLinks;
161 }
162
163 public PartnerLinks getPartnerLinks() {
164 return partnerLinks;
165 }
166
167 public void setPartners(Partners partners) {
168 this.partners = partners;
169 }
170
171 public Partners getPartners() {
172 return partners;
173 }
174
175 public void setVariables(Variables variables) {
176 this.variables = variables;
177 }
178
179 public Variables getVariables() {
180 return variables;
181 }
182
183 public void setCorrelationSets(CorrelationSets correlationSets) {
184 this.correlationSets = correlationSets;
185 }
186
187 public CorrelationSets getCorrelationSets() {
188 return correlationSets;
189 }
190
191 public void setFaultHandlers(FaultHandlers faultHandlers) {
192 this.faultHandlers = faultHandlers;
193 }
194
195 public FaultHandlers getFaultHandlers() {
196 return faultHandlers;
197 }
198
199 public void setCompensationHandler(CompensationHandler compensationHandler) {
200 this.compensationHandler = compensationHandler;
201 }
202
203 public CompensationHandler getCompensationHandler() {
204 return compensationHandler;
205 }
206
207 public void setEventHandlers(EventHandlers eventHandlers) {
208 this.eventHandlers = eventHandlers;
209 }
210
211 public EventHandlers getEventHandlers() {
212 return eventHandlers;
213 }
214
215 public void activity(Activity activity) {
216 setActivity(activity);
217 }
218
219 public void setActivity(Activity activity) {
220 this.activity = activity;
221 }
222
223 public Activity getActivity() {
224 return activity;
225 }
226
227 //***************************************************/
228
229 //***************************************************/
230
231 public void accept(ProcessController controller, ProcessInstance instance)
232 throws Exception {
233 controller.process(this, instance);
234 }
235
236 public void accept(BPELElementVisitor elementVisitor) {
237 elementVisitor.visit(this);
238 }
239
240 //***************************************************/
241
242 //***************************************************/
243
244 private String getValidValueOrDefault(String value, String defaultValue) {
245 if (StringUtils.isNullOrEmpty(value)) {
246 return defaultValue;
247 } else {
248 return value;
249 }
250 }
251
252 private boolean getValidValueOrDefault(String value, boolean defaultValue) {
253 try {
254 return BooleanUtils.strictYesNoToBoolean(value);
255 } catch (InvalidValueException e) {
256 return defaultValue;
257 }
258 }
259
260 }