| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.seff.seff_reliability.impl; |
| 7 | |
| 8 | import de.uka.ipd.sdq.pcm.seff.impl.AbstractInternalControlFlowActionImpl; |
| 9 | |
| 10 | import de.uka.ipd.sdq.pcm.seff.seff_reliability.RecoveryAction; |
| 11 | import de.uka.ipd.sdq.pcm.seff.seff_reliability.RecoveryActionBehaviour; |
| 12 | import de.uka.ipd.sdq.pcm.seff.seff_reliability.Seff_reliabilityPackage; |
| 13 | |
| 14 | import de.uka.ipd.sdq.pcm.seff.seff_reliability.util.Seff_reliabilityValidator; |
| 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 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 32 | |
| 33 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| 34 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 35 | import org.eclipse.emf.ecore.util.InternalEList; |
| 36 | |
| 37 | import org.eclipse.ocl.ParserException; |
| 38 | |
| 39 | import org.eclipse.ocl.ecore.Constraint; |
| 40 | import org.eclipse.ocl.ecore.OCL; |
| 41 | |
| 42 | /** |
| 43 | * <!-- begin-user-doc --> |
| 44 | * An implementation of the model object '<em><b>Recovery Action</b></em>'. |
| 45 | * <!-- end-user-doc --> |
| 46 | * <p> |
| 47 | * The following features are implemented: |
| 48 | * <ul> |
| 49 | * <li>{@link de.uka.ipd.sdq.pcm.seff.seff_reliability.impl.RecoveryActionImpl#getPrimaryBehaviour__RecoveryAction <em>Primary Behaviour Recovery Action</em>}</li> |
| 50 | * <li>{@link de.uka.ipd.sdq.pcm.seff.seff_reliability.impl.RecoveryActionImpl#getRecoveryActionBehaviours__RecoveryAction <em>Recovery Action Behaviours Recovery Action</em>}</li> |
| 51 | * </ul> |
| 52 | * </p> |
| 53 | * |
| 54 | * @generated |
| 55 | */ |
| 56 | public class RecoveryActionImpl extends AbstractInternalControlFlowActionImpl implements RecoveryAction { |
| 57 | /** |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @generated |
| 61 | */ |
| 62 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 63 | |
| 64 | /** |
| 65 | * The cached value of the '{@link #getPrimaryBehaviour__RecoveryAction() <em>Primary Behaviour Recovery Action</em>}' reference. |
| 66 | * <!-- begin-user-doc --> |
| 67 | * <!-- end-user-doc --> |
| 68 | * @see #getPrimaryBehaviour__RecoveryAction() |
| 69 | * @generated |
| 70 | * @ordered |
| 71 | */ |
| 72 | protected RecoveryActionBehaviour primaryBehaviour__RecoveryAction; |
| 73 | |
| 74 | /** |
| 75 | * The cached value of the '{@link #getRecoveryActionBehaviours__RecoveryAction() <em>Recovery Action Behaviours Recovery Action</em>}' containment reference list. |
| 76 | * <!-- begin-user-doc --> |
| 77 | * <!-- end-user-doc --> |
| 78 | * @see #getRecoveryActionBehaviours__RecoveryAction() |
| 79 | * @generated |
| 80 | * @ordered |
| 81 | */ |
| 82 | protected EList<RecoveryActionBehaviour> recoveryActionBehaviours__RecoveryAction; |
| 83 | |
| 84 | /** |
| 85 | * <!-- begin-user-doc --> |
| 86 | * <!-- end-user-doc --> |
| 87 | * @generated |
| 88 | */ |
| 89 | protected RecoveryActionImpl() { |
| 90 | super(); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * <!-- begin-user-doc --> |
| 95 | * <!-- end-user-doc --> |
| 96 | * @generated |
| 97 | */ |
| 98 | @Override |
| 99 | protected EClass eStaticClass() { |
| 100 | return Seff_reliabilityPackage.Literals.RECOVERY_ACTION; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * <!-- begin-user-doc --> |
| 105 | * <!-- end-user-doc --> |
| 106 | * @generated |
| 107 | */ |
| 108 | public RecoveryActionBehaviour getPrimaryBehaviour__RecoveryAction() { |
| 109 | if (primaryBehaviour__RecoveryAction != null && primaryBehaviour__RecoveryAction.eIsProxy()) { |
| 110 | InternalEObject oldPrimaryBehaviour__RecoveryAction = (InternalEObject)primaryBehaviour__RecoveryAction; |
| 111 | primaryBehaviour__RecoveryAction = (RecoveryActionBehaviour)eResolveProxy(oldPrimaryBehaviour__RecoveryAction); |
| 112 | if (primaryBehaviour__RecoveryAction != oldPrimaryBehaviour__RecoveryAction) { |
| 113 | if (eNotificationRequired()) |
| 114 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION, oldPrimaryBehaviour__RecoveryAction, primaryBehaviour__RecoveryAction)); |
| 115 | } |
| 116 | } |
| 117 | return primaryBehaviour__RecoveryAction; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * <!-- begin-user-doc --> |
| 122 | * <!-- end-user-doc --> |
| 123 | * @generated |
| 124 | */ |
| 125 | public RecoveryActionBehaviour basicGetPrimaryBehaviour__RecoveryAction() { |
| 126 | return primaryBehaviour__RecoveryAction; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * <!-- begin-user-doc --> |
| 131 | * <!-- end-user-doc --> |
| 132 | * @generated |
| 133 | */ |
| 134 | public void setPrimaryBehaviour__RecoveryAction(RecoveryActionBehaviour newPrimaryBehaviour__RecoveryAction) { |
| 135 | RecoveryActionBehaviour oldPrimaryBehaviour__RecoveryAction = primaryBehaviour__RecoveryAction; |
| 136 | primaryBehaviour__RecoveryAction = newPrimaryBehaviour__RecoveryAction; |
| 137 | if (eNotificationRequired()) |
| 138 | eNotify(new ENotificationImpl(this, Notification.SET, Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION, oldPrimaryBehaviour__RecoveryAction, primaryBehaviour__RecoveryAction)); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | public EList<RecoveryActionBehaviour> getRecoveryActionBehaviours__RecoveryAction() { |
| 147 | if (recoveryActionBehaviours__RecoveryAction == null) { |
| 148 | recoveryActionBehaviours__RecoveryAction = new EObjectContainmentWithInverseEList<RecoveryActionBehaviour>(RecoveryActionBehaviour.class, this, Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION, Seff_reliabilityPackage.RECOVERY_ACTION_BEHAVIOUR__RECOVERY_ACTION_RECOVERY_ACTION_BEHAVIOUR); |
| 149 | } |
| 150 | return recoveryActionBehaviours__RecoveryAction; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * The cached OCL expression body for the '{@link #PrimaryBehaviourOfRecoveryActionMustBeSet(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Primary Behaviour Of Recovery Action Must Be Set</em>}' operation. |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @see #PrimaryBehaviourOfRecoveryActionMustBeSet(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 158 | * @generated |
| 159 | * @ordered |
| 160 | */ |
| 161 | protected static final String PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.primaryBehaviour__RecoveryAction <> null"; |
| 162 | |
| 163 | /** |
| 164 | * The cached OCL invariant for the '{@link #PrimaryBehaviourOfRecoveryActionMustBeSet(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Primary Behaviour Of Recovery Action Must Be Set</em>}' invariant operation. |
| 165 | * <!-- begin-user-doc --> |
| 166 | * <!-- end-user-doc --> |
| 167 | * @see #PrimaryBehaviourOfRecoveryActionMustBeSet(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 168 | * @generated |
| 169 | * @ordered |
| 170 | */ |
| 171 | protected static Constraint PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 172 | |
| 173 | /** |
| 174 | * <!-- begin-user-doc --> |
| 175 | * <!-- end-user-doc --> |
| 176 | * @generated |
| 177 | */ |
| 178 | public boolean PrimaryBehaviourOfRecoveryActionMustBeSet(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 179 | if (PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 180 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 181 | helper.setContext(Seff_reliabilityPackage.Literals.RECOVERY_ACTION); |
| 182 | try { |
| 183 | PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 184 | } |
| 185 | catch (ParserException pe) { |
| 186 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 187 | } |
| 188 | } |
| 189 | if (!EOCL_ENV.createQuery(PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 190 | if (diagnostics != null) { |
| 191 | diagnostics.add |
| 192 | (new BasicDiagnostic |
| 193 | (Diagnostic.ERROR, |
| 194 | Seff_reliabilityValidator.DIAGNOSTIC_SOURCE, |
| 195 | Seff_reliabilityValidator.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_OF_RECOVERY_ACTION_MUST_BE_SET, |
| 196 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "PrimaryBehaviourOfRecoveryActionMustBeSet", EObjectValidator.getObjectLabel(this, context) }), |
| 197 | new Object [] { this })); |
| 198 | } |
| 199 | return false; |
| 200 | } |
| 201 | return true; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * <!-- begin-user-doc --> |
| 206 | * <!-- end-user-doc --> |
| 207 | * @generated |
| 208 | */ |
| 209 | @SuppressWarnings("unchecked") |
| 210 | @Override |
| 211 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 212 | switch (featureID) { |
| 213 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 214 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getRecoveryActionBehaviours__RecoveryAction()).basicAdd(otherEnd, msgs); |
| 215 | } |
| 216 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * <!-- begin-user-doc --> |
| 221 | * <!-- end-user-doc --> |
| 222 | * @generated |
| 223 | */ |
| 224 | @Override |
| 225 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 226 | switch (featureID) { |
| 227 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 228 | return ((InternalEList<?>)getRecoveryActionBehaviours__RecoveryAction()).basicRemove(otherEnd, msgs); |
| 229 | } |
| 230 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * <!-- begin-user-doc --> |
| 235 | * <!-- end-user-doc --> |
| 236 | * @generated |
| 237 | */ |
| 238 | @Override |
| 239 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 240 | switch (featureID) { |
| 241 | case Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION: |
| 242 | if (resolve) return getPrimaryBehaviour__RecoveryAction(); |
| 243 | return basicGetPrimaryBehaviour__RecoveryAction(); |
| 244 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 245 | return getRecoveryActionBehaviours__RecoveryAction(); |
| 246 | } |
| 247 | return super.eGet(featureID, resolve, coreType); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * <!-- begin-user-doc --> |
| 252 | * <!-- end-user-doc --> |
| 253 | * @generated |
| 254 | */ |
| 255 | @SuppressWarnings("unchecked") |
| 256 | @Override |
| 257 | public void eSet(int featureID, Object newValue) { |
| 258 | switch (featureID) { |
| 259 | case Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION: |
| 260 | setPrimaryBehaviour__RecoveryAction((RecoveryActionBehaviour)newValue); |
| 261 | return; |
| 262 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 263 | getRecoveryActionBehaviours__RecoveryAction().clear(); |
| 264 | getRecoveryActionBehaviours__RecoveryAction().addAll((Collection<? extends RecoveryActionBehaviour>)newValue); |
| 265 | return; |
| 266 | } |
| 267 | super.eSet(featureID, newValue); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * <!-- begin-user-doc --> |
| 272 | * <!-- end-user-doc --> |
| 273 | * @generated |
| 274 | */ |
| 275 | @Override |
| 276 | public void eUnset(int featureID) { |
| 277 | switch (featureID) { |
| 278 | case Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION: |
| 279 | setPrimaryBehaviour__RecoveryAction((RecoveryActionBehaviour)null); |
| 280 | return; |
| 281 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 282 | getRecoveryActionBehaviours__RecoveryAction().clear(); |
| 283 | return; |
| 284 | } |
| 285 | super.eUnset(featureID); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * <!-- begin-user-doc --> |
| 290 | * <!-- end-user-doc --> |
| 291 | * @generated |
| 292 | */ |
| 293 | @Override |
| 294 | public boolean eIsSet(int featureID) { |
| 295 | switch (featureID) { |
| 296 | case Seff_reliabilityPackage.RECOVERY_ACTION__PRIMARY_BEHAVIOUR_RECOVERY_ACTION: |
| 297 | return primaryBehaviour__RecoveryAction != null; |
| 298 | case Seff_reliabilityPackage.RECOVERY_ACTION__RECOVERY_ACTION_BEHAVIOURS_RECOVERY_ACTION: |
| 299 | return recoveryActionBehaviours__RecoveryAction != null && !recoveryActionBehaviours__RecoveryAction.isEmpty(); |
| 300 | } |
| 301 | return super.eIsSet(featureID); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * The cached environment for evaluating OCL expressions. |
| 306 | * <!-- begin-user-doc --> |
| 307 | * <!-- end-user-doc --> |
| 308 | * @generated |
| 309 | * @ordered |
| 310 | */ |
| 311 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
| 312 | |
| 313 | } //RecoveryActionImpl |