EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.fzi.se.accuracy.transformation]

COVERAGE SUMMARY FOR SOURCE FILE [AccuracyInfluenceSEFFTransformationStrategyMaximum.java]

nameclass, %method, %block, %line, %
AccuracyInfluenceSEFFTransformationStrategyMaximum.java0%   (0/1)0%   (0/11)0%   (0/466)0%   (0/99)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AccuracyInfluenceSEFFTransformationStrategyMaximum0%   (0/1)0%   (0/11)0%   (0/466)0%   (0/99)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/2)
AccuracyInfluenceSEFFTransformationStrategyMaximum (PCMResourceSetPartition):... 0%   (0/1)0%   (0/19)0%   (0/5)
copyFailureTypes (FailureHandlingEntity, FailureHandlingEntity): void 0%   (0/1)0%   (0/18)0%   (0/3)
copyInputVariableUsages (CallAction, CallAction): void 0%   (0/1)0%   (0/53)0%   (0/9)
copyReturnVariableUsage (CallReturnAction, CallReturnAction): void 0%   (0/1)0%   (0/53)0%   (0/9)
handleInputParametersOfCallAction (CallAction, REPrecision): void 0%   (0/1)0%   (0/36)0%   (0/5)
modifyComponentExternalCall (ExternalCallAction, REPrecision): void 0%   (0/1)0%   (0/105)0%   (0/26)
modifyComponentInternalCall (InternalCallAction, REPrecision): void 0%   (0/1)0%   (0/89)0%   (0/22)
modifyInfrastructureCall (InfrastructureCall, REPrecision): void 0%   (0/1)0%   (0/16)0%   (0/4)
modifyResourceCall (ResourceCall, REPrecision): void 0%   (0/1)0%   (0/47)0%   (0/7)
modifyResourceDemand (ParametricResourceDemand, REPrecision): void 0%   (0/1)0%   (0/26)0%   (0/7)

