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.Collection; |
9 | import java.util.Map; |
10 | |
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.common.util.EList; |
16 | import org.eclipse.emf.ecore.EClass; |
17 | import org.eclipse.emf.ecore.InternalEObject; |
18 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
19 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
20 | import org.eclipse.emf.ecore.util.EObjectValidator; |
21 | import org.eclipse.emf.ecore.util.InternalEList; |
22 | import org.eclipse.ocl.ParserException; |
23 | import org.eclipse.ocl.ecore.Constraint; |
24 | import org.eclipse.ocl.ecore.OCL; |
25 | |
26 | import de.uka.ipd.sdq.pcm.reliability.InternalFailureOccurrenceDescription; |
27 | import de.uka.ipd.sdq.pcm.reliability.ReliabilityPackage; |
28 | import de.uka.ipd.sdq.pcm.seff.InternalAction; |
29 | import de.uka.ipd.sdq.pcm.seff.SeffPackage; |
30 | import de.uka.ipd.sdq.pcm.seff.util.SeffValidator; |
31 | |
32 | /** |
33 | * <!-- begin-user-doc --> |
34 | * An implementation of the model object '<em><b>Internal Action</b></em>'. |
35 | * <!-- end-user-doc --> |
36 | * <p> |
37 | * The following features are implemented: |
38 | * <ul> |
39 | * <li>{@link de.uka.ipd.sdq.pcm.seff.impl.InternalActionImpl#getInternalFailureOccurrenceDescriptions__InternalAction <em>Internal Failure Occurrence Descriptions Internal Action</em>}</li> |
40 | * </ul> |
41 | * </p> |
42 | * |
43 | * @generated |
44 | */ |
45 | public class InternalActionImpl extends AbstractInternalControlFlowActionImpl implements InternalAction { |
46 | /** |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
52 | |
53 | /** |
54 | * The cached value of the '{@link #getInternalFailureOccurrenceDescriptions__InternalAction() <em>Internal Failure Occurrence Descriptions Internal Action</em>}' containment reference list. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @see #getInternalFailureOccurrenceDescriptions__InternalAction() |
58 | * @generated |
59 | * @ordered |
60 | */ |
61 | protected EList<InternalFailureOccurrenceDescription> internalFailureOccurrenceDescriptions__InternalAction; |
62 | |
63 | /** |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @generated |
67 | */ |
68 | protected InternalActionImpl() { |
69 | super(); |
70 | } |
71 | |
72 | /** |
73 | * <!-- begin-user-doc --> |
74 | * <!-- end-user-doc --> |
75 | * @generated |
76 | */ |
77 | @Override |
78 | protected EClass eStaticClass() { |
79 | return SeffPackage.Literals.INTERNAL_ACTION; |
80 | } |
81 | |
82 | /** |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | public EList<InternalFailureOccurrenceDescription> getInternalFailureOccurrenceDescriptions__InternalAction() { |
88 | if (internalFailureOccurrenceDescriptions__InternalAction == null) { |
89 | internalFailureOccurrenceDescriptions__InternalAction = new EObjectContainmentWithInverseEList<InternalFailureOccurrenceDescription>(InternalFailureOccurrenceDescription.class, this, SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION, ReliabilityPackage.INTERNAL_FAILURE_OCCURRENCE_DESCRIPTION__INTERNAL_ACTION_INTERNAL_FAILURE_OCCURRENCE_DESCRIPTION); |
90 | } |
91 | return internalFailureOccurrenceDescriptions__InternalAction; |
92 | } |
93 | |
94 | /** |
95 | * The cached OCL expression body for the '{@link #MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Multiple Internal Occurrence Descriptions Per Failure Type Not Allowed</em>}' operation. |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @see #MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
99 | * @generated |
100 | * @ordered |
101 | */ |
102 | protected static final String MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.internalFailureOccurrenceDescriptions__InternalAction->forAll(x:pcm::reliability::InternalFailureOccurrenceDescription,y:pcm::reliability::InternalFailureOccurrenceDescription | x<>y implies x.softwareInducedFailureType__InternalFailureOccurrenceDescription <> y.softwareInducedFailureType__InternalFailureOccurrenceDescription )\n"+""; |
103 | |
104 | /** |
105 | * The cached OCL invariant for the '{@link #MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Multiple Internal Occurrence Descriptions Per Failure Type Not Allowed</em>}' invariant operation. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @see #MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
109 | * @generated |
110 | * @ordered |
111 | */ |
112 | protected static Constraint MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | public boolean MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed(DiagnosticChain diagnostics, Map<Object, Object> context) { |
120 | if (MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
121 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
122 | helper.setContext(SeffPackage.Literals.INTERNAL_ACTION); |
123 | try { |
124 | MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
125 | } |
126 | catch (ParserException pe) { |
127 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
128 | } |
129 | } |
130 | if (!EOCL_ENV.createQuery(MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
131 | if (diagnostics != null) { |
132 | diagnostics.add |
133 | (new BasicDiagnostic |
134 | (Diagnostic.ERROR, |
135 | SeffValidator.DIAGNOSTIC_SOURCE, |
136 | SeffValidator.INTERNAL_ACTION__MULTIPLE_INTERNAL_OCCURRENCE_DESCRIPTIONS_PER_FAILURE_TYPE_NOT_ALLOWED, |
137 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "MultipleInternalOccurrenceDescriptionsPerFailureTypeNotAllowed", EObjectValidator.getObjectLabel(this, context) }), |
138 | new Object [] { this })); |
139 | } |
140 | return false; |
141 | } |
142 | return true; |
143 | } |
144 | |
145 | /** |
146 | * The cached OCL expression body for the '{@link #SumOfInternalActionFailureProbabilitiesMustNotExceed1(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Sum Of Internal Action Failure Probabilities Must Not Exceed1</em>}' operation. |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @see #SumOfInternalActionFailureProbabilitiesMustNotExceed1(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
150 | * @generated |
151 | * @ordered |
152 | */ |
153 | protected static final String SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.internalFailureOccurrenceDescriptions__InternalAction.failureProbability.oclAsType(Real)->sum()<=1.0\n"+""; |
154 | |
155 | /** |
156 | * The cached OCL invariant for the '{@link #SumOfInternalActionFailureProbabilitiesMustNotExceed1(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Sum Of Internal Action Failure Probabilities Must Not Exceed1</em>}' invariant operation. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @see #SumOfInternalActionFailureProbabilitiesMustNotExceed1(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
160 | * @generated |
161 | * @ordered |
162 | */ |
163 | protected static Constraint SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
164 | |
165 | /** |
166 | * <!-- begin-user-doc --> |
167 | * <!-- end-user-doc --> |
168 | * @generated |
169 | */ |
170 | public boolean SumOfInternalActionFailureProbabilitiesMustNotExceed1(DiagnosticChain diagnostics, Map<Object, Object> context) { |
171 | if (SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
172 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
173 | helper.setContext(SeffPackage.Literals.INTERNAL_ACTION); |
174 | try { |
175 | SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
176 | } |
177 | catch (ParserException pe) { |
178 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
179 | } |
180 | } |
181 | if (!EOCL_ENV.createQuery(SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
182 | if (diagnostics != null) { |
183 | diagnostics.add |
184 | (new BasicDiagnostic |
185 | (Diagnostic.ERROR, |
186 | SeffValidator.DIAGNOSTIC_SOURCE, |
187 | SeffValidator.INTERNAL_ACTION__SUM_OF_INTERNAL_ACTION_FAILURE_PROBABILITIES_MUST_NOT_EXCEED1, |
188 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "SumOfInternalActionFailureProbabilitiesMustNotExceed1", EObjectValidator.getObjectLabel(this, context) }), |
189 | new Object [] { this })); |
190 | } |
191 | return false; |
192 | } |
193 | return true; |
194 | } |
195 | |
196 | /** |
197 | * <!-- begin-user-doc --> |
198 | * <!-- end-user-doc --> |
199 | * @generated |
200 | */ |
201 | @SuppressWarnings("unchecked") |
202 | @Override |
203 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
204 | switch (featureID) { |
205 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
206 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getInternalFailureOccurrenceDescriptions__InternalAction()).basicAdd(otherEnd, msgs); |
207 | } |
208 | return super.eInverseAdd(otherEnd, featureID, msgs); |
209 | } |
210 | |
211 | /** |
212 | * <!-- begin-user-doc --> |
213 | * <!-- end-user-doc --> |
214 | * @generated |
215 | */ |
216 | @Override |
217 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
218 | switch (featureID) { |
219 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
220 | return ((InternalEList<?>)getInternalFailureOccurrenceDescriptions__InternalAction()).basicRemove(otherEnd, msgs); |
221 | } |
222 | return super.eInverseRemove(otherEnd, featureID, msgs); |
223 | } |
224 | |
225 | /** |
226 | * <!-- begin-user-doc --> |
227 | * <!-- end-user-doc --> |
228 | * @generated |
229 | */ |
230 | @Override |
231 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
232 | switch (featureID) { |
233 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
234 | return getInternalFailureOccurrenceDescriptions__InternalAction(); |
235 | } |
236 | return super.eGet(featureID, resolve, coreType); |
237 | } |
238 | |
239 | /** |
240 | * <!-- begin-user-doc --> |
241 | * <!-- end-user-doc --> |
242 | * @generated |
243 | */ |
244 | @SuppressWarnings("unchecked") |
245 | @Override |
246 | public void eSet(int featureID, Object newValue) { |
247 | switch (featureID) { |
248 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
249 | getInternalFailureOccurrenceDescriptions__InternalAction().clear(); |
250 | getInternalFailureOccurrenceDescriptions__InternalAction().addAll((Collection<? extends InternalFailureOccurrenceDescription>)newValue); |
251 | return; |
252 | } |
253 | super.eSet(featureID, newValue); |
254 | } |
255 | |
256 | /** |
257 | * <!-- begin-user-doc --> |
258 | * <!-- end-user-doc --> |
259 | * @generated |
260 | */ |
261 | @Override |
262 | public void eUnset(int featureID) { |
263 | switch (featureID) { |
264 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
265 | getInternalFailureOccurrenceDescriptions__InternalAction().clear(); |
266 | return; |
267 | } |
268 | super.eUnset(featureID); |
269 | } |
270 | |
271 | /** |
272 | * <!-- begin-user-doc --> |
273 | * <!-- end-user-doc --> |
274 | * @generated |
275 | */ |
276 | @Override |
277 | public boolean eIsSet(int featureID) { |
278 | switch (featureID) { |
279 | case SeffPackage.INTERNAL_ACTION__INTERNAL_FAILURE_OCCURRENCE_DESCRIPTIONS_INTERNAL_ACTION: |
280 | return internalFailureOccurrenceDescriptions__InternalAction != null && !internalFailureOccurrenceDescriptions__InternalAction.isEmpty(); |
281 | } |
282 | return super.eIsSet(featureID); |
283 | } |
284 | |
285 | /** |
286 | * The cached environment for evaluating OCL expressions. |
287 | * <!-- begin-user-doc --> |
288 | * <!-- end-user-doc --> |
289 | * @generated |
290 | * @ordered |
291 | */ |
292 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
293 | |
294 | } //InternalActionImpl |