| 1 | /** |
| 2 | * Copyright SDQ, IPD, U Karlsruhe, 2007 |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.completions.impl; |
| 7 | |
| 8 | import java.util.Collection; |
| 9 | import java.util.Map; |
| 10 | |
| 11 | import org.eclipse.emf.common.notify.Notification; |
| 12 | import org.eclipse.emf.common.notify.NotificationChain; |
| 13 | import org.eclipse.emf.common.util.BasicDiagnostic; |
| 14 | import org.eclipse.emf.common.util.Diagnostic; |
| 15 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 16 | import org.eclipse.emf.common.util.EList; |
| 17 | import org.eclipse.emf.ecore.EClass; |
| 18 | import org.eclipse.emf.ecore.InternalEObject; |
| 19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 21 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 22 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| 23 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 24 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 25 | import org.eclipse.emf.ecore.util.InternalEList; |
| 26 | import org.eclipse.ocl.ParserException; |
| 27 | import org.eclipse.ocl.ecore.Constraint; |
| 28 | import org.eclipse.ocl.ecore.OCL; |
| 29 | |
| 30 | import de.uka.ipd.sdq.completions.Completion; |
| 31 | import de.uka.ipd.sdq.completions.CompletionsPackage; |
| 32 | import de.uka.ipd.sdq.pcm.core.entity.impl.ComposedProvidingRequiringEntityImpl; |
| 33 | import de.uka.ipd.sdq.pcm.parameter.VariableUsage; |
| 34 | import de.uka.ipd.sdq.pcm.repository.CompleteComponentType; |
| 35 | import de.uka.ipd.sdq.pcm.repository.ComponentType; |
| 36 | import de.uka.ipd.sdq.pcm.repository.ImplementationComponentType; |
| 37 | import de.uka.ipd.sdq.pcm.repository.Repository; |
| 38 | import de.uka.ipd.sdq.pcm.repository.RepositoryComponent; |
| 39 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 40 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
| 41 | |
| 42 | /** |
| 43 | * <!-- begin-user-doc --> |
| 44 | * An implementation of the model object '<em><b>Completion</b></em>'. |
| 45 | * <!-- end-user-doc --> |
| 46 | * <p> |
| 47 | * The following features are implemented: |
| 48 | * <ul> |
| 49 | * <li>{@link de.uka.ipd.sdq.completions.impl.CompletionImpl#getRepository__RepositoryComponent <em>Repository Repository Component</em>}</li> |
| 50 | * <li>{@link de.uka.ipd.sdq.completions.impl.CompletionImpl#getParentCompleteComponentTypes <em>Parent Complete Component Types</em>}</li> |
| 51 | * <li>{@link de.uka.ipd.sdq.completions.impl.CompletionImpl#getComponentParameterUsage_ImplementationComponentType <em>Component Parameter Usage Implementation Component Type</em>}</li> |
| 52 | * <li>{@link de.uka.ipd.sdq.completions.impl.CompletionImpl#getComponentType <em>Component Type</em>}</li> |
| 53 | * </ul> |
| 54 | * </p> |
| 55 | * |
| 56 | * @generated |
| 57 | */ |
| 58 | public class CompletionImpl extends ComposedProvidingRequiringEntityImpl implements Completion { |
| 59 | /** |
| 60 | * The cached value of the '{@link #getParentCompleteComponentTypes() <em>Parent Complete Component Types</em>}' reference list. |
| 61 | * <!-- begin-user-doc --> |
| 62 | * <!-- end-user-doc --> |
| 63 | * @see #getParentCompleteComponentTypes() |
| 64 | * @generated |
| 65 | * @ordered |
| 66 | */ |
| 67 | protected EList<CompleteComponentType> parentCompleteComponentTypes; |
| 68 | |
| 69 | /** |
| 70 | * The cached value of the '{@link #getComponentParameterUsage_ImplementationComponentType() <em>Component Parameter Usage Implementation Component Type</em>}' containment reference list. |
| 71 | * <!-- begin-user-doc --> |
| 72 | * <!-- end-user-doc --> |
| 73 | * @see #getComponentParameterUsage_ImplementationComponentType() |
| 74 | * @generated |
| 75 | * @ordered |
| 76 | */ |
| 77 | protected EList<VariableUsage> componentParameterUsage_ImplementationComponentType; |
| 78 | |
| 79 | /** |
| 80 | * The default value of the '{@link #getComponentType() <em>Component Type</em>}' attribute. |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @see #getComponentType() |
| 84 | * @generated |
| 85 | * @ordered |
| 86 | */ |
| 87 | protected static final ComponentType COMPONENT_TYPE_EDEFAULT = ComponentType.BUSINESS_COMPONENT; |
| 88 | |
| 89 | /** |
| 90 | * The cached value of the '{@link #getComponentType() <em>Component Type</em>}' attribute. |
| 91 | * <!-- begin-user-doc --> |
| 92 | * <!-- end-user-doc --> |
| 93 | * @see #getComponentType() |
| 94 | * @generated |
| 95 | * @ordered |
| 96 | */ |
| 97 | protected ComponentType componentType = COMPONENT_TYPE_EDEFAULT; |
| 98 | |
| 99 | /** |
| 100 | * <!-- begin-user-doc --> |
| 101 | * <!-- end-user-doc --> |
| 102 | * @generated |
| 103 | */ |
| 104 | protected CompletionImpl() { |
| 105 | super(); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * <!-- begin-user-doc --> |
| 110 | * <!-- end-user-doc --> |
| 111 | * @generated |
| 112 | */ |
| 113 | @Override |
| 114 | protected EClass eStaticClass() { |
| 115 | return CompletionsPackage.Literals.COMPLETION; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * <!-- begin-user-doc --> |
| 120 | * <!-- end-user-doc --> |
| 121 | * @generated |
| 122 | */ |
| 123 | public Repository getRepository__RepositoryComponent() { |
| 124 | if (eContainerFeatureID() != CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT) return null; |
| 125 | return (Repository)eContainer(); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * <!-- begin-user-doc --> |
| 130 | * <!-- end-user-doc --> |
| 131 | * @generated |
| 132 | */ |
| 133 | public NotificationChain basicSetRepository__RepositoryComponent(Repository newRepository__RepositoryComponent, NotificationChain msgs) { |
| 134 | msgs = eBasicSetContainer((InternalEObject)newRepository__RepositoryComponent, CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT, msgs); |
| 135 | return msgs; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * <!-- begin-user-doc --> |
| 140 | * <!-- end-user-doc --> |
| 141 | * @generated |
| 142 | */ |
| 143 | public void setRepository__RepositoryComponent(Repository newRepository__RepositoryComponent) { |
| 144 | if (newRepository__RepositoryComponent != eInternalContainer() || (eContainerFeatureID() != CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT && newRepository__RepositoryComponent != null)) { |
| 145 | if (EcoreUtil.isAncestor(this, newRepository__RepositoryComponent)) |
| 146 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 147 | NotificationChain msgs = null; |
| 148 | if (eInternalContainer() != null) |
| 149 | msgs = eBasicRemoveFromContainer(msgs); |
| 150 | if (newRepository__RepositoryComponent != null) |
| 151 | msgs = ((InternalEObject)newRepository__RepositoryComponent).eInverseAdd(this, RepositoryPackage.REPOSITORY__COMPONENTS_REPOSITORY, Repository.class, msgs); |
| 152 | msgs = basicSetRepository__RepositoryComponent(newRepository__RepositoryComponent, msgs); |
| 153 | if (msgs != null) msgs.dispatch(); |
| 154 | } |
| 155 | else if (eNotificationRequired()) |
| 156 | eNotify(new ENotificationImpl(this, Notification.SET, CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT, newRepository__RepositoryComponent, newRepository__RepositoryComponent)); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * <!-- begin-user-doc --> |
| 161 | * <!-- end-user-doc --> |
| 162 | * @generated |
| 163 | */ |
| 164 | public EList<CompleteComponentType> getParentCompleteComponentTypes() { |
| 165 | if (parentCompleteComponentTypes == null) { |
| 166 | parentCompleteComponentTypes = new EObjectResolvingEList<CompleteComponentType>(CompleteComponentType.class, this, CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES); |
| 167 | } |
| 168 | return parentCompleteComponentTypes; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * <!-- begin-user-doc --> |
| 173 | * <!-- end-user-doc --> |
| 174 | * @generated |
| 175 | */ |
| 176 | public EList<VariableUsage> getComponentParameterUsage_ImplementationComponentType() { |
| 177 | if (componentParameterUsage_ImplementationComponentType == null) { |
| 178 | componentParameterUsage_ImplementationComponentType = new EObjectContainmentEList<VariableUsage>(VariableUsage.class, this, CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE); |
| 179 | } |
| 180 | return componentParameterUsage_ImplementationComponentType; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * <!-- begin-user-doc --> |
| 185 | * <!-- end-user-doc --> |
| 186 | * @generated |
| 187 | */ |
| 188 | public ComponentType getComponentType() { |
| 189 | return componentType; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * <!-- begin-user-doc --> |
| 194 | * <!-- end-user-doc --> |
| 195 | * @generated |
| 196 | */ |
| 197 | public void setComponentType(ComponentType newComponentType) { |
| 198 | ComponentType oldComponentType = componentType; |
| 199 | componentType = newComponentType == null ? COMPONENT_TYPE_EDEFAULT : newComponentType; |
| 200 | if (eNotificationRequired()) |
| 201 | eNotify(new ENotificationImpl(this, Notification.SET, CompletionsPackage.COMPLETION__COMPONENT_TYPE, oldComponentType, componentType)); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * The cached OCL expression body for the '{@link #RequiredInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Required Interfaces Have To Conform To Complete Type</em>}' operation. |
| 206 | * <!-- begin-user-doc --> |
| 207 | * <!-- end-user-doc --> |
| 208 | * @see #RequiredInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 209 | * @generated |
| 210 | * @ordered |
| 211 | */ |
| 212 | protected static final String REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- ImplementationTypes required Interfaces have to be a subset"+ |
| 213 | "-- of CompleteComponentType required Interfaces #"+ |
| 214 | "--"+ |
| 215 | "-- ACCx are used to accumulate Sets/Bags; usually only the very inner ACCx is used at all."+ |
| 216 | "--"+ |
| 217 | "-- Recursive Query for parent Interface IDs"+ |
| 218 | "-- see 'lpar2005.pdf' (Second-order principles in specification languages for Object-Oriented Programs; Beckert, Tretelman) pp. 11 #"+ |
| 219 | "--let parentInterfaces : Bag(Interface) ="+ |
| 220 | "-- self.parentCompleteComponentTypes->iterate(pt : CompleteComponentType; acc1 : Bag(Interface) = Bag{} |"+ |
| 221 | "-- acc1->union(pt.requiredRoles->iterate(r : RequiredRole; acc2 : Bag(Interface) = Bag{} |"+ |
| 222 | "-- acc2->union(r.requiredInterface.parentInterface->asBag()) -- asBag required to allow Set operations #"+ |
| 223 | "-- ))"+ |
| 224 | "-- ) in"+ |
| 225 | "--let anchestorInterfaces : Bag(Interface) ="+ |
| 226 | "-- self.parentCompleteComponentTypes->iterate(pt : CompleteComponentType; acc3 : Bag(Interface) = Bag{} |"+ |
| 227 | "-- acc3->union(pt.requiredRoles->iterate(r : RequiredRole; acc4 : Bag(Interface) = Bag{} |"+ |
| 228 | "-- acc4->union(r.requiredInterface.parentInterface->asBag()) -- asBag required to allow Set operations #"+ |
| 229 | "-- ))"+ |
| 230 | "-- )->union( -- union with anchestors found in former recursion #"+ |
| 231 | "-- self.parentCompleteComponentTypes->iterate(pt : CompleteComponentType; acc5 : Bag(Interface) = Bag{} |"+ |
| 232 | "-- acc5->union(pt.requiredRoles->iterate(r : RequiredRole; acc6 : Bag(Interface) = Bag{} |"+ |
| 233 | "-- acc6->union(r.requiredInterface.parentInterface.anchestorInterfaces) --already Set/Bag"+ |
| 234 | "-- ))"+ |
| 235 | "-- )"+ |
| 236 | "-- ) in"+ |
| 237 | "-- Directly required interfaces need to be a subset of required anchestorInterfaces of Supertype #"+ |
| 238 | "--anchestorInterfaces.identifier.id->includesAll("+ |
| 239 | "-- self.requiredRoles->iterate(p : RequiredRole; acc7 : Bag(String) = Bag{} |"+ |
| 240 | "-- acc7->union(p.requiredInterface.identifier.id->asBag())"+ |
| 241 | "-- ) "+ |
| 242 | "--)"+ |
| 243 | "true"; |
| 244 | |
| 245 | /** |
| 246 | * The cached OCL invariant for the '{@link #RequiredInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Required Interfaces Have To Conform To Complete Type</em>}' invariant operation. |
| 247 | * <!-- begin-user-doc --> |
| 248 | * <!-- end-user-doc --> |
| 249 | * @see #RequiredInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 250 | * @generated |
| 251 | * @ordered |
| 252 | */ |
| 253 | protected static Constraint REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 254 | |
| 255 | /** |
| 256 | * <!-- begin-user-doc --> |
| 257 | * <!-- end-user-doc --> |
| 258 | * @generated |
| 259 | */ |
| 260 | public boolean RequiredInterfacesHaveToConformToCompleteType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 261 | if (REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 262 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 263 | helper.setContext(RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE); |
| 264 | try { |
| 265 | REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 266 | } |
| 267 | catch (ParserException pe) { |
| 268 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 269 | } |
| 270 | } |
| 271 | if (!EOCL_ENV.createQuery(REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 272 | if (diagnostics != null) { |
| 273 | diagnostics.add |
| 274 | (new BasicDiagnostic |
| 275 | (Diagnostic.ERROR, |
| 276 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 277 | RepositoryValidator.IMPLEMENTATION_COMPONENT_TYPE__REQUIRED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE, |
| 278 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "RequiredInterfacesHaveToConformToCompleteType", EObjectValidator.getObjectLabel(this, context) }), |
| 279 | new Object [] { this })); |
| 280 | } |
| 281 | return false; |
| 282 | } |
| 283 | return true; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * The cached OCL expression body for the '{@link #providedInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interfaces Have To Conform To Complete Type</em>}' operation. |
| 288 | * <!-- begin-user-doc --> |
| 289 | * <!-- end-user-doc --> |
| 290 | * @see #providedInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 291 | * @generated |
| 292 | * @ordered |
| 293 | */ |
| 294 | protected static final String PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- ### EXACT COPY FROM ABOVE ###"+ |
| 295 | "-- ImplementationComponentTypes provided Interfaces have to be a superset"+ |
| 296 | "-- of CompleteComponentType provided Interfaces #"+ |
| 297 | "--"+ |
| 298 | "-- ACCx are used to accumulate Sets/Bags; usually only the very inner ACCx is used at all."+ |
| 299 | "--"+ |
| 300 | "-- Recursive Query for parent Interface IDs"+ |
| 301 | "-- see 'lpar2005.pdf' (Second-order principles in specification languages for Object-Oriented Programs; Beckert, Tretelman) pp. 11 #"+ |
| 302 | "--let parentInterfaces : Bag(Interface) ="+ |
| 303 | "-- self.providedRoles->iterate(r : ProvidedRole; acc2 : Bag(Interface) = Bag{} |"+ |
| 304 | "-- acc2->union(r.providedInterface.parentInterface->asBag()) -- asBag required to allow Set operations #"+ |
| 305 | "-- ) in"+ |
| 306 | "--let anchestorInterfaces : Bag(Interface) ="+ |
| 307 | "-- self.providedRoles->iterate(r : ProvidedRole; acc4 : Bag(Interface) = Bag{} |"+ |
| 308 | "-- acc4->union(r.providedInterface.parentInterface->asBag()) -- asBag required to allow Set operations #"+ |
| 309 | "-- )->union( -- union with anchestors found in former recursion #"+ |
| 310 | "-- self.providedRoles->iterate(r : ProvidedRole; acc6 : Bag(Interface) = Bag{} |"+ |
| 311 | "-- acc6->union(r.providedInterface.parentInterface.anchestorInterfaces) --already Set/Bag"+ |
| 312 | "-- )"+ |
| 313 | "-- ) in"+ |
| 314 | " -- Directly provided anchestorInterfaces need to be a superset of provided interfaces of Supertype #"+ |
| 315 | "-- anchestorInterfaces.identifier.id->includesAll("+ |
| 316 | "-- self.parentProvidesComponentTypes->iterate(pt : ProvidesComponentType; acc1 : Bag(String) = Bag{} |"+ |
| 317 | "-- pt.providedRoles->iterate(r : ProvidedRole; acc2 : Bag(String) = Bag{} |"+ |
| 318 | "-- acc2->union(r.providedInterface.identifier.id->asBag()) -- asBag required to allow Set operations #"+ |
| 319 | "-- )"+ |
| 320 | "-- )"+ |
| 321 | "-- )"+ |
| 322 | "true"; |
| 323 | |
| 324 | /** |
| 325 | * The cached OCL invariant for the '{@link #providedInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interfaces Have To Conform To Complete Type</em>}' invariant operation. |
| 326 | * <!-- begin-user-doc --> |
| 327 | * <!-- end-user-doc --> |
| 328 | * @see #providedInterfacesHaveToConformToCompleteType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 329 | * @generated |
| 330 | * @ordered |
| 331 | */ |
| 332 | protected static Constraint PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 333 | |
| 334 | /** |
| 335 | * <!-- begin-user-doc --> |
| 336 | * <!-- end-user-doc --> |
| 337 | * @generated |
| 338 | */ |
| 339 | public boolean providedInterfacesHaveToConformToCompleteType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 340 | if (PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 341 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 342 | helper.setContext(RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE); |
| 343 | try { |
| 344 | PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 345 | } |
| 346 | catch (ParserException pe) { |
| 347 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 348 | } |
| 349 | } |
| 350 | if (!EOCL_ENV.createQuery(PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 351 | if (diagnostics != null) { |
| 352 | diagnostics.add |
| 353 | (new BasicDiagnostic |
| 354 | (Diagnostic.ERROR, |
| 355 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 356 | RepositoryValidator.IMPLEMENTATION_COMPONENT_TYPE__PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_COMPLETE_TYPE, |
| 357 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "providedInterfacesHaveToConformToCompleteType", EObjectValidator.getObjectLabel(this, context) }), |
| 358 | new Object [] { this })); |
| 359 | } |
| 360 | return false; |
| 361 | } |
| 362 | return true; |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * The cached OCL expression body for the '{@link #ProvidedInterfaceHaveToConformToComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interface Have To Conform To Component Type</em>}' operation. |
| 367 | * <!-- begin-user-doc --> |
| 368 | * <!-- end-user-doc --> |
| 369 | * @see #ProvidedInterfaceHaveToConformToComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 370 | * @generated |
| 371 | * @ordered |
| 372 | */ |
| 373 | protected static final String PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "if self.componentType = ComponentType::INFRASTRUCTURE_COMPONENT then"+ |
| 374 | " self.providedRoles_InterfaceProvidingEntity->select(role | role.oclIsTypeOf(OperationInterface) or role.oclIsTypeOf(EventGroup))->size() = 0"+ |
| 375 | "else if self.componentType = ComponentType::BUSINESS_COMPONENT then"+ |
| 376 | " self.providedRoles_InterfaceProvidingEntity->select(role | role.oclIsTypeOf(InfrastructureInterface))->size() = 0"+ |
| 377 | "else"+ |
| 378 | " 1 = 0"+ |
| 379 | "endif"+ |
| 380 | "endif"; |
| 381 | |
| 382 | /** |
| 383 | * The cached OCL invariant for the '{@link #ProvidedInterfaceHaveToConformToComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interface Have To Conform To Component Type</em>}' invariant operation. |
| 384 | * <!-- begin-user-doc --> |
| 385 | * <!-- end-user-doc --> |
| 386 | * @see #ProvidedInterfaceHaveToConformToComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 387 | * @generated |
| 388 | * @ordered |
| 389 | */ |
| 390 | protected static Constraint PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 391 | |
| 392 | /** |
| 393 | * <!-- begin-user-doc --> |
| 394 | * <!-- end-user-doc --> |
| 395 | * @generated |
| 396 | */ |
| 397 | public boolean ProvidedInterfaceHaveToConformToComponentType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 398 | if (PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 399 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 400 | helper.setContext(RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE); |
| 401 | try { |
| 402 | PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 403 | } |
| 404 | catch (ParserException pe) { |
| 405 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 406 | } |
| 407 | } |
| 408 | if (!EOCL_ENV.createQuery(PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 409 | if (diagnostics != null) { |
| 410 | diagnostics.add |
| 411 | (new BasicDiagnostic |
| 412 | (Diagnostic.ERROR, |
| 413 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 414 | RepositoryValidator.IMPLEMENTATION_COMPONENT_TYPE__PROVIDED_INTERFACE_HAVE_TO_CONFORM_TO_COMPONENT_TYPE, |
| 415 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ProvidedInterfaceHaveToConformToComponentType", EObjectValidator.getObjectLabel(this, context) }), |
| 416 | new Object [] { this })); |
| 417 | } |
| 418 | return false; |
| 419 | } |
| 420 | return true; |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * <!-- begin-user-doc --> |
| 425 | * <!-- end-user-doc --> |
| 426 | * @generated |
| 427 | */ |
| 428 | @Override |
| 429 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 430 | switch (featureID) { |
| 431 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 432 | if (eInternalContainer() != null) |
| 433 | msgs = eBasicRemoveFromContainer(msgs); |
| 434 | return basicSetRepository__RepositoryComponent((Repository)otherEnd, msgs); |
| 435 | } |
| 436 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * <!-- begin-user-doc --> |
| 441 | * <!-- end-user-doc --> |
| 442 | * @generated |
| 443 | */ |
| 444 | @Override |
| 445 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 446 | switch (featureID) { |
| 447 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 448 | return basicSetRepository__RepositoryComponent(null, msgs); |
| 449 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 450 | return ((InternalEList<?>)getComponentParameterUsage_ImplementationComponentType()).basicRemove(otherEnd, msgs); |
| 451 | } |
| 452 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * <!-- begin-user-doc --> |
| 457 | * <!-- end-user-doc --> |
| 458 | * @generated |
| 459 | */ |
| 460 | @Override |
| 461 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 462 | switch (eContainerFeatureID()) { |
| 463 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 464 | return eInternalContainer().eInverseRemove(this, RepositoryPackage.REPOSITORY__COMPONENTS_REPOSITORY, Repository.class, msgs); |
| 465 | } |
| 466 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * <!-- begin-user-doc --> |
| 471 | * <!-- end-user-doc --> |
| 472 | * @generated |
| 473 | */ |
| 474 | @Override |
| 475 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 476 | switch (featureID) { |
| 477 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 478 | return getRepository__RepositoryComponent(); |
| 479 | case CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES: |
| 480 | return getParentCompleteComponentTypes(); |
| 481 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 482 | return getComponentParameterUsage_ImplementationComponentType(); |
| 483 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: |
| 484 | return getComponentType(); |
| 485 | } |
| 486 | return super.eGet(featureID, resolve, coreType); |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * <!-- begin-user-doc --> |
| 491 | * <!-- end-user-doc --> |
| 492 | * @generated |
| 493 | */ |
| 494 | @SuppressWarnings("unchecked") |
| 495 | @Override |
| 496 | public void eSet(int featureID, Object newValue) { |
| 497 | switch (featureID) { |
| 498 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 499 | setRepository__RepositoryComponent((Repository)newValue); |
| 500 | return; |
| 501 | case CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES: |
| 502 | getParentCompleteComponentTypes().clear(); |
| 503 | getParentCompleteComponentTypes().addAll((Collection<? extends CompleteComponentType>)newValue); |
| 504 | return; |
| 505 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 506 | getComponentParameterUsage_ImplementationComponentType().clear(); |
| 507 | getComponentParameterUsage_ImplementationComponentType().addAll((Collection<? extends VariableUsage>)newValue); |
| 508 | return; |
| 509 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: |
| 510 | setComponentType((ComponentType)newValue); |
| 511 | return; |
| 512 | } |
| 513 | super.eSet(featureID, newValue); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * <!-- begin-user-doc --> |
| 518 | * <!-- end-user-doc --> |
| 519 | * @generated |
| 520 | */ |
| 521 | @Override |
| 522 | public void eUnset(int featureID) { |
| 523 | switch (featureID) { |
| 524 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 525 | setRepository__RepositoryComponent((Repository)null); |
| 526 | return; |
| 527 | case CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES: |
| 528 | getParentCompleteComponentTypes().clear(); |
| 529 | return; |
| 530 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 531 | getComponentParameterUsage_ImplementationComponentType().clear(); |
| 532 | return; |
| 533 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: |
| 534 | setComponentType(COMPONENT_TYPE_EDEFAULT); |
| 535 | return; |
| 536 | } |
| 537 | super.eUnset(featureID); |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * <!-- begin-user-doc --> |
| 542 | * <!-- end-user-doc --> |
| 543 | * @generated |
| 544 | */ |
| 545 | @Override |
| 546 | public boolean eIsSet(int featureID) { |
| 547 | switch (featureID) { |
| 548 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: |
| 549 | return getRepository__RepositoryComponent() != null; |
| 550 | case CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES: |
| 551 | return parentCompleteComponentTypes != null && !parentCompleteComponentTypes.isEmpty(); |
| 552 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 553 | return componentParameterUsage_ImplementationComponentType != null && !componentParameterUsage_ImplementationComponentType.isEmpty(); |
| 554 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: |
| 555 | return componentType != COMPONENT_TYPE_EDEFAULT; |
| 556 | } |
| 557 | return super.eIsSet(featureID); |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * <!-- begin-user-doc --> |
| 562 | * <!-- end-user-doc --> |
| 563 | * @generated |
| 564 | */ |
| 565 | @Override |
| 566 | public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| 567 | if (baseClass == RepositoryComponent.class) { |
| 568 | switch (derivedFeatureID) { |
| 569 | case CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT: return RepositoryPackage.REPOSITORY_COMPONENT__REPOSITORY_REPOSITORY_COMPONENT; |
| 570 | default: return -1; |
| 571 | } |
| 572 | } |
| 573 | if (baseClass == ImplementationComponentType.class) { |
| 574 | switch (derivedFeatureID) { |
| 575 | case CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES: return RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__PARENT_COMPLETE_COMPONENT_TYPES; |
| 576 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: return RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE; |
| 577 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: return RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_TYPE; |
| 578 | default: return -1; |
| 579 | } |
| 580 | } |
| 581 | return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * <!-- begin-user-doc --> |
| 586 | * <!-- end-user-doc --> |
| 587 | * @generated |
| 588 | */ |
| 589 | @Override |
| 590 | public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| 591 | if (baseClass == RepositoryComponent.class) { |
| 592 | switch (baseFeatureID) { |
| 593 | case RepositoryPackage.REPOSITORY_COMPONENT__REPOSITORY_REPOSITORY_COMPONENT: return CompletionsPackage.COMPLETION__REPOSITORY_REPOSITORY_COMPONENT; |
| 594 | default: return -1; |
| 595 | } |
| 596 | } |
| 597 | if (baseClass == ImplementationComponentType.class) { |
| 598 | switch (baseFeatureID) { |
| 599 | case RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__PARENT_COMPLETE_COMPONENT_TYPES: return CompletionsPackage.COMPLETION__PARENT_COMPLETE_COMPONENT_TYPES; |
| 600 | case RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: return CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE; |
| 601 | case RepositoryPackage.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_TYPE: return CompletionsPackage.COMPLETION__COMPONENT_TYPE; |
| 602 | default: return -1; |
| 603 | } |
| 604 | } |
| 605 | return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * <!-- begin-user-doc --> |
| 610 | * <!-- end-user-doc --> |
| 611 | * @generated |
| 612 | */ |
| 613 | @Override |
| 614 | public String toString() { |
| 615 | if (eIsProxy()) return super.toString(); |
| 616 | |
| 617 | StringBuffer result = new StringBuffer(super.toString()); |
| 618 | result.append(" (componentType: "); |
| 619 | result.append(componentType); |
| 620 | result.append(')'); |
| 621 | return result.toString(); |
| 622 | } |
| 623 | |
| 624 | } //CompletionImpl |