1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl; |
8 | |
9 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.Criterion; |
10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.SimpleQMLContract; |
12 | |
13 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.util.QMLContractValidator; |
14 | |
15 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractType; |
16 | |
17 | import java.util.Collection; |
18 | import java.util.Map; |
19 | |
20 | import org.eclipse.emf.common.notify.Notification; |
21 | import org.eclipse.emf.common.notify.NotificationChain; |
22 | |
23 | import org.eclipse.emf.common.util.BasicDiagnostic; |
24 | import org.eclipse.emf.common.util.Diagnostic; |
25 | import org.eclipse.emf.common.util.DiagnosticChain; |
26 | import org.eclipse.emf.common.util.EList; |
27 | |
28 | import org.eclipse.emf.ecore.EClass; |
29 | import org.eclipse.emf.ecore.InternalEObject; |
30 | |
31 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
32 | |
33 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
34 | |
35 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
36 | import org.eclipse.emf.ecore.util.EObjectValidator; |
37 | import org.eclipse.emf.ecore.util.InternalEList; |
38 | |
39 | import org.eclipse.ocl.ParserException; |
40 | |
41 | import org.eclipse.ocl.ecore.Constraint; |
42 | import org.eclipse.ocl.ecore.OCL; |
43 | |
44 | /** |
45 | * <!-- begin-user-doc --> |
46 | * An implementation of the model object '<em><b>Simple QML Contract</b></em>'. |
47 | * <!-- end-user-doc --> |
48 | * <p> |
49 | * The following features are implemented: |
50 | * <ul> |
51 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl.SimpleQMLContractImpl#getCriteria <em>Criteria</em>}</li> |
52 | * <li>{@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.impl.SimpleQMLContractImpl#getContractType <em>Contract Type</em>}</li> |
53 | * </ul> |
54 | * </p> |
55 | * |
56 | * @generated |
57 | */ |
58 | public class SimpleQMLContractImpl extends GenericQMLContractImpl implements SimpleQMLContract { |
59 | /** |
60 | * The cached value of the '{@link #getCriteria() <em>Criteria</em>}' containment reference list. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @see #getCriteria() |
64 | * @generated |
65 | * @ordered |
66 | */ |
67 | protected EList<Criterion> criteria; |
68 | |
69 | /** |
70 | * The cached value of the '{@link #getContractType() <em>Contract Type</em>}' reference. |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @see #getContractType() |
74 | * @generated |
75 | * @ordered |
76 | */ |
77 | protected QMLContractType contractType; |
78 | |
79 | /** |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected SimpleQMLContractImpl() { |
85 | super(); |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | @Override |
94 | protected EClass eStaticClass() { |
95 | return QMLContractPackage.Literals.SIMPLE_QML_CONTRACT; |
96 | } |
97 | |
98 | /** |
99 | * <!-- begin-user-doc --> |
100 | * <!-- end-user-doc --> |
101 | * @generated |
102 | */ |
103 | public EList<Criterion> getCriteria() { |
104 | if (criteria == null) { |
105 | criteria = new EObjectContainmentEList<Criterion>(Criterion.class, this, QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA); |
106 | } |
107 | return criteria; |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | public QMLContractType getContractType() { |
116 | if (contractType != null && contractType.eIsProxy()) { |
117 | InternalEObject oldContractType = (InternalEObject)contractType; |
118 | contractType = (QMLContractType)eResolveProxy(oldContractType); |
119 | if (contractType != oldContractType) { |
120 | if (eNotificationRequired()) |
121 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE, oldContractType, contractType)); |
122 | } |
123 | } |
124 | return contractType; |
125 | } |
126 | |
127 | /** |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated |
131 | */ |
132 | public QMLContractType basicGetContractType() { |
133 | return contractType; |
134 | } |
135 | |
136 | /** |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | public void setContractType(QMLContractType newContractType) { |
142 | QMLContractType oldContractType = contractType; |
143 | contractType = newContractType; |
144 | if (eNotificationRequired()) |
145 | eNotify(new ENotificationImpl(this, Notification.SET, QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE, oldContractType, contractType)); |
146 | } |
147 | |
148 | /** |
149 | * The cached OCL expression body for the '{@link #all_DIMENSIONs_must_be_from_same_CONTRACTTYPE(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>All DIMENSIO Ns must be from same CONTRACTTYPE</em>}' operation. |
150 | * <!-- begin-user-doc --> |
151 | * <!-- end-user-doc --> |
152 | * @see #all_DIMENSIONs_must_be_from_same_CONTRACTTYPE(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
153 | * @generated |
154 | * @ordered |
155 | */ |
156 | protected static final String ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "(self.contractType<> null) implies ("+ |
157 | " self.criteria->forAll(c|"+ |
158 | " self.contractType.dimensions->exists(dim|c.dimension=dim)"+ |
159 | " )"+ |
160 | ")"; |
161 | |
162 | /** |
163 | * The cached OCL invariant for the '{@link #all_DIMENSIONs_must_be_from_same_CONTRACTTYPE(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>All DIMENSIO Ns must be from same CONTRACTTYPE</em>}' invariant operation. |
164 | * <!-- begin-user-doc --> |
165 | * <!-- end-user-doc --> |
166 | * @see #all_DIMENSIONs_must_be_from_same_CONTRACTTYPE(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
167 | * @generated |
168 | * @ordered |
169 | */ |
170 | protected static Constraint ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
171 | |
172 | /** |
173 | * <!-- begin-user-doc --> |
174 | * <!-- end-user-doc --> |
175 | * @generated |
176 | */ |
177 | public boolean all_DIMENSIONs_must_be_from_same_CONTRACTTYPE(DiagnosticChain diagnostics, Map<Object, Object> context) { |
178 | if (ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
179 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
180 | helper.setContext(QMLContractPackage.Literals.SIMPLE_QML_CONTRACT); |
181 | try { |
182 | ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
183 | } |
184 | catch (ParserException pe) { |
185 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
186 | } |
187 | } |
188 | if (!EOCL_ENV.createQuery(ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
189 | if (diagnostics != null) { |
190 | diagnostics.add |
191 | (new BasicDiagnostic |
192 | (Diagnostic.ERROR, |
193 | QMLContractValidator.DIAGNOSTIC_SOURCE, |
194 | QMLContractValidator.SIMPLE_QML_CONTRACT__ALL_DIMENSIO_NS_MUST_BE_FROM_SAME_CONTRACTTYPE, |
195 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "all_DIMENSIONs_must_be_from_same_CONTRACTTYPE", EObjectValidator.getObjectLabel(this, context) }), |
196 | new Object [] { this })); |
197 | } |
198 | return false; |
199 | } |
200 | return true; |
201 | } |
202 | |
203 | /** |
204 | * <!-- begin-user-doc --> |
205 | * <!-- end-user-doc --> |
206 | * @generated |
207 | */ |
208 | @Override |
209 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
210 | switch (featureID) { |
211 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA: |
212 | return ((InternalEList<?>)getCriteria()).basicRemove(otherEnd, msgs); |
213 | } |
214 | return super.eInverseRemove(otherEnd, featureID, msgs); |
215 | } |
216 | |
217 | /** |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | @Override |
223 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
224 | switch (featureID) { |
225 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA: |
226 | return getCriteria(); |
227 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE: |
228 | if (resolve) return getContractType(); |
229 | return basicGetContractType(); |
230 | } |
231 | return super.eGet(featureID, resolve, coreType); |
232 | } |
233 | |
234 | /** |
235 | * <!-- begin-user-doc --> |
236 | * <!-- end-user-doc --> |
237 | * @generated |
238 | */ |
239 | @SuppressWarnings("unchecked") |
240 | @Override |
241 | public void eSet(int featureID, Object newValue) { |
242 | switch (featureID) { |
243 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA: |
244 | getCriteria().clear(); |
245 | getCriteria().addAll((Collection<? extends Criterion>)newValue); |
246 | return; |
247 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE: |
248 | setContractType((QMLContractType)newValue); |
249 | return; |
250 | } |
251 | super.eSet(featureID, newValue); |
252 | } |
253 | |
254 | /** |
255 | * <!-- begin-user-doc --> |
256 | * <!-- end-user-doc --> |
257 | * @generated |
258 | */ |
259 | @Override |
260 | public void eUnset(int featureID) { |
261 | switch (featureID) { |
262 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA: |
263 | getCriteria().clear(); |
264 | return; |
265 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE: |
266 | setContractType((QMLContractType)null); |
267 | return; |
268 | } |
269 | super.eUnset(featureID); |
270 | } |
271 | |
272 | /** |
273 | * <!-- begin-user-doc --> |
274 | * <!-- end-user-doc --> |
275 | * @generated |
276 | */ |
277 | @Override |
278 | public boolean eIsSet(int featureID) { |
279 | switch (featureID) { |
280 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CRITERIA: |
281 | return criteria != null && !criteria.isEmpty(); |
282 | case QMLContractPackage.SIMPLE_QML_CONTRACT__CONTRACT_TYPE: |
283 | return contractType != null; |
284 | } |
285 | return super.eIsSet(featureID); |
286 | } |
287 | |
288 | /** |
289 | * The cached environment for evaluating OCL expressions. |
290 | * <!-- begin-user-doc --> |
291 | * <!-- end-user-doc --> |
292 | * @generated |
293 | * @ordered |
294 | */ |
295 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
296 | |
297 | } //SimpleQMLContractImpl |