1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.usagemodel.impl; |
7 | |
8 | import java.util.Map; |
9 | |
10 | import org.eclipse.emf.common.notify.Notification; |
11 | import org.eclipse.emf.common.notify.NotificationChain; |
12 | import org.eclipse.emf.common.util.BasicDiagnostic; |
13 | import org.eclipse.emf.common.util.Diagnostic; |
14 | import org.eclipse.emf.common.util.DiagnosticChain; |
15 | import org.eclipse.emf.ecore.EClass; |
16 | import org.eclipse.emf.ecore.InternalEObject; |
17 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
18 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
19 | import org.eclipse.emf.ecore.util.EObjectValidator; |
20 | import org.eclipse.ocl.ParserException; |
21 | import org.eclipse.ocl.ecore.Constraint; |
22 | import org.eclipse.ocl.ecore.OCL; |
23 | |
24 | import de.uka.ipd.sdq.pcm.core.CorePackage; |
25 | import de.uka.ipd.sdq.pcm.core.PCMRandomVariable; |
26 | import de.uka.ipd.sdq.pcm.usagemodel.ClosedWorkload; |
27 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
28 | import de.uka.ipd.sdq.pcm.usagemodel.util.UsagemodelValidator; |
29 | |
30 | /** |
31 | * <!-- begin-user-doc --> |
32 | * An implementation of the model object '<em><b>Closed Workload</b></em>'. |
33 | * <!-- end-user-doc --> |
34 | * <p> |
35 | * The following features are implemented: |
36 | * <ul> |
37 | * <li>{@link de.uka.ipd.sdq.pcm.usagemodel.impl.ClosedWorkloadImpl#getPopulation <em>Population</em>}</li> |
38 | * <li>{@link de.uka.ipd.sdq.pcm.usagemodel.impl.ClosedWorkloadImpl#getThinkTime_ClosedWorkload <em>Think Time Closed Workload</em>}</li> |
39 | * </ul> |
40 | * </p> |
41 | * |
42 | * @generated |
43 | */ |
44 | public class ClosedWorkloadImpl extends WorkloadImpl implements ClosedWorkload { |
45 | /** |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @generated |
49 | */ |
50 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
51 | |
52 | /** |
53 | * The default value of the '{@link #getPopulation() <em>Population</em>}' attribute. |
54 | * <!-- begin-user-doc --> |
55 | * <!-- end-user-doc --> |
56 | * @see #getPopulation() |
57 | * @generated |
58 | * @ordered |
59 | */ |
60 | protected static final int POPULATION_EDEFAULT = 0; |
61 | |
62 | /** |
63 | * The cached value of the '{@link #getPopulation() <em>Population</em>}' attribute. |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @see #getPopulation() |
67 | * @generated |
68 | * @ordered |
69 | */ |
70 | protected int population = POPULATION_EDEFAULT; |
71 | |
72 | /** |
73 | * The cached value of the '{@link #getThinkTime_ClosedWorkload() <em>Think Time Closed Workload</em>}' containment reference. |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @see #getThinkTime_ClosedWorkload() |
77 | * @generated |
78 | * @ordered |
79 | */ |
80 | protected PCMRandomVariable thinkTime_ClosedWorkload; |
81 | |
82 | /** |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | protected ClosedWorkloadImpl() { |
88 | super(); |
89 | } |
90 | |
91 | /** |
92 | * <!-- begin-user-doc --> |
93 | * <!-- end-user-doc --> |
94 | * @generated |
95 | */ |
96 | @Override |
97 | protected EClass eStaticClass() { |
98 | return UsagemodelPackage.Literals.CLOSED_WORKLOAD; |
99 | } |
100 | |
101 | /** |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | public int getPopulation() { |
107 | return population; |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | public void setPopulation(int newPopulation) { |
116 | int oldPopulation = population; |
117 | population = newPopulation; |
118 | if (eNotificationRequired()) |
119 | eNotify(new ENotificationImpl(this, Notification.SET, UsagemodelPackage.CLOSED_WORKLOAD__POPULATION, oldPopulation, population)); |
120 | } |
121 | |
122 | /** |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | public PCMRandomVariable getThinkTime_ClosedWorkload() { |
128 | return thinkTime_ClosedWorkload; |
129 | } |
130 | |
131 | /** |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | public NotificationChain basicSetThinkTime_ClosedWorkload(PCMRandomVariable newThinkTime_ClosedWorkload, NotificationChain msgs) { |
137 | PCMRandomVariable oldThinkTime_ClosedWorkload = thinkTime_ClosedWorkload; |
138 | thinkTime_ClosedWorkload = newThinkTime_ClosedWorkload; |
139 | if (eNotificationRequired()) { |
140 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD, oldThinkTime_ClosedWorkload, newThinkTime_ClosedWorkload); |
141 | if (msgs == null) msgs = notification; else msgs.add(notification); |
142 | } |
143 | return msgs; |
144 | } |
145 | |
146 | /** |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | public void setThinkTime_ClosedWorkload(PCMRandomVariable newThinkTime_ClosedWorkload) { |
152 | if (newThinkTime_ClosedWorkload != thinkTime_ClosedWorkload) { |
153 | NotificationChain msgs = null; |
154 | if (thinkTime_ClosedWorkload != null) |
155 | msgs = ((InternalEObject)thinkTime_ClosedWorkload).eInverseRemove(this, CorePackage.PCM_RANDOM_VARIABLE__CLOSED_WORKLOAD_PCM_RANDOM_VARIABLE, PCMRandomVariable.class, msgs); |
156 | if (newThinkTime_ClosedWorkload != null) |
157 | msgs = ((InternalEObject)newThinkTime_ClosedWorkload).eInverseAdd(this, CorePackage.PCM_RANDOM_VARIABLE__CLOSED_WORKLOAD_PCM_RANDOM_VARIABLE, PCMRandomVariable.class, msgs); |
158 | msgs = basicSetThinkTime_ClosedWorkload(newThinkTime_ClosedWorkload, msgs); |
159 | if (msgs != null) msgs.dispatch(); |
160 | } |
161 | else if (eNotificationRequired()) |
162 | eNotify(new ENotificationImpl(this, Notification.SET, UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD, newThinkTime_ClosedWorkload, newThinkTime_ClosedWorkload)); |
163 | } |
164 | |
165 | /** |
166 | * The cached OCL expression body for the '{@link #PopulationInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Population In Closed Workload Needs To Be Specified</em>}' operation. |
167 | * <!-- begin-user-doc --> |
168 | * <!-- end-user-doc --> |
169 | * @see #PopulationInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
170 | * @generated |
171 | * @ordered |
172 | */ |
173 | protected static final String POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "not self.population.oclIsUndefined() and self.population <> ''"; |
174 | |
175 | /** |
176 | * The cached OCL invariant for the '{@link #PopulationInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Population In Closed Workload Needs To Be Specified</em>}' invariant operation. |
177 | * <!-- begin-user-doc --> |
178 | * <!-- end-user-doc --> |
179 | * @see #PopulationInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
180 | * @generated |
181 | * @ordered |
182 | */ |
183 | protected static Constraint POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
184 | |
185 | /** |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | public boolean PopulationInClosedWorkloadNeedsToBeSpecified(DiagnosticChain diagnostics, Map<Object, Object> context) { |
191 | if (POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
192 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
193 | helper.setContext(UsagemodelPackage.Literals.CLOSED_WORKLOAD); |
194 | try { |
195 | POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
196 | } |
197 | catch (ParserException pe) { |
198 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
199 | } |
200 | } |
201 | if (!EOCL_ENV.createQuery(POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
202 | if (diagnostics != null) { |
203 | diagnostics.add |
204 | (new BasicDiagnostic |
205 | (Diagnostic.ERROR, |
206 | UsagemodelValidator.DIAGNOSTIC_SOURCE, |
207 | UsagemodelValidator.CLOSED_WORKLOAD__POPULATION_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED, |
208 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "PopulationInClosedWorkloadNeedsToBeSpecified", EObjectValidator.getObjectLabel(this, context) }), |
209 | new Object [] { this })); |
210 | } |
211 | return false; |
212 | } |
213 | return true; |
214 | } |
215 | |
216 | /** |
217 | * The cached OCL expression body for the '{@link #ThinkTimeInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Think Time In Closed Workload Needs To Be Specified</em>}' operation. |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @see #ThinkTimeInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
221 | * @generated |
222 | * @ordered |
223 | */ |
224 | protected static final String THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "not self.thinkTime_ClosedWorkload.oclIsUndefined() and self.thinkTime_ClosedWorkload.specification <> ''"; |
225 | |
226 | /** |
227 | * The cached OCL invariant for the '{@link #ThinkTimeInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Think Time In Closed Workload Needs To Be Specified</em>}' invariant operation. |
228 | * <!-- begin-user-doc --> |
229 | * <!-- end-user-doc --> |
230 | * @see #ThinkTimeInClosedWorkloadNeedsToBeSpecified(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
231 | * @generated |
232 | * @ordered |
233 | */ |
234 | protected static Constraint THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
235 | |
236 | /** |
237 | * <!-- begin-user-doc --> |
238 | * <!-- end-user-doc --> |
239 | * @generated |
240 | */ |
241 | public boolean ThinkTimeInClosedWorkloadNeedsToBeSpecified(DiagnosticChain diagnostics, Map<Object, Object> context) { |
242 | if (THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
243 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
244 | helper.setContext(UsagemodelPackage.Literals.CLOSED_WORKLOAD); |
245 | try { |
246 | THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
247 | } |
248 | catch (ParserException pe) { |
249 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
250 | } |
251 | } |
252 | if (!EOCL_ENV.createQuery(THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
253 | if (diagnostics != null) { |
254 | diagnostics.add |
255 | (new BasicDiagnostic |
256 | (Diagnostic.ERROR, |
257 | UsagemodelValidator.DIAGNOSTIC_SOURCE, |
258 | UsagemodelValidator.CLOSED_WORKLOAD__THINK_TIME_IN_CLOSED_WORKLOAD_NEEDS_TO_BE_SPECIFIED, |
259 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ThinkTimeInClosedWorkloadNeedsToBeSpecified", EObjectValidator.getObjectLabel(this, context) }), |
260 | new Object [] { this })); |
261 | } |
262 | return false; |
263 | } |
264 | return true; |
265 | } |
266 | |
267 | /** |
268 | * <!-- begin-user-doc --> |
269 | * <!-- end-user-doc --> |
270 | * @generated |
271 | */ |
272 | @Override |
273 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
274 | switch (featureID) { |
275 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
276 | if (thinkTime_ClosedWorkload != null) |
277 | msgs = ((InternalEObject)thinkTime_ClosedWorkload).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD, null, msgs); |
278 | return basicSetThinkTime_ClosedWorkload((PCMRandomVariable)otherEnd, msgs); |
279 | } |
280 | return super.eInverseAdd(otherEnd, featureID, msgs); |
281 | } |
282 | |
283 | /** |
284 | * <!-- begin-user-doc --> |
285 | * <!-- end-user-doc --> |
286 | * @generated |
287 | */ |
288 | @Override |
289 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
290 | switch (featureID) { |
291 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
292 | return basicSetThinkTime_ClosedWorkload(null, msgs); |
293 | } |
294 | return super.eInverseRemove(otherEnd, featureID, msgs); |
295 | } |
296 | |
297 | /** |
298 | * <!-- begin-user-doc --> |
299 | * <!-- end-user-doc --> |
300 | * @generated |
301 | */ |
302 | @Override |
303 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
304 | switch (featureID) { |
305 | case UsagemodelPackage.CLOSED_WORKLOAD__POPULATION: |
306 | return getPopulation(); |
307 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
308 | return getThinkTime_ClosedWorkload(); |
309 | } |
310 | return super.eGet(featureID, resolve, coreType); |
311 | } |
312 | |
313 | /** |
314 | * <!-- begin-user-doc --> |
315 | * <!-- end-user-doc --> |
316 | * @generated |
317 | */ |
318 | @Override |
319 | public void eSet(int featureID, Object newValue) { |
320 | switch (featureID) { |
321 | case UsagemodelPackage.CLOSED_WORKLOAD__POPULATION: |
322 | setPopulation((Integer)newValue); |
323 | return; |
324 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
325 | setThinkTime_ClosedWorkload((PCMRandomVariable)newValue); |
326 | return; |
327 | } |
328 | super.eSet(featureID, newValue); |
329 | } |
330 | |
331 | /** |
332 | * <!-- begin-user-doc --> |
333 | * <!-- end-user-doc --> |
334 | * @generated |
335 | */ |
336 | @Override |
337 | public void eUnset(int featureID) { |
338 | switch (featureID) { |
339 | case UsagemodelPackage.CLOSED_WORKLOAD__POPULATION: |
340 | setPopulation(POPULATION_EDEFAULT); |
341 | return; |
342 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
343 | setThinkTime_ClosedWorkload((PCMRandomVariable)null); |
344 | return; |
345 | } |
346 | super.eUnset(featureID); |
347 | } |
348 | |
349 | /** |
350 | * <!-- begin-user-doc --> |
351 | * <!-- end-user-doc --> |
352 | * @generated |
353 | */ |
354 | @Override |
355 | public boolean eIsSet(int featureID) { |
356 | switch (featureID) { |
357 | case UsagemodelPackage.CLOSED_WORKLOAD__POPULATION: |
358 | return population != POPULATION_EDEFAULT; |
359 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
360 | return thinkTime_ClosedWorkload != null; |
361 | } |
362 | return super.eIsSet(featureID); |
363 | } |
364 | |
365 | /** |
366 | * <!-- begin-user-doc --> |
367 | * <!-- end-user-doc --> |
368 | * @generated |
369 | */ |
370 | @Override |
371 | public String toString() { |
372 | if (eIsProxy()) return super.toString(); |
373 | |
374 | StringBuffer result = new StringBuffer(super.toString()); |
375 | result.append(" (population: "); |
376 | result.append(population); |
377 | result.append(')'); |
378 | return result.toString(); |
379 | } |
380 | |
381 | /** |
382 | * The cached environment for evaluating OCL expressions. |
383 | * <!-- begin-user-doc --> |
384 | * <!-- end-user-doc --> |
385 | * @generated |
386 | * @ordered |
387 | */ |
388 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
389 | |
390 | } //ClosedWorkloadImpl |