1/**
2 *
3 */
4package de.fzi.se.accuracy.transformation;
5 
6import org.apache.log4j.Logger;
7 
8import de.fzi.se.quality.qualityannotation.NoPrecision;
9import de.fzi.se.quality.qualityannotation.REPrecision;
10import de.fzi.se.quality.util.EcoreCopierCreatingNewIds;
11import de.uka.ipd.sdq.pcm.core.PCMRandomVariable;
12import de.uka.ipd.sdq.pcm.parameter.ParameterFactory;
13import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation;
14import de.uka.ipd.sdq.pcm.parameter.VariableUsage;
15import de.uka.ipd.sdq.pcm.reliability.FailureType;
16import de.uka.ipd.sdq.pcm.seff.AbstractAction;
17import de.uka.ipd.sdq.pcm.seff.CallAction;
18import de.uka.ipd.sdq.pcm.seff.CallReturnAction;
19import de.uka.ipd.sdq.pcm.seff.ExternalCallAction;
20import de.uka.ipd.sdq.pcm.seff.InternalCallAction;
21import de.uka.ipd.sdq.pcm.seff.SeffFactory;
22import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification;
23import de.uka.ipd.sdq.pcm.seff.seff_performance.InfrastructureCall;
24import de.uka.ipd.sdq.pcm.seff.seff_performance.ParametricResourceDemand;
25import de.uka.ipd.sdq.pcm.seff.seff_performance.ResourceCall;
26import de.uka.ipd.sdq.pcm.seff.seff_reliability.FailureHandlingEntity;
27import de.uka.ipd.sdq.stoex.AbstractNamedReference;
28import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition;
29import de.uka.ipd.sdq.workflow.pcm.runconfig.AccuracyInfluenceAnalysisState;
30 
31/**
32 * Implementing the transformation of given SEFFs for the state
33 * {@link AccuracyInfluenceAnalysisState#MAXIMUM}. Start the transformation by
34 * invoking {@link #doSwitch(org.eclipse.emf.ecore.EObject)} with a parameter of
35 * type {@link ServiceEffectSpecification}.
36 *
37 * @author groenda
38 *
39 */
40public class AccuracyInfluenceSEFFTransformationStrategyMaximum extends
41                AbstractAccuracyInfluenceSEFFTransformationStrategy {
42        /** Logger for this class. */
43        private static final Logger logger = Logger.getLogger(AccuracyInfluenceSEFFTransformationStrategyMaximum.class);
44 
45        /** Copier for EMF elements. */
46        private EcoreCopierCreatingNewIds copier = new EcoreCopierCreatingNewIds();
47 
48        /** Transformation of the specification of {@link PCMRandomVariable} for the maximum of a precision. */
49        private final PCMRandomVariableSpecificationAccuracyMaximumTrafo randomVariableMaximumTrafo = new PCMRandomVariableSpecificationAccuracyMaximumTrafo();
50        /** Returns the minimum value for a validation precision and provided absolute value. */
51        private final ValidationPrecisionToMaximumLongValue precisionMaximalValue = new ValidationPrecisionToMaximumLongValue();
52 
53        /**Create a new instance using the given quality annotations.
54         * @param pcmPartition Partition containing the quality annotations.
55         */
56        public AccuracyInfluenceSEFFTransformationStrategyMaximum(PCMResourceSetPartition pcmPartition) {
57                super(pcmPartition);
58        }
59 
60        /* (non-Javadoc)
61         * @see de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs.AbstractAccuracyInfluenceSEFFTransformationStrategy#modifyComponentExternalCall(de.uka.ipd.sdq.pcm.seff.ExternalCallAction, de.fzi.se.quality.qualityannotation.REPrecision)
62         */
63        @Override
64        protected void modifyComponentExternalCall(ExternalCallAction call,
65                        REPrecision precision) {
66                // Call Parameters for an CallAction
67                handleInputParametersOfCallAction(call, precision);
68                // Number of Calls for an AbstractAction
69                precisionMaximalValue.setAbsoluteValue(1l);
70                long max = precisionMaximalValue.doSwitch(precision.getDefaultPrecisionNumberOfCalls());
71                if (max > 1) {
72                        ExternalCallAction eca = null;
73                        AbstractAction predecessor = call;
74                        AbstractAction finalSuccessor = call.getSuccessor_AbstractAction();
75                        //replicate action
76                        for (int i = 1; i < max; i++) {
77                                eca = SeffFactory.eINSTANCE.createExternalCallAction();
78                                if (i == 1) { // special case for the first replica for correct control flow
79                                        call.setSuccessor_AbstractAction(eca);
80                                }
81                                eca.setCalledService_ExternalService(call.getCalledService_ExternalService());
82                                eca.setEntityName(call.getEntityName() + " Accuracy Influence Replica " + i);
83                                eca.setRetryCount(eca.getRetryCount());
84                                copyInputVariableUsages(eca, call);
85                                copyReturnVariableUsage(eca, call);
86                                copyFailureTypes(eca, call);
87                                eca.setRole_ExternalService(call.getRole_ExternalService());
88                                eca.setPredecessor_AbstractAction(predecessor);
89                                predecessor = eca;
90                        }
91                        if (eca != null) {
92                                eca.setSuccessor_AbstractAction(finalSuccessor);
93                        } else {
94                                String msg = "Impossible control flow in implemenation. Correct implemenatation.";
95                                logger.fatal(msg);
96                                throw new IllegalArgumentException(msg);
97                        }
98                }
99        }
100 
101        /* (non-Javadoc)
102         * @see de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs.AbstractAccuracyInfluenceSEFFTransformationStrategy#modifyComponentInternalCall(de.uka.ipd.sdq.pcm.seff.InternalCallAction, de.fzi.se.quality.qualityannotation.REPrecision)
103         */
104        @Override
105        protected void modifyComponentInternalCall(InternalCallAction call,
106                        REPrecision precision) {
107                // Call Parameters for an CallAction
108                handleInputParametersOfCallAction(call, precision);
109                // Number of Calls for an AbstractAction
110                precisionMaximalValue.setAbsoluteValue(1l);
111                long max = precisionMaximalValue.doSwitch(precision.getDefaultPrecisionNumberOfCalls());
112                if (max > 1) {
113                        InternalCallAction ica = null;
114                        AbstractAction predecessor = call;
115                        AbstractAction finalSuccessor = call.getSuccessor_AbstractAction();
116                        //replicate action
117                        for (int i = 1; i < max; i++) {
118                                ica = SeffFactory.eINSTANCE.createInternalCallAction();
119                                if (i == 1) { // special case for the first replica for correct control flow
120                                        call.setSuccessor_AbstractAction(ica);
121                                }
122                                ica.setCalledResourceDemandingInternalBehaviour(call.getCalledResourceDemandingInternalBehaviour());
123                                ica.setEntityName(call.getEntityName() + " Accuracy Influence Replica " + i);
124                                copyInputVariableUsages(ica, call);
125                                // not implemented although it should be copyReturnVariableUsage(ica, call);
126                                ica.setPredecessor_AbstractAction(predecessor);
127                                predecessor = ica;
128                        }
129                        if (ica != null) {
130                                ica.setSuccessor_AbstractAction(finalSuccessor);
131                        } else {
132                                String msg = "Impossible control flow in implemenation. Correct implemenatation.";
133                                logger.fatal(msg);
134                                throw new IllegalArgumentException(msg);
135                        }
136                }
137        }
138 
139        /* (non-Javadoc)
140         * @see de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs.AbstractAccuracyInfluenceSEFFTransformationStrategy#modifyInfrastructureCall(de.uka.ipd.sdq.pcm.seff.seff_performance.InfrastructureCall, de.fzi.se.quality.qualityannotation.REPrecision)
141         */
142        @Override
143        protected void modifyInfrastructureCall(InfrastructureCall call,
144                        REPrecision precision) {
145                // Number of Calls
146                randomVariableMaximumTrafo.setModifiedVariable(call.getNumberOfCalls__InfrastructureCall());
147                randomVariableMaximumTrafo.doSwitch(precision.getDefaultPrecisionNumberOfCalls());
148                // Call parameters
149                handleInputParametersOfCallAction(call, precision);
150        }
151 
152        /* (non-Javadoc)
153         * @see de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs.AbstractAccuracyInfluenceSEFFTransformationStrategy#modifyResourceCall(de.uka.ipd.sdq.pcm.seff.seff_performance.ResourceCall, de.fzi.se.quality.qualityannotation.REPrecision)
154         */
155        @Override
156        protected void modifyResourceCall(ResourceCall call, REPrecision precision) {
157                // Number of Calls
158                randomVariableMaximumTrafo.setModifiedVariable(call.getNumberOfCalls__ResourceCall());
159                randomVariableMaximumTrafo.doSwitch(precision.getDefaultPrecisionNumberOfCalls());
160                // Call parameters
161                for (VariableUsage variableUsage : call.getInputVariableUsages__CallAction()) {
162                        for (VariableCharacterisation varChar : variableUsage.getVariableCharacterisation_VariableUsage()) {
163                                randomVariableMaximumTrafo.setModifiedVariable(varChar.getSpecification_VariableCharacterisation());
164                                randomVariableMaximumTrafo.doSwitch(precision.getDefaultPrecisionCallParameter());
165                        }
166                }
167        }
168 
169        /* (non-Javadoc)
170         * @see de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs.AbstractAccuracyInfluenceSEFFTransformationStrategy#modifyResourceDemand(de.uka.ipd.sdq.pcm.seff.seff_performance.ParametricResourceDemand, de.fzi.se.quality.qualityannotation.REPrecision)
171         */
172        @Override
173        protected void modifyResourceDemand(ParametricResourceDemand demand,
174                        REPrecision precision) {
175                // Number of Calls
176                randomVariableMaximumTrafo.setModifiedVariable(demand.getSpecification_ParametericResourceDemand());
177                randomVariableMaximumTrafo.doSwitch(precision.getDefaultPrecisionNumberOfCalls());
178                // Call Parameters
179                if (!(precision.getDefaultPrecisionCallParameter() instanceof NoPrecision)) {
180                        String msg = "A ResourceDemand has no parameters. The default precision for call parameters must be set to NoPrecision.";
181                        logger.error(msg);
182                        throw new IllegalArgumentException(msg);
183                }
184        }
185 
186        /**Handles the transformation for input parameters of call actions.
187         * @param call Call action to transform.
188         * @param precision Precision.
189         */
190        private void handleInputParametersOfCallAction(CallAction call,
191                        REPrecision precision) {
192                for (VariableUsage variableUsage : call.getInputVariableUsages__CallAction()) {
193                        for (VariableCharacterisation varChar : variableUsage.getVariableCharacterisation_VariableUsage()) {
194                                randomVariableMaximumTrafo.setModifiedVariable(varChar.getSpecification_VariableCharacterisation());
195                                randomVariableMaximumTrafo.doSwitch(precision.getDefaultPrecisionCallParameter());
196                        }
197                }
198        }
199 
200        /**Copy input variable usages from source to target.
201         * @param target Target.
202         * @param source Source.
203         */
204        private void copyInputVariableUsages(CallAction target,
205                        CallAction source) {
206                VariableUsage newVU;
207                VariableCharacterisation newVC;
208                for (VariableUsage variableUsage : source.getInputVariableUsages__CallAction()) {
209                        newVU = ParameterFactory.eINSTANCE.createVariableUsage();
210                        newVU.setNamedReference__VariableUsage((AbstractNamedReference) copier.copy(variableUsage.getNamedReference__VariableUsage()));
211                        for (VariableCharacterisation varChar : variableUsage.getVariableCharacterisation_VariableUsage()) {
212                                newVC = ParameterFactory.eINSTANCE.createVariableCharacterisation();
213                                newVC.setSpecification_VariableCharacterisation(varChar.getSpecification_VariableCharacterisation());
214                                newVU.getVariableCharacterisation_VariableUsage().add(newVC);
215                        }
216                        target.getInputVariableUsages__CallAction().add(newVU);
217                }
218        }
219 
220        /**Copy return variable usages from source to target.
221         * @param target Target.
222         * @param source Source.
223         */
224        private void copyReturnVariableUsage(CallReturnAction target,
225                        CallReturnAction source) {
226                VariableUsage newVU;
227                VariableCharacterisation newVC;
228                for (VariableUsage variableUsage : source.getReturnVariableUsage__CallReturnAction()) {
229                        newVU = ParameterFactory.eINSTANCE.createVariableUsage();
230                        newVU.setNamedReference__VariableUsage((AbstractNamedReference) copier.copy(variableUsage.getNamedReference__VariableUsage()));
231                        for (VariableCharacterisation varChar : variableUsage.getVariableCharacterisation_VariableUsage()) {
232                                newVC = ParameterFactory.eINSTANCE.createVariableCharacterisation();
233                                newVC.setSpecification_VariableCharacterisation(varChar.getSpecification_VariableCharacterisation());
234                                newVU.getVariableCharacterisation_VariableUsage().add(newVC);
235                        }
236                        target.getReturnVariableUsage__CallReturnAction().add(newVU);
237                }
238        }
239 
240        /**Copy failure types from source to target.
241         * @param target Target.
242         * @param source Source.
243         */
244        private void copyFailureTypes(FailureHandlingEntity target,
245                        FailureHandlingEntity source) {
246                for (FailureType failureType : source.getFailureTypes_FailureHandlingEntity()) {
247                        target.getFailureTypes_FailureHandlingEntity().add(failureType);
248                }
249        }
250 
251 
252}

[all classes][de.fzi.se.accuracy.transformation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov