1 package org.andromda.cartridges.jbpm.metafacades;
2
3 import org.andromda.cartridges.jbpm.JBpmProfile;
4 import org.andromda.metafacades.uml.ActivityGraphFacade;
5 import org.andromda.metafacades.uml.ModelElementFacade;
6 import org.andromda.metafacades.uml.OperationFacade;
7 import org.andromda.metafacades.uml.StateMachineFacade;
8 import org.apache.commons.lang.StringUtils;
9
10
11
12
13
14
15 public class JBpmActionLogicImpl
16 extends JBpmActionLogic
17 {
18 private static final long serialVersionUID = 34L;
19
20
21
22
23 public JBpmActionLogicImpl(Object metaObject, String context)
24 {
25 super(metaObject, context);
26 }
27
28
29
30
31 protected boolean handleIsContainedInBusinessProcess()
32 {
33 boolean containedInBusinessProcess = false;
34 if (this.getState() != null)
35 {
36 final StateMachineFacade stateMachine = this.getState().getStateMachine();
37 if (stateMachine instanceof ActivityGraphFacade)
38 {
39 final ActivityGraphFacade activityGraph = (ActivityGraphFacade)stateMachine;
40 containedInBusinessProcess = activityGraph.getUseCase() instanceof JBpmProcessDefinition;
41 }
42 }
43 else
44 {
45 containedInBusinessProcess = this.getTransition() instanceof JBpmTransition;
46 }
47 return containedInBusinessProcess;
48 }
49
50
51
52
53
54
55 @Override
56 public String getName()
57 {
58 String name = super.getName();
59
60 if (StringUtils.isBlank(name))
61 {
62 final ModelElementFacade operation = getOperation();
63 if (operation != null)
64 {
65 name = operation.getName();
66 }
67 }
68
69 return name;
70 }
71
72
73
74
75
76 protected boolean handleIsBeforeSignal()
77 {
78 return this.hasStereotype(JBpmProfile.STEREOTYPE_BEFORE_SIGNAL);
79 }
80
81
82
83
84
85 protected boolean handleIsAfterSignal()
86 {
87 return this.hasStereotype(JBpmProfile.STEREOTYPE_AFTER_SIGNAL);
88 }
89
90
91
92
93
94 protected boolean handleIsNodeEnter()
95 {
96 return this.hasStereotype(JBpmProfile.STEREOTYPE_NODE_ENTER);
97 }
98
99
100
101
102
103 protected boolean handleIsNodeLeave()
104 {
105 return this.hasStereotype(JBpmProfile.STEREOTYPE_NODE_LEAVE);
106 }
107
108
109
110
111
112 protected boolean handleIsTask()
113 {
114
115 return this.hasStereotype(JBpmProfile.STEREOTYPE_TASK) && this.getState() instanceof JBpmNode;
116 }
117
118
119
120
121
122 protected boolean handleIsTimer()
123 {
124 return this.hasStereotype(JBpmProfile.STEREOTYPE_TIMER);
125 }
126
127
128
129
130
131 protected boolean handleIsBlocking()
132 {
133 final String blocking = (String)this.findTaggedValue(JBpmProfile.TAGGEDVALUE_TASK_BLOCKING);
134 return blocking == null || Boolean.valueOf(blocking).booleanValue();
135 }
136
137
138
139
140
141 protected String handleGetDueDate()
142 {
143 return isTimer() ? (String)findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_DUEDATE) : null;
144 }
145
146
147
148
149 protected String handleGetTimerRepeat()
150 {
151 return (String)findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_REPEAT);
152 }
153
154
155
156
157 protected String handleGetTimerTransition()
158 {
159 return (String)findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_TRANSITION);
160 }
161
162
163
164
165
166 protected String handleGetClazz()
167 {
168 String clazz = null;
169 if (this.isAssignment() || this.isTimer())
170 {
171 final OperationFacade handler = this.getOperation();
172
173 if (handler instanceof JBpmHandler)
174 {
175 final StringBuilder clazzBuffer = new StringBuilder();
176 final String packageName = handler.getOwner().getPackageName();
177 clazzBuffer.append(packageName);
178 if (StringUtils.isNotBlank(packageName))
179 {
180 clazzBuffer.append('.');
181 }
182 clazzBuffer.append(((JBpmHandler)handler).getHandlerClassName());
183 clazz = clazzBuffer.toString();
184 }
185 }
186
187 return clazz;
188 }
189
190
191
192
193
194
195 protected String handleGetConfigType()
196 {
197
198 return null;
199 }
200
201
202
203
204
205 protected boolean handleIsAssignment()
206 {
207 return this.getOperation() != null;
208 }
209 }