1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.repository.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.repository.BasicComponent; |
27 | import de.uka.ipd.sdq.pcm.repository.PassiveResource; |
28 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
29 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
30 | import de.uka.ipd.sdq.pcm.seff.SeffPackage; |
31 | import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification; |
32 | |
33 | /** |
34 | * <!-- begin-user-doc --> |
35 | * An implementation of the model object '<em><b>Basic Component</b></em>'. |
36 | * <!-- end-user-doc --> |
37 | * <p> |
38 | * The following features are implemented: |
39 | * <ul> |
40 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.BasicComponentImpl#getServiceEffectSpecifications__BasicComponent <em>Service Effect Specifications Basic Component</em>}</li> |
41 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.BasicComponentImpl#getPassiveResource_BasicComponent <em>Passive Resource Basic Component</em>}</li> |
42 | * </ul> |
43 | * </p> |
44 | * |
45 | * @generated |
46 | */ |
47 | public class BasicComponentImpl extends ImplementationComponentTypeImpl implements BasicComponent { |
48 | /** |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @generated |
52 | */ |
53 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
54 | |
55 | /** |
56 | * The cached value of the '{@link #getServiceEffectSpecifications__BasicComponent() <em>Service Effect Specifications Basic Component</em>}' containment reference list. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @see #getServiceEffectSpecifications__BasicComponent() |
60 | * @generated |
61 | * @ordered |
62 | */ |
63 | protected EList<ServiceEffectSpecification> serviceEffectSpecifications__BasicComponent; |
64 | |
65 | /** |
66 | * The cached value of the '{@link #getPassiveResource_BasicComponent() <em>Passive Resource Basic Component</em>}' containment reference list. |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @see #getPassiveResource_BasicComponent() |
70 | * @generated |
71 | * @ordered |
72 | */ |
73 | protected EList<PassiveResource> passiveResource_BasicComponent; |
74 | |
75 | /** |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | protected BasicComponentImpl() { |
81 | super(); |
82 | } |
83 | |
84 | /** |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @generated |
88 | */ |
89 | @Override |
90 | protected EClass eStaticClass() { |
91 | return RepositoryPackage.Literals.BASIC_COMPONENT; |
92 | } |
93 | |
94 | /** |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | public EList<ServiceEffectSpecification> getServiceEffectSpecifications__BasicComponent() { |
100 | if (serviceEffectSpecifications__BasicComponent == null) { |
101 | serviceEffectSpecifications__BasicComponent = new EObjectContainmentWithInverseEList<ServiceEffectSpecification>(ServiceEffectSpecification.class, this, RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT, SeffPackage.SERVICE_EFFECT_SPECIFICATION__BASIC_COMPONENT_SERVICE_EFFECT_SPECIFICATION); |
102 | } |
103 | return serviceEffectSpecifications__BasicComponent; |
104 | } |
105 | |
106 | /** |
107 | * <!-- begin-user-doc --> |
108 | * <!-- end-user-doc --> |
109 | * @generated |
110 | */ |
111 | public EList<PassiveResource> getPassiveResource_BasicComponent() { |
112 | if (passiveResource_BasicComponent == null) { |
113 | passiveResource_BasicComponent = new EObjectContainmentWithInverseEList<PassiveResource>(PassiveResource.class, this, RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT, RepositoryPackage.PASSIVE_RESOURCE__BASIC_COMPONENT_PASSIVE_RESOURCE); |
114 | } |
115 | return passiveResource_BasicComponent; |
116 | } |
117 | |
118 | /** |
119 | * The cached OCL expression body for the '{@link #NoSeffTypeUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>No Seff Type Used Twice</em>}' operation. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @see #NoSeffTypeUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
123 | * @generated |
124 | * @ordered |
125 | */ |
126 | protected static final String NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.serviceEffectSpecifications__BasicComponent->forAll(p1, p2 |\n"+" p1 <> p2 implies (p1.describedService__SEFF = p2.describedService__SEFF implies p1.seffTypeID <> p2.seffTypeID))"; |
127 | |
128 | /** |
129 | * The cached OCL invariant for the '{@link #NoSeffTypeUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>No Seff Type Used Twice</em>}' invariant operation. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @see #NoSeffTypeUsedTwice(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
133 | * @generated |
134 | * @ordered |
135 | */ |
136 | protected static Constraint NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
137 | |
138 | /** |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | public boolean NoSeffTypeUsedTwice(DiagnosticChain diagnostics, Map<Object, Object> context) { |
144 | if (NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
145 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
146 | helper.setContext(RepositoryPackage.Literals.BASIC_COMPONENT); |
147 | try { |
148 | NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
149 | } |
150 | catch (ParserException pe) { |
151 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
152 | } |
153 | } |
154 | if (!EOCL_ENV.createQuery(NO_SEFF_TYPE_USED_TWICE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
155 | if (diagnostics != null) { |
156 | diagnostics.add |
157 | (new BasicDiagnostic |
158 | (Diagnostic.ERROR, |
159 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
160 | RepositoryValidator.BASIC_COMPONENT__NO_SEFF_TYPE_USED_TWICE, |
161 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "NoSeffTypeUsedTwice", EObjectValidator.getObjectLabel(this, context) }), |
162 | new Object [] { this })); |
163 | } |
164 | return false; |
165 | } |
166 | return true; |
167 | } |
168 | |
169 | /** |
170 | * The cached OCL expression body for the '{@link #ProvideSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provide Same Interfaces As Implementation Type</em>}' operation. |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @see #ProvideSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
174 | * @generated |
175 | * @ordered |
176 | */ |
177 | protected static final String PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- BC has to provide the same interfaces like the implementationComponentType (if set) #\n"+"if\n"+" -- apply constraint only for non-empty ImplementationComponentTypes of a BC #\n"+" self.parentCompleteComponentTypes->notEmpty()\n"+"then\n"+" --own interface IDs:\n"+" self.providedRoles_InterfaceProvidingEntity->collect(pr : ProvidedRole | pr.providingEntity_ProvidedRole.id)->asSet()\n"+" =\n"+" --complete type interface IDs:\n"+" self.parentCompleteComponentTypes->collect(pr | pr.providedRoles_InterfaceProvidingEntity.providingEntity_ProvidedRole.id)->asSet()\n"+"else\n"+" true\n"+"endif"; |
178 | |
179 | /** |
180 | * The cached OCL invariant for the '{@link #ProvideSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provide Same Interfaces As Implementation Type</em>}' invariant operation. |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @see #ProvideSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
184 | * @generated |
185 | * @ordered |
186 | */ |
187 | protected static Constraint PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
188 | |
189 | /** |
190 | * <!-- begin-user-doc --> |
191 | * <!-- end-user-doc --> |
192 | * @generated |
193 | */ |
194 | public boolean ProvideSameInterfacesAsImplementationType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
195 | if (PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
196 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
197 | helper.setContext(RepositoryPackage.Literals.BASIC_COMPONENT); |
198 | try { |
199 | PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
200 | } |
201 | catch (ParserException pe) { |
202 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
203 | } |
204 | } |
205 | if (!EOCL_ENV.createQuery(PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
206 | if (diagnostics != null) { |
207 | diagnostics.add |
208 | (new BasicDiagnostic |
209 | (Diagnostic.ERROR, |
210 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
211 | RepositoryValidator.BASIC_COMPONENT__PROVIDE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE, |
212 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ProvideSameInterfacesAsImplementationType", EObjectValidator.getObjectLabel(this, context) }), |
213 | new Object [] { this })); |
214 | } |
215 | return false; |
216 | } |
217 | return true; |
218 | } |
219 | |
220 | /** |
221 | * The cached OCL expression body for the '{@link #RequireSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Require Same Interfaces As Implementation Type</em>}' operation. |
222 | * <!-- begin-user-doc --> |
223 | * <!-- end-user-doc --> |
224 | * @see #RequireSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
225 | * @generated |
226 | * @ordered |
227 | */ |
228 | protected static final String REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- BC has to require the same interfaces like the implementationComponentType (if set) #\n"+"if\n"+" -- apply constraint only for non-empty ImplementationComponentTypes of a BC #\n"+" self.parentCompleteComponentTypes->notEmpty()\n"+"then\n"+" --own interface IDs:\n"+" self.requiredRoles_InterfaceRequiringEntity->select(rr |rr.oclIsTypeOf(OperationRequiredRole))->collect(rr | rr.oclAsType (OperationRequiredRole).requiredInterface__OperationRequiredRole.id)->asSet()\n"+" =\n"+" --complete type interface IDs:\n"+" self.parentCompleteComponentTypes.requiredRoles_InterfaceRequiringEntity->select(rr |rr.oclIsTypeOf(OperationRequiredRole))->collect(rr | rr.oclAsType (OperationRequiredRole).requiredInterface__OperationRequiredRole.id)->asSet()\n"+"else\n"+" true\n"+"endif"; |
229 | |
230 | /** |
231 | * The cached OCL invariant for the '{@link #RequireSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Require Same Interfaces As Implementation Type</em>}' invariant operation. |
232 | * <!-- begin-user-doc --> |
233 | * <!-- end-user-doc --> |
234 | * @see #RequireSameInterfacesAsImplementationType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
235 | * @generated |
236 | * @ordered |
237 | */ |
238 | protected static Constraint REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
239 | |
240 | /** |
241 | * <!-- begin-user-doc --> |
242 | * <!-- end-user-doc --> |
243 | * @generated |
244 | */ |
245 | public boolean RequireSameInterfacesAsImplementationType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
246 | if (REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
247 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
248 | helper.setContext(RepositoryPackage.Literals.BASIC_COMPONENT); |
249 | try { |
250 | REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
251 | } |
252 | catch (ParserException pe) { |
253 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
254 | } |
255 | } |
256 | if (!EOCL_ENV.createQuery(REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
257 | if (diagnostics != null) { |
258 | diagnostics.add |
259 | (new BasicDiagnostic |
260 | (Diagnostic.ERROR, |
261 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
262 | RepositoryValidator.BASIC_COMPONENT__REQUIRE_SAME_INTERFACES_AS_IMPLEMENTATION_TYPE, |
263 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "RequireSameInterfacesAsImplementationType", EObjectValidator.getObjectLabel(this, context) }), |
264 | new Object [] { this })); |
265 | } |
266 | return false; |
267 | } |
268 | return true; |
269 | } |
270 | |
271 | /** |
272 | * <!-- begin-user-doc --> |
273 | * <!-- end-user-doc --> |
274 | * @generated |
275 | */ |
276 | @SuppressWarnings("unchecked") |
277 | @Override |
278 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
279 | switch (featureID) { |
280 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
281 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getServiceEffectSpecifications__BasicComponent()).basicAdd(otherEnd, msgs); |
282 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
283 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getPassiveResource_BasicComponent()).basicAdd(otherEnd, msgs); |
284 | } |
285 | return super.eInverseAdd(otherEnd, featureID, msgs); |
286 | } |
287 | |
288 | /** |
289 | * <!-- begin-user-doc --> |
290 | * <!-- end-user-doc --> |
291 | * @generated |
292 | */ |
293 | @Override |
294 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
295 | switch (featureID) { |
296 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
297 | return ((InternalEList<?>)getServiceEffectSpecifications__BasicComponent()).basicRemove(otherEnd, msgs); |
298 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
299 | return ((InternalEList<?>)getPassiveResource_BasicComponent()).basicRemove(otherEnd, msgs); |
300 | } |
301 | return super.eInverseRemove(otherEnd, featureID, msgs); |
302 | } |
303 | |
304 | /** |
305 | * <!-- begin-user-doc --> |
306 | * <!-- end-user-doc --> |
307 | * @generated |
308 | */ |
309 | @Override |
310 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
311 | switch (featureID) { |
312 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
313 | return getServiceEffectSpecifications__BasicComponent(); |
314 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
315 | return getPassiveResource_BasicComponent(); |
316 | } |
317 | return super.eGet(featureID, resolve, coreType); |
318 | } |
319 | |
320 | /** |
321 | * <!-- begin-user-doc --> |
322 | * <!-- end-user-doc --> |
323 | * @generated |
324 | */ |
325 | @SuppressWarnings("unchecked") |
326 | @Override |
327 | public void eSet(int featureID, Object newValue) { |
328 | switch (featureID) { |
329 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
330 | getServiceEffectSpecifications__BasicComponent().clear(); |
331 | getServiceEffectSpecifications__BasicComponent().addAll((Collection<? extends ServiceEffectSpecification>)newValue); |
332 | return; |
333 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
334 | getPassiveResource_BasicComponent().clear(); |
335 | getPassiveResource_BasicComponent().addAll((Collection<? extends PassiveResource>)newValue); |
336 | return; |
337 | } |
338 | super.eSet(featureID, newValue); |
339 | } |
340 | |
341 | /** |
342 | * <!-- begin-user-doc --> |
343 | * <!-- end-user-doc --> |
344 | * @generated |
345 | */ |
346 | @Override |
347 | public void eUnset(int featureID) { |
348 | switch (featureID) { |
349 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
350 | getServiceEffectSpecifications__BasicComponent().clear(); |
351 | return; |
352 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
353 | getPassiveResource_BasicComponent().clear(); |
354 | return; |
355 | } |
356 | super.eUnset(featureID); |
357 | } |
358 | |
359 | /** |
360 | * <!-- begin-user-doc --> |
361 | * <!-- end-user-doc --> |
362 | * @generated |
363 | */ |
364 | @Override |
365 | public boolean eIsSet(int featureID) { |
366 | switch (featureID) { |
367 | case RepositoryPackage.BASIC_COMPONENT__SERVICE_EFFECT_SPECIFICATIONS_BASIC_COMPONENT: |
368 | return serviceEffectSpecifications__BasicComponent != null && !serviceEffectSpecifications__BasicComponent.isEmpty(); |
369 | case RepositoryPackage.BASIC_COMPONENT__PASSIVE_RESOURCE_BASIC_COMPONENT: |
370 | return passiveResource_BasicComponent != null && !passiveResource_BasicComponent.isEmpty(); |
371 | } |
372 | return super.eIsSet(featureID); |
373 | } |
374 | |
375 | } //BasicComponentImpl |