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.OperationInterface; |
27 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
28 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
29 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
30 | |
31 | /** |
32 | * <!-- begin-user-doc --> |
33 | * An implementation of the model object '<em><b>Operation Interface</b></em>'. |
34 | * <!-- end-user-doc --> |
35 | * <p> |
36 | * The following features are implemented: |
37 | * <ul> |
38 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.OperationInterfaceImpl#getSignatures__OperationInterface <em>Signatures Operation Interface</em>}</li> |
39 | * </ul> |
40 | * </p> |
41 | * |
42 | * @generated |
43 | */ |
44 | public class OperationInterfaceImpl extends InterfaceImpl implements OperationInterface { |
45 | /** |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @generated |
49 | */ |
50 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
51 | |
52 | /** |
53 | * The cached value of the '{@link #getSignatures__OperationInterface() <em>Signatures Operation Interface</em>}' containment reference list. |
54 | * <!-- begin-user-doc --> |
55 | * <!-- end-user-doc --> |
56 | * @see #getSignatures__OperationInterface() |
57 | * @generated |
58 | * @ordered |
59 | */ |
60 | protected EList<OperationSignature> signatures__OperationInterface; |
61 | |
62 | /** |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @generated |
66 | */ |
67 | protected OperationInterfaceImpl() { |
68 | super(); |
69 | } |
70 | |
71 | /** |
72 | * <!-- begin-user-doc --> |
73 | * <!-- end-user-doc --> |
74 | * @generated |
75 | */ |
76 | @Override |
77 | protected EClass eStaticClass() { |
78 | return RepositoryPackage.Literals.OPERATION_INTERFACE; |
79 | } |
80 | |
81 | /** |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | public EList<OperationSignature> getSignatures__OperationInterface() { |
87 | if (signatures__OperationInterface == null) { |
88 | signatures__OperationInterface = new EObjectContainmentWithInverseEList<OperationSignature>(OperationSignature.class, this, RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE, RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE); |
89 | } |
90 | return signatures__OperationInterface; |
91 | } |
92 | |
93 | /** |
94 | * The cached OCL expression body for the '{@link #SignaturesHaveToBeUniqueForAnInterface(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Signatures Have To Be Unique For An Interface</em>}' operation. |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @see #SignaturesHaveToBeUniqueForAnInterface(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
98 | * @generated |
99 | * @ordered |
100 | */ |
101 | protected static final String SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "-- full signature has to be unique \n"+"-- (use of ocl-tupels) #\n"+"let sigs : Bag(\n"+" -- parameters: Sequence of DataType, NOT name #\n"+" -- exceptions have not to be considered #\n"+" Tuple(returnType : DataType, serviceName : String, parameters : Sequence(DataType) ) \n"+") = \n"+"self.signatures__OperationInterface->collect(sig : OperationSignature |\n"+" Tuple{\n"+" returnType : DataType = sig.returnType__OperationSignature,\n"+" serviceName : String = sig.entityName,\n"+" parameters : Sequence(DataType) = sig.parameters__OperationSignature.dataType__Parameter\n"+" }\n"+")\n"+"in\n"+"sigs->isUnique(s|s)"; |
102 | |
103 | /** |
104 | * The cached OCL invariant for the '{@link #SignaturesHaveToBeUniqueForAnInterface(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Signatures Have To Be Unique For An Interface</em>}' invariant operation. |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @see #SignaturesHaveToBeUniqueForAnInterface(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
108 | * @generated |
109 | * @ordered |
110 | */ |
111 | protected static Constraint SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
112 | |
113 | /** |
114 | * <!-- begin-user-doc --> |
115 | * <!-- end-user-doc --> |
116 | * @generated |
117 | */ |
118 | public boolean SignaturesHaveToBeUniqueForAnInterface(DiagnosticChain diagnostics, Map<Object, Object> context) { |
119 | if (SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
120 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
121 | helper.setContext(RepositoryPackage.Literals.OPERATION_INTERFACE); |
122 | try { |
123 | SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
124 | } |
125 | catch (ParserException pe) { |
126 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
127 | } |
128 | } |
129 | if (!EOCL_ENV.createQuery(SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
130 | if (diagnostics != null) { |
131 | diagnostics.add |
132 | (new BasicDiagnostic |
133 | (Diagnostic.ERROR, |
134 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
135 | RepositoryValidator.OPERATION_INTERFACE__SIGNATURES_HAVE_TO_BE_UNIQUE_FOR_AN_INTERFACE, |
136 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "SignaturesHaveToBeUniqueForAnInterface", EObjectValidator.getObjectLabel(this, context) }), |
137 | new Object [] { this })); |
138 | } |
139 | return false; |
140 | } |
141 | return true; |
142 | } |
143 | |
144 | /** |
145 | * <!-- begin-user-doc --> |
146 | * <!-- end-user-doc --> |
147 | * @generated |
148 | */ |
149 | @SuppressWarnings("unchecked") |
150 | @Override |
151 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
152 | switch (featureID) { |
153 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
154 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getSignatures__OperationInterface()).basicAdd(otherEnd, msgs); |
155 | } |
156 | return super.eInverseAdd(otherEnd, featureID, msgs); |
157 | } |
158 | |
159 | /** |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
166 | switch (featureID) { |
167 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
168 | return ((InternalEList<?>)getSignatures__OperationInterface()).basicRemove(otherEnd, msgs); |
169 | } |
170 | return super.eInverseRemove(otherEnd, featureID, msgs); |
171 | } |
172 | |
173 | /** |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | @Override |
179 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
180 | switch (featureID) { |
181 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
182 | return getSignatures__OperationInterface(); |
183 | } |
184 | return super.eGet(featureID, resolve, coreType); |
185 | } |
186 | |
187 | /** |
188 | * <!-- begin-user-doc --> |
189 | * <!-- end-user-doc --> |
190 | * @generated |
191 | */ |
192 | @SuppressWarnings("unchecked") |
193 | @Override |
194 | public void eSet(int featureID, Object newValue) { |
195 | switch (featureID) { |
196 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
197 | getSignatures__OperationInterface().clear(); |
198 | getSignatures__OperationInterface().addAll((Collection<? extends OperationSignature>)newValue); |
199 | return; |
200 | } |
201 | super.eSet(featureID, newValue); |
202 | } |
203 | |
204 | /** |
205 | * <!-- begin-user-doc --> |
206 | * <!-- end-user-doc --> |
207 | * @generated |
208 | */ |
209 | @Override |
210 | public void eUnset(int featureID) { |
211 | switch (featureID) { |
212 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
213 | getSignatures__OperationInterface().clear(); |
214 | return; |
215 | } |
216 | super.eUnset(featureID); |
217 | } |
218 | |
219 | /** |
220 | * <!-- begin-user-doc --> |
221 | * <!-- end-user-doc --> |
222 | * @generated |
223 | */ |
224 | @Override |
225 | public boolean eIsSet(int featureID) { |
226 | switch (featureID) { |
227 | case RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE: |
228 | return signatures__OperationInterface != null && !signatures__OperationInterface.isEmpty(); |
229 | } |
230 | return super.eIsSet(featureID); |
231 | } |
232 | |
233 | } //OperationInterfaceImpl |