1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.reliability.impl; |
7 | |
8 | |
9 | import java.util.Map; |
10 | |
11 | import org.eclipse.emf.common.notify.Notification; |
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.ecore.EClass; |
16 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
17 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
18 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
19 | import org.eclipse.emf.ecore.util.EObjectValidator; |
20 | import org.eclipse.ocl.ParserException; |
21 | import org.eclipse.ocl.ecore.Constraint; |
22 | import org.eclipse.ocl.ecore.OCL; |
23 | |
24 | import de.uka.ipd.sdq.pcm.reliability.FailureOccurrenceDescription; |
25 | import de.uka.ipd.sdq.pcm.reliability.ReliabilityPackage; |
26 | import de.uka.ipd.sdq.pcm.reliability.util.ReliabilityValidator; |
27 | |
28 | /** |
29 | * <!-- begin-user-doc --> |
30 | * An implementation of the model object '<em><b>Failure Occurrence Description</b></em>'. |
31 | * <!-- end-user-doc --> |
32 | * <p> |
33 | * The following features are implemented: |
34 | * <ul> |
35 | * <li>{@link de.uka.ipd.sdq.pcm.reliability.impl.FailureOccurrenceDescriptionImpl#getFailureProbability <em>Failure Probability</em>}</li> |
36 | * </ul> |
37 | * </p> |
38 | * |
39 | * @generated |
40 | */ |
41 | public abstract class FailureOccurrenceDescriptionImpl extends EObjectImpl implements FailureOccurrenceDescription { |
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 default value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute. |
51 | * <!-- begin-user-doc --> |
52 | * <!-- end-user-doc --> |
53 | * @see #getFailureProbability() |
54 | * @generated |
55 | * @ordered |
56 | */ |
57 | protected static final double FAILURE_PROBABILITY_EDEFAULT = 0.0; |
58 | |
59 | /** |
60 | * The cached value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute. |
61 | * <!-- begin-user-doc --> |
62 | * <!-- end-user-doc --> |
63 | * @see #getFailureProbability() |
64 | * @generated |
65 | * @ordered |
66 | */ |
67 | protected double failureProbability = FAILURE_PROBABILITY_EDEFAULT; |
68 | |
69 | /** |
70 | * <!-- begin-user-doc --> |
71 | * <!-- end-user-doc --> |
72 | * @generated |
73 | */ |
74 | protected FailureOccurrenceDescriptionImpl() { |
75 | super(); |
76 | } |
77 | |
78 | /** |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | @Override |
84 | protected EClass eStaticClass() { |
85 | return ReliabilityPackage.Literals.FAILURE_OCCURRENCE_DESCRIPTION; |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | public double getFailureProbability() { |
94 | return failureProbability; |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | public void setFailureProbability(double newFailureProbability) { |
103 | double oldFailureProbability = failureProbability; |
104 | failureProbability = newFailureProbability; |
105 | if (eNotificationRequired()) |
106 | eNotify(new ENotificationImpl(this, Notification.SET, ReliabilityPackage.FAILURE_OCCURRENCE_DESCRIPTION__FAILURE_PROBABILITY, oldFailureProbability, failureProbability)); |
107 | } |
108 | |
109 | /** |
110 | * The cached OCL expression body for the '{@link #EnsureValidFailureProbabilityRange(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Ensure Valid Failure Probability Range</em>}' operation. |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @see #EnsureValidFailureProbabilityRange(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
114 | * @generated |
115 | * @ordered |
116 | */ |
117 | protected static final String ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "(self.failureProbability.oclAsType(Real) <= 1.0) and (self.failureProbability.oclAsType(Real) >= 0.0)"; |
118 | |
119 | /** |
120 | * The cached OCL invariant for the '{@link #EnsureValidFailureProbabilityRange(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Ensure Valid Failure Probability Range</em>}' invariant operation. |
121 | * <!-- begin-user-doc --> |
122 | * <!-- end-user-doc --> |
123 | * @see #EnsureValidFailureProbabilityRange(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
124 | * @generated |
125 | * @ordered |
126 | */ |
127 | protected static Constraint ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
128 | |
129 | /** |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @generated |
133 | */ |
134 | public boolean EnsureValidFailureProbabilityRange(DiagnosticChain diagnostics, Map<Object, Object> context) { |
135 | if (ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
136 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
137 | helper.setContext(ReliabilityPackage.Literals.FAILURE_OCCURRENCE_DESCRIPTION); |
138 | try { |
139 | ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
140 | } |
141 | catch (ParserException pe) { |
142 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
143 | } |
144 | } |
145 | if (!EOCL_ENV.createQuery(ENSURE_VALID_FAILURE_PROBABILITY_RANGE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
146 | if (diagnostics != null) { |
147 | diagnostics.add |
148 | (new BasicDiagnostic |
149 | (Diagnostic.ERROR, |
150 | ReliabilityValidator.DIAGNOSTIC_SOURCE, |
151 | ReliabilityValidator.FAILURE_OCCURRENCE_DESCRIPTION__ENSURE_VALID_FAILURE_PROBABILITY_RANGE, |
152 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "EnsureValidFailureProbabilityRange", EObjectValidator.getObjectLabel(this, context) }), |
153 | new Object [] { this })); |
154 | } |
155 | return false; |
156 | } |
157 | return true; |
158 | } |
159 | |
160 | /** |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | @Override |
166 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
167 | switch (featureID) { |
168 | case ReliabilityPackage.FAILURE_OCCURRENCE_DESCRIPTION__FAILURE_PROBABILITY: |
169 | return getFailureProbability(); |
170 | } |
171 | return super.eGet(featureID, resolve, coreType); |
172 | } |
173 | |
174 | /** |
175 | * <!-- begin-user-doc --> |
176 | * <!-- end-user-doc --> |
177 | * @generated |
178 | */ |
179 | @Override |
180 | public void eSet(int featureID, Object newValue) { |
181 | switch (featureID) { |
182 | case ReliabilityPackage.FAILURE_OCCURRENCE_DESCRIPTION__FAILURE_PROBABILITY: |
183 | setFailureProbability((Double)newValue); |
184 | return; |
185 | } |
186 | super.eSet(featureID, newValue); |
187 | } |
188 | |
189 | /** |
190 | * <!-- begin-user-doc --> |
191 | * <!-- end-user-doc --> |
192 | * @generated |
193 | */ |
194 | @Override |
195 | public void eUnset(int featureID) { |
196 | switch (featureID) { |
197 | case ReliabilityPackage.FAILURE_OCCURRENCE_DESCRIPTION__FAILURE_PROBABILITY: |
198 | setFailureProbability(FAILURE_PROBABILITY_EDEFAULT); |
199 | return; |
200 | } |
201 | super.eUnset(featureID); |
202 | } |
203 | |
204 | /** |
205 | * <!-- begin-user-doc --> |
206 | * <!-- end-user-doc --> |
207 | * @generated |
208 | */ |
209 | @Override |
210 | public boolean eIsSet(int featureID) { |
211 | switch (featureID) { |
212 | case ReliabilityPackage.FAILURE_OCCURRENCE_DESCRIPTION__FAILURE_PROBABILITY: |
213 | return failureProbability != FAILURE_PROBABILITY_EDEFAULT; |
214 | } |
215 | return super.eIsSet(featureID); |
216 | } |
217 | |
218 | /** |
219 | * <!-- begin-user-doc --> |
220 | * <!-- end-user-doc --> |
221 | * @generated |
222 | */ |
223 | @Override |
224 | public String toString() { |
225 | if (eIsProxy()) return super.toString(); |
226 | |
227 | StringBuffer result = new StringBuffer(super.toString()); |
228 | result.append(" (failureProbability: "); |
229 | result.append(failureProbability); |
230 | result.append(')'); |
231 | return result.toString(); |
232 | } |
233 | |
234 | /** |
235 | * The cached environment for evaluating OCL expressions. |
236 | * <!-- begin-user-doc --> |
237 | * <!-- end-user-doc --> |
238 | * @generated |
239 | * @ordered |
240 | */ |
241 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
242 | |
243 | } //FailureOccurrenceDescriptionImpl |