| 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.util.BasicDiagnostic; |
| 12 | import org.eclipse.emf.common.util.Diagnostic; |
| 13 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 14 | import org.eclipse.emf.common.util.EList; |
| 15 | import org.eclipse.emf.ecore.EClass; |
| 16 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 17 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| 18 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 19 | import org.eclipse.ocl.ParserException; |
| 20 | import org.eclipse.ocl.ecore.Constraint; |
| 21 | import org.eclipse.ocl.ecore.OCL; |
| 22 | |
| 23 | import de.uka.ipd.sdq.pcm.repository.CompleteComponentType; |
| 24 | import de.uka.ipd.sdq.pcm.repository.ProvidesComponentType; |
| 25 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 26 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
| 27 | |
| 28 | /** |
| 29 | * <!-- begin-user-doc --> |
| 30 | * An implementation of the model object '<em><b>Complete Component Type</b></em>'. |
| 31 | * <!-- end-user-doc --> |
| 32 | * <p> |
| 33 | * The following features are implemented: |
| 34 | * <ul> |
| 35 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.CompleteComponentTypeImpl#getParentProvidesComponentTypes <em>Parent Provides Component Types</em>}</li> |
| 36 | * </ul> |
| 37 | * </p> |
| 38 | * |
| 39 | * @generated |
| 40 | */ |
| 41 | public class CompleteComponentTypeImpl extends RepositoryComponentImpl implements CompleteComponentType { |
| 42 | /** |
| 43 | * <!-- begin-user-doc --> |
| 44 | * <!-- end-user-doc --> |
| 45 | * @generated |
| 46 | */ |
| 47 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 48 | |
| 49 | /** |
| 50 | * The cached value of the '{@link #getParentProvidesComponentTypes() <em>Parent Provides Component Types</em>}' reference list. |
| 51 | * <!-- begin-user-doc --> |
| 52 | * <!-- end-user-doc --> |
| 53 | * @see #getParentProvidesComponentTypes() |
| 54 | * @generated |
| 55 | * @ordered |
| 56 | */ |
| 57 | protected EList<ProvidesComponentType> parentProvidesComponentTypes; |
| 58 | |
| 59 | /** |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @generated |
| 63 | */ |
| 64 | protected CompleteComponentTypeImpl() { |
| 65 | super(); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * <!-- begin-user-doc --> |
| 70 | * <!-- end-user-doc --> |
| 71 | * @generated |
| 72 | */ |
| 73 | @Override |
| 74 | protected EClass eStaticClass() { |
| 75 | return RepositoryPackage.Literals.COMPLETE_COMPONENT_TYPE; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | public EList<ProvidesComponentType> getParentProvidesComponentTypes() { |
| 84 | if (parentProvidesComponentTypes == null) { |
| 85 | parentProvidesComponentTypes = new EObjectResolvingEList<ProvidesComponentType>(ProvidesComponentType.class, this, RepositoryPackage.COMPLETE_COMPONENT_TYPE__PARENT_PROVIDES_COMPONENT_TYPES); |
| 86 | } |
| 87 | return parentProvidesComponentTypes; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * The cached OCL expression body for the '{@link #AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>At Least One Interface Has To Be Provided Or Required By AUsefull Complete Component Type</em>}' operation. |
| 92 | * <!-- begin-user-doc --> |
| 93 | * <!-- end-user-doc --> |
| 94 | * @see #AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 95 | * @generated |
| 96 | * @ordered |
| 97 | */ |
| 98 | protected static final String AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "(\n"+" self.oclIsTypeOf(CompleteComponentType)\n"+" or\n"+" self.oclIsTypeOf(ImplementationComponentType)\n"+" or\n"+" self.oclIsTypeOf(CompositeComponent)\n"+" or\n"+" self.oclIsTypeOf(BasicComponent)\n"+")\n"+"implies\n"+"(\n"+" self.providedRoles_InterfaceProvidingEntity->size() >= 1\n"+" or\n"+" self.requiredRoles_InterfaceRequiringEntity->size() >= 1\n"+")"; |
| 99 | |
| 100 | /** |
| 101 | * The cached OCL invariant for the '{@link #AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>At Least One Interface Has To Be Provided Or Required By AUsefull Complete Component Type</em>}' invariant operation. |
| 102 | * <!-- begin-user-doc --> |
| 103 | * <!-- end-user-doc --> |
| 104 | * @see #AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 105 | * @generated |
| 106 | * @ordered |
| 107 | */ |
| 108 | protected static Constraint AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 109 | |
| 110 | /** |
| 111 | * <!-- begin-user-doc --> |
| 112 | * <!-- end-user-doc --> |
| 113 | * @generated |
| 114 | */ |
| 115 | public boolean AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 116 | if (AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 117 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 118 | helper.setContext(RepositoryPackage.Literals.COMPLETE_COMPONENT_TYPE); |
| 119 | try { |
| 120 | AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 121 | } |
| 122 | catch (ParserException pe) { |
| 123 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 124 | } |
| 125 | } |
| 126 | if (!EOCL_ENV.createQuery(AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 127 | if (diagnostics != null) { |
| 128 | diagnostics.add |
| 129 | (new BasicDiagnostic |
| 130 | (Diagnostic.ERROR, |
| 131 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 132 | RepositoryValidator.COMPLETE_COMPONENT_TYPE__AT_LEAST_ONE_INTERFACE_HAS_TO_BE_PROVIDED_OR_REQUIRED_BY_AUSEFULL_COMPLETE_COMPONENT_TYPE, |
| 133 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "AtLeastOneInterfaceHasToBeProvidedOrRequiredByAUsefullCompleteComponentType", EObjectValidator.getObjectLabel(this, context) }), |
| 134 | new Object [] { this })); |
| 135 | } |
| 136 | return false; |
| 137 | } |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * The cached OCL expression body for the '{@link #providedInterfacesHaveToConformToProvidedType2(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interfaces Have To Conform To Provided Type2</em>}' operation. |
| 143 | * <!-- begin-user-doc --> |
| 144 | * <!-- end-user-doc --> |
| 145 | * @see #providedInterfacesHaveToConformToProvidedType2(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 146 | * @generated |
| 147 | * @ordered |
| 148 | */ |
| 149 | protected static final String PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- CompleteTypes provided Interfaces have to be a superset\n"+"-- of ProvidesComponentType provided Interfaces #\n"+"--\n"+"-- ACCx are used to accumulate Sets/Bags; usually only the very inner ACCx is used at all.\n"+"--\n"+"-- Recursive Query for parent Interface IDs\n"+"-- see 'lpar2005.pdf' (Second-order principles in specification languages for Object-Oriented Programs; Beckert, Tretelman) pp. 11 #\n"+"--let parentInterfaces : Bag(Interface) =\n"+"-- self.providedRoles->iterate(r : ProvidedRole; acc2 : Bag(Interface) = Bag{} |\n"+"-- acc2->union(r.providedInterface.parentInterface->asBag()) -- asBag required to allow Set operations #\n"+"-- ) in\n"+"--let anchestorInterfaces : Bag(Interface) =\n"+"-- self.providedRoles->iterate(r : ProvidedRole; acc4 : Bag(Interface) = Bag{} |\n"+"-- acc4->union(r.providedInterface.parentInterface->asBag()) -- asBag required to allow Set operations #\n"+"-- )->union( -- union with anchestors found in former recursion #\n"+"-- self.providedRoles->iterate(r : ProvidedRole; acc6 : Bag(Interface) = Bag{} |\n"+"-- acc6->union(r.providedInterface.parentInterface.anchestorInterfaces) --already Set/Bag\n"+"-- )\n"+"-- ) in\n"+"-- -- Directly provided anchestorInterfaces need to be a superset of provided interfaces of Supertype #\n"+"-- anchestorInterfaces.identifier.id->includesAll(\n"+"-- self.parentProvidesComponentTypes->iterate(pt : ProvidesComponentType; acc1 : Bag(String) = Bag{} |\n"+"-- pt.providedRoles->iterate(r : ProvidedRole; acc2 : Bag(String) = Bag{} |\n"+"-- acc2->union(r.providedInterface.identifier.id->asBag()) -- asBag required to allow Set operations #\n"+"-- )\n"+"-- )\n"+"-- )\n"+"true"; |
| 150 | |
| 151 | /** |
| 152 | * The cached OCL invariant for the '{@link #providedInterfacesHaveToConformToProvidedType2(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Provided Interfaces Have To Conform To Provided Type2</em>}' invariant operation. |
| 153 | * <!-- begin-user-doc --> |
| 154 | * <!-- end-user-doc --> |
| 155 | * @see #providedInterfacesHaveToConformToProvidedType2(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 156 | * @generated |
| 157 | * @ordered |
| 158 | */ |
| 159 | protected static Constraint PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 160 | |
| 161 | /** |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | public boolean providedInterfacesHaveToConformToProvidedType2(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 167 | if (PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 168 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 169 | helper.setContext(RepositoryPackage.Literals.COMPLETE_COMPONENT_TYPE); |
| 170 | try { |
| 171 | PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 172 | } |
| 173 | catch (ParserException pe) { |
| 174 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 175 | } |
| 176 | } |
| 177 | if (!EOCL_ENV.createQuery(PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 178 | if (diagnostics != null) { |
| 179 | diagnostics.add |
| 180 | (new BasicDiagnostic |
| 181 | (Diagnostic.ERROR, |
| 182 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 183 | RepositoryValidator.COMPLETE_COMPONENT_TYPE__PROVIDED_INTERFACES_HAVE_TO_CONFORM_TO_PROVIDED_TYPE2, |
| 184 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "providedInterfacesHaveToConformToProvidedType2", EObjectValidator.getObjectLabel(this, context) }), |
| 185 | new Object [] { this })); |
| 186 | } |
| 187 | return false; |
| 188 | } |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * <!-- begin-user-doc --> |
| 194 | * <!-- end-user-doc --> |
| 195 | * @generated |
| 196 | */ |
| 197 | @Override |
| 198 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 199 | switch (featureID) { |
| 200 | case RepositoryPackage.COMPLETE_COMPONENT_TYPE__PARENT_PROVIDES_COMPONENT_TYPES: |
| 201 | return getParentProvidesComponentTypes(); |
| 202 | } |
| 203 | return super.eGet(featureID, resolve, coreType); |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * <!-- begin-user-doc --> |
| 208 | * <!-- end-user-doc --> |
| 209 | * @generated |
| 210 | */ |
| 211 | @SuppressWarnings("unchecked") |
| 212 | @Override |
| 213 | public void eSet(int featureID, Object newValue) { |
| 214 | switch (featureID) { |
| 215 | case RepositoryPackage.COMPLETE_COMPONENT_TYPE__PARENT_PROVIDES_COMPONENT_TYPES: |
| 216 | getParentProvidesComponentTypes().clear(); |
| 217 | getParentProvidesComponentTypes().addAll((Collection<? extends ProvidesComponentType>)newValue); |
| 218 | return; |
| 219 | } |
| 220 | super.eSet(featureID, newValue); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * <!-- begin-user-doc --> |
| 225 | * <!-- end-user-doc --> |
| 226 | * @generated |
| 227 | */ |
| 228 | @Override |
| 229 | public void eUnset(int featureID) { |
| 230 | switch (featureID) { |
| 231 | case RepositoryPackage.COMPLETE_COMPONENT_TYPE__PARENT_PROVIDES_COMPONENT_TYPES: |
| 232 | getParentProvidesComponentTypes().clear(); |
| 233 | return; |
| 234 | } |
| 235 | super.eUnset(featureID); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * <!-- begin-user-doc --> |
| 240 | * <!-- end-user-doc --> |
| 241 | * @generated |
| 242 | */ |
| 243 | @Override |
| 244 | public boolean eIsSet(int featureID) { |
| 245 | switch (featureID) { |
| 246 | case RepositoryPackage.COMPLETE_COMPONENT_TYPE__PARENT_PROVIDES_COMPONENT_TYPES: |
| 247 | return parentProvidesComponentTypes != null && !parentProvidesComponentTypes.isEmpty(); |
| 248 | } |
| 249 | return super.eIsSet(featureID); |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * The cached environment for evaluating OCL expressions. |
| 254 | * <!-- begin-user-doc --> |
| 255 | * <!-- end-user-doc --> |
| 256 | * @generated |
| 257 | * @ordered |
| 258 | */ |
| 259 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
| 260 | |
| 261 | } //CompleteComponentTypeImpl |