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