1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.seff.impl; |
7 | |
8 | import java.util.Map; |
9 | |
10 | import org.eclipse.emf.common.notify.Notification; |
11 | import org.eclipse.emf.common.util.BasicDiagnostic; |
12 | import org.eclipse.emf.common.util.Diagnostic; |
13 | import org.eclipse.emf.common.util.DiagnosticChain; |
14 | import org.eclipse.emf.ecore.EClass; |
15 | import org.eclipse.emf.ecore.InternalEObject; |
16 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
17 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
18 | import org.eclipse.emf.ecore.util.EObjectValidator; |
19 | import org.eclipse.ocl.ParserException; |
20 | import org.eclipse.ocl.ecore.Constraint; |
21 | import org.eclipse.ocl.ecore.OCL; |
22 | |
23 | import de.uka.ipd.sdq.pcm.repository.PassiveResource; |
24 | import de.uka.ipd.sdq.pcm.seff.AcquireAction; |
25 | import de.uka.ipd.sdq.pcm.seff.SeffPackage; |
26 | import de.uka.ipd.sdq.pcm.seff.util.SeffValidator; |
27 | |
28 | /** |
29 | * <!-- begin-user-doc --> |
30 | * An implementation of the model object '<em><b>Acquire Action</b></em>'. |
31 | * <!-- end-user-doc --> |
32 | * <p> |
33 | * The following features are implemented: |
34 | * <ul> |
35 | * <li>{@link de.uka.ipd.sdq.pcm.seff.impl.AcquireActionImpl#getPassiveresource_AcquireAction <em>Passiveresource Acquire Action</em>}</li> |
36 | * <li>{@link de.uka.ipd.sdq.pcm.seff.impl.AcquireActionImpl#isTimeout <em>Timeout</em>}</li> |
37 | * <li>{@link de.uka.ipd.sdq.pcm.seff.impl.AcquireActionImpl#getTimeoutValue <em>Timeout Value</em>}</li> |
38 | * </ul> |
39 | * </p> |
40 | * |
41 | * @generated |
42 | */ |
43 | public class AcquireActionImpl extends AbstractInternalControlFlowActionImpl implements AcquireAction { |
44 | /** |
45 | * <!-- begin-user-doc --> |
46 | * <!-- end-user-doc --> |
47 | * @generated |
48 | */ |
49 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
50 | |
51 | /** |
52 | * The cached value of the '{@link #getPassiveresource_AcquireAction() <em>Passiveresource Acquire Action</em>}' reference. |
53 | * <!-- begin-user-doc --> |
54 | * <!-- end-user-doc --> |
55 | * @see #getPassiveresource_AcquireAction() |
56 | * @generated |
57 | * @ordered |
58 | */ |
59 | protected PassiveResource passiveresource_AcquireAction; |
60 | |
61 | /** |
62 | * The default value of the '{@link #isTimeout() <em>Timeout</em>}' attribute. |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @see #isTimeout() |
66 | * @generated |
67 | * @ordered |
68 | */ |
69 | protected static final boolean TIMEOUT_EDEFAULT = false; |
70 | |
71 | /** |
72 | * The cached value of the '{@link #isTimeout() <em>Timeout</em>}' attribute. |
73 | * <!-- begin-user-doc --> |
74 | * <!-- end-user-doc --> |
75 | * @see #isTimeout() |
76 | * @generated |
77 | * @ordered |
78 | */ |
79 | protected boolean timeout = TIMEOUT_EDEFAULT; |
80 | |
81 | /** |
82 | * The default value of the '{@link #getTimeoutValue() <em>Timeout Value</em>}' attribute. |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @see #getTimeoutValue() |
86 | * @generated |
87 | * @ordered |
88 | */ |
89 | protected static final double TIMEOUT_VALUE_EDEFAULT = 0.0; |
90 | |
91 | /** |
92 | * The cached value of the '{@link #getTimeoutValue() <em>Timeout Value</em>}' attribute. |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @see #getTimeoutValue() |
96 | * @generated |
97 | * @ordered |
98 | */ |
99 | protected double timeoutValue = TIMEOUT_VALUE_EDEFAULT; |
100 | |
101 | /** |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | protected AcquireActionImpl() { |
107 | super(); |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | @Override |
116 | protected EClass eStaticClass() { |
117 | return SeffPackage.Literals.ACQUIRE_ACTION; |
118 | } |
119 | |
120 | /** |
121 | * <!-- begin-user-doc --> |
122 | * <!-- end-user-doc --> |
123 | * @generated |
124 | */ |
125 | public PassiveResource getPassiveresource_AcquireAction() { |
126 | if (passiveresource_AcquireAction != null && passiveresource_AcquireAction.eIsProxy()) { |
127 | InternalEObject oldPassiveresource_AcquireAction = (InternalEObject)passiveresource_AcquireAction; |
128 | passiveresource_AcquireAction = (PassiveResource)eResolveProxy(oldPassiveresource_AcquireAction); |
129 | if (passiveresource_AcquireAction != oldPassiveresource_AcquireAction) { |
130 | if (eNotificationRequired()) |
131 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION, oldPassiveresource_AcquireAction, passiveresource_AcquireAction)); |
132 | } |
133 | } |
134 | return passiveresource_AcquireAction; |
135 | } |
136 | |
137 | /** |
138 | * <!-- begin-user-doc --> |
139 | * <!-- end-user-doc --> |
140 | * @generated |
141 | */ |
142 | public PassiveResource basicGetPassiveresource_AcquireAction() { |
143 | return passiveresource_AcquireAction; |
144 | } |
145 | |
146 | /** |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | public void setPassiveresource_AcquireAction(PassiveResource newPassiveresource_AcquireAction) { |
152 | PassiveResource oldPassiveresource_AcquireAction = passiveresource_AcquireAction; |
153 | passiveresource_AcquireAction = newPassiveresource_AcquireAction; |
154 | if (eNotificationRequired()) |
155 | eNotify(new ENotificationImpl(this, Notification.SET, SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION, oldPassiveresource_AcquireAction, passiveresource_AcquireAction)); |
156 | } |
157 | |
158 | /** |
159 | * <!-- begin-user-doc --> |
160 | * <!-- end-user-doc --> |
161 | * @generated |
162 | */ |
163 | public boolean isTimeout() { |
164 | return timeout; |
165 | } |
166 | |
167 | /** |
168 | * <!-- begin-user-doc --> |
169 | * <!-- end-user-doc --> |
170 | * @generated |
171 | */ |
172 | public void setTimeout(boolean newTimeout) { |
173 | boolean oldTimeout = timeout; |
174 | timeout = newTimeout; |
175 | if (eNotificationRequired()) |
176 | eNotify(new ENotificationImpl(this, Notification.SET, SeffPackage.ACQUIRE_ACTION__TIMEOUT, oldTimeout, timeout)); |
177 | } |
178 | |
179 | /** |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | public double getTimeoutValue() { |
185 | return timeoutValue; |
186 | } |
187 | |
188 | /** |
189 | * <!-- begin-user-doc --> |
190 | * <!-- end-user-doc --> |
191 | * @generated |
192 | */ |
193 | public void setTimeoutValue(double newTimeoutValue) { |
194 | double oldTimeoutValue = timeoutValue; |
195 | timeoutValue = newTimeoutValue; |
196 | if (eNotificationRequired()) |
197 | eNotify(new ENotificationImpl(this, Notification.SET, SeffPackage.ACQUIRE_ACTION__TIMEOUT_VALUE, oldTimeoutValue, timeoutValue)); |
198 | } |
199 | |
200 | /** |
201 | * The cached OCL expression body for the '{@link #TimeoutValueOfAcquireActionMustNotBeNegative(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Timeout Value Of Acquire Action Must Not Be Negative</em>}' operation. |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @see #TimeoutValueOfAcquireActionMustNotBeNegative(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
205 | * @generated |
206 | * @ordered |
207 | */ |
208 | protected static final String TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.timeoutValue.oclAsType(Real) >= 0.0"; |
209 | |
210 | /** |
211 | * The cached OCL invariant for the '{@link #TimeoutValueOfAcquireActionMustNotBeNegative(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Timeout Value Of Acquire Action Must Not Be Negative</em>}' invariant operation. |
212 | * <!-- begin-user-doc --> |
213 | * <!-- end-user-doc --> |
214 | * @see #TimeoutValueOfAcquireActionMustNotBeNegative(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
215 | * @generated |
216 | * @ordered |
217 | */ |
218 | protected static Constraint TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | public boolean TimeoutValueOfAcquireActionMustNotBeNegative(DiagnosticChain diagnostics, Map<Object, Object> context) { |
226 | if (TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
227 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
228 | helper.setContext(SeffPackage.Literals.ACQUIRE_ACTION); |
229 | try { |
230 | TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
231 | } |
232 | catch (ParserException pe) { |
233 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
234 | } |
235 | } |
236 | if (!EOCL_ENV.createQuery(TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
237 | if (diagnostics != null) { |
238 | diagnostics.add |
239 | (new BasicDiagnostic |
240 | (Diagnostic.ERROR, |
241 | SeffValidator.DIAGNOSTIC_SOURCE, |
242 | SeffValidator.ACQUIRE_ACTION__TIMEOUT_VALUE_OF_ACQUIRE_ACTION_MUST_NOT_BE_NEGATIVE, |
243 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "TimeoutValueOfAcquireActionMustNotBeNegative", EObjectValidator.getObjectLabel(this, context) }), |
244 | new Object [] { this })); |
245 | } |
246 | return false; |
247 | } |
248 | return true; |
249 | } |
250 | |
251 | /** |
252 | * <!-- begin-user-doc --> |
253 | * <!-- end-user-doc --> |
254 | * @generated |
255 | */ |
256 | @Override |
257 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
258 | switch (featureID) { |
259 | case SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION: |
260 | if (resolve) return getPassiveresource_AcquireAction(); |
261 | return basicGetPassiveresource_AcquireAction(); |
262 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT: |
263 | return isTimeout(); |
264 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT_VALUE: |
265 | return getTimeoutValue(); |
266 | } |
267 | return super.eGet(featureID, resolve, coreType); |
268 | } |
269 | |
270 | /** |
271 | * <!-- begin-user-doc --> |
272 | * <!-- end-user-doc --> |
273 | * @generated |
274 | */ |
275 | @Override |
276 | public void eSet(int featureID, Object newValue) { |
277 | switch (featureID) { |
278 | case SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION: |
279 | setPassiveresource_AcquireAction((PassiveResource)newValue); |
280 | return; |
281 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT: |
282 | setTimeout((Boolean)newValue); |
283 | return; |
284 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT_VALUE: |
285 | setTimeoutValue((Double)newValue); |
286 | return; |
287 | } |
288 | super.eSet(featureID, newValue); |
289 | } |
290 | |
291 | /** |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | @Override |
297 | public void eUnset(int featureID) { |
298 | switch (featureID) { |
299 | case SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION: |
300 | setPassiveresource_AcquireAction((PassiveResource)null); |
301 | return; |
302 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT: |
303 | setTimeout(TIMEOUT_EDEFAULT); |
304 | return; |
305 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT_VALUE: |
306 | setTimeoutValue(TIMEOUT_VALUE_EDEFAULT); |
307 | return; |
308 | } |
309 | super.eUnset(featureID); |
310 | } |
311 | |
312 | /** |
313 | * <!-- begin-user-doc --> |
314 | * <!-- end-user-doc --> |
315 | * @generated |
316 | */ |
317 | @Override |
318 | public boolean eIsSet(int featureID) { |
319 | switch (featureID) { |
320 | case SeffPackage.ACQUIRE_ACTION__PASSIVERESOURCE_ACQUIRE_ACTION: |
321 | return passiveresource_AcquireAction != null; |
322 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT: |
323 | return timeout != TIMEOUT_EDEFAULT; |
324 | case SeffPackage.ACQUIRE_ACTION__TIMEOUT_VALUE: |
325 | return timeoutValue != TIMEOUT_VALUE_EDEFAULT; |
326 | } |
327 | return super.eIsSet(featureID); |
328 | } |
329 | |
330 | /** |
331 | * <!-- begin-user-doc --> |
332 | * <!-- end-user-doc --> |
333 | * @generated |
334 | */ |
335 | @Override |
336 | public String toString() { |
337 | if (eIsProxy()) return super.toString(); |
338 | |
339 | StringBuffer result = new StringBuffer(super.toString()); |
340 | result.append(" (timeout: "); |
341 | result.append(timeout); |
342 | result.append(", timeoutValue: "); |
343 | result.append(timeoutValue); |
344 | result.append(')'); |
345 | return result.toString(); |
346 | } |
347 | |
348 | /** |
349 | * The cached environment for evaluating OCL expressions. |
350 | * <!-- begin-user-doc --> |
351 | * <!-- end-user-doc --> |
352 | * @generated |
353 | * @ordered |
354 | */ |
355 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
356 | |
357 | } //AcquireActionImpl |