EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs]

COVERAGE SUMMARY FOR SOURCE FILE [TransformPCMToCodeJob.java]

nameclass, %method, %block, %line, %
TransformPCMToCodeJob.java0%   (0/1)0%   (0/12)0%   (0/365)0%   (0/68)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TransformPCMToCodeJob0%   (0/1)0%   (0/12)0%   (0/365)0%   (0/68)
TransformPCMToCodeJob (AbstractCodeGenerationWorkflowRunConfiguration): void 0%   (0/1)0%   (0/9)0%   (0/4)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/92)0%   (0/16)
getBasePath (): String 0%   (0/1)0%   (0/22)0%   (0/3)
getCompletionRepositorySlots (): HashMap 0%   (0/1)0%   (0/26)0%   (0/4)
getGeneratorJob (HashMap, String): XpandGeneratorJob 0%   (0/1)0%   (0/6)0%   (0/1)
getGeneratorJob (HashMap, String, AbstractExpressionsUsingWorkflowComponent$G... 0%   (0/1)0%   (0/63)0%   (0/14)
getMiddlewareRepositorySlots (): HashMap 0%   (0/1)0%   (0/26)0%   (0/4)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getPCMOutlets (): Outlet [] 0%   (0/1)0%   (0/26)0%   (0/4)
getRepositoryCount (): int 0%   (0/1)0%   (0/11)0%   (0/2)
getRepositoryTransformationSlots (int): HashMap 0%   (0/1)0%   (0/35)0%   (0/6)
getSystemTransformationSlots (): HashMap 0%   (0/1)0%   (0/47)0%   (0/9)

1package de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs;
2 
3import java.util.HashMap;
4 
5import org.eclipse.core.resources.ResourcesPlugin;
6import org.eclipse.core.runtime.IProgressMonitor;
7import org.eclipse.emf.ecore.EPackage;
8import org.eclipse.xpand2.output.Outlet;
9import org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent.GlobalVarDef;
10 
11import de.fzi.se.quality.QualityFactory;
12import de.fzi.se.quality.QualityPackage;
13import de.fzi.se.quality.parameters.ParametersPackage;
14import de.fzi.se.quality.parameters.pcm.PCMPackage;
15import de.fzi.se.quality.qualityannotation.QualityAnnotationPackage;
16import de.uka.ipd.sdq.pcm.repository.Repository;
17import de.uka.ipd.sdq.pcm.transformations.ApplyConnectorCompletionsJob;
18import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob;
19import de.uka.ipd.sdq.workflow.IJob;
20import de.uka.ipd.sdq.workflow.OrderPreservingBlackboardCompositeJob;
21import de.uka.ipd.sdq.workflow.exceptions.JobFailedException;
22import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException;
23import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard;
24import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition;
25import de.uka.ipd.sdq.workflow.mdsd.oaw.XpandGeneratorJob;
26import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition;
27import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractCodeGenerationWorkflowRunConfiguration;
28import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration;
29import de.uka.ipd.sdq.workflow.pcm.jobs.LoadMiddlewareConfigurationIntoBlackboardJob;
30import de.uka.ipd.sdq.workflow.pcm.jobs.LoadPCMModelsIntoBlackboardJob;
31 
32/**
33 * Start the Workflow-Engine of oAW - Generator
34 */
35public class TransformPCMToCodeJob
36extends OrderPreservingBlackboardCompositeJob<MDSDBlackboard>
37implements IJob, IBlackboardInteractingJob<MDSDBlackboard> {
38 
39        private static final String REPOSITORY_ROOT_EXPAND_EXPRESSION = "m2t_transforms::repository::Root FOR pcmmodel";
40        private static final String SYSTEM_ROOT_EXPAND_EXPRESSION     = "m2t_transforms::system::Root FOR system";
41        private static final String ALLOCATION_ROOT_EXPAND_EXPRESSION = "m2t_transforms::allocation::AllocationTM FOR allocation";
42        private static final String USAGE_ROOT_EXPAND_EXPRESSION           = "m2t_transforms::usage::UsageModel(allocation) FOR usage";
43 
44        /** Name of the global variable used in the XPand generation to access the quality annotation repository. Used for accuracy influence analysis only. */
45        private static final String GLOBAL_VARIABLE_NAME_QUALITY_ANNOTATION_REPOSITORY = "qualityAnnotationRepository";
46        /** Name of the slot containing the model with the quality annotation repository. */
47        private static final String SLOT_NAME_QUALITY_ANNOTATION_MODEL = "qualityannotationmodel";
48 
49        private AbstractCodeGenerationWorkflowRunConfiguration configuration = null;
50 
51        public TransformPCMToCodeJob(AbstractCodeGenerationWorkflowRunConfiguration configuration) {
52                super();
53 
54                this.configuration  = configuration;
55        }
56 
57        @Override
58        public void execute(IProgressMonitor monitor) throws JobFailedException,
59                        UserCanceledException {
60                // First generate the jobs
61                // 1. Generate all repositories
62                for(int repositoryIndex = 0; repositoryIndex < getRepositoryCount(); repositoryIndex++) {
63                        if (configuration.isAccuracyInfluenceAnalysisEnabled()) {
64                                GlobalVarDef[] globalVars = new GlobalVarDef[1];
65                                globalVars[0] = new GlobalVarDef();
66                                globalVars[0].setName(GLOBAL_VARIABLE_NAME_QUALITY_ANNOTATION_REPOSITORY);
67                                globalVars[0].setValue(SLOT_NAME_QUALITY_ANNOTATION_MODEL);
68                                this.addJob(this.getGeneratorJob(getRepositoryTransformationSlots(repositoryIndex), REPOSITORY_ROOT_EXPAND_EXPRESSION, globalVars));
69                        } else {
70                                this.addJob(this.getGeneratorJob(getRepositoryTransformationSlots(repositoryIndex), REPOSITORY_ROOT_EXPAND_EXPRESSION));
71                        }
72                }
73                if (configuration.isLoadMiddlewareAndCompletionFiles()) {
74                        this.addJob(this.getGeneratorJob(getMiddlewareRepositorySlots(), REPOSITORY_ROOT_EXPAND_EXPRESSION));
75                        this.addJob(this.getGeneratorJob(getCompletionRepositorySlots(), REPOSITORY_ROOT_EXPAND_EXPRESSION));
76                }
77 
78                // 2. Generate the system
79                this.addJob(this.getGeneratorJob(getSystemTransformationSlots(), SYSTEM_ROOT_EXPAND_EXPRESSION));
80 
81                // 3. Generate the allocation
82                this.addJob(this.getGeneratorJob(getSystemTransformationSlots(), ALLOCATION_ROOT_EXPAND_EXPRESSION));
83 
84                // 4. Generate the usage
85                this.addJob(this.getGeneratorJob(getSystemTransformationSlots(), USAGE_ROOT_EXPAND_EXPRESSION));
86 
87                // Now let them run
88                super.execute(monitor);
89        }
90 
91        private HashMap<String, Object> getCompletionRepositorySlots() {
92                HashMap<String,Object> sC2 = new HashMap<String, Object>();
93                ResourceSetPartition completionRepositoryPartition = this.myBlackboard.getPartition(ApplyConnectorCompletionsJob.COMPLETION_REPOSITORY_PARTITION);
94 
95                sC2.put("pcmmodel",completionRepositoryPartition.getResourceSet().getResources().get(0).getContents().get(0));
96 
97                return sC2;
98        }
99 
100        private HashMap<String,Object> getMiddlewareRepositorySlots() {
101                HashMap<String,Object> sC2 = new HashMap<String, Object>();
102                ResourceSetPartition mwRepositoryPartition = this.myBlackboard.getPartition(LoadMiddlewareConfigurationIntoBlackboardJob.MIDDLEWARE_PARTITION_ID);
103 
104                sC2.put("pcmmodel",mwRepositoryPartition.getResourceSet().getResources().get(0).getContents().get(0));
105 
106                return sC2;
107        }
108 
109        /**Creates an XPand generator job.
110         * @param slots XPand slots and their content.
111         * @param expression XPand expression starting the generation.
112         * @param globalVarDefs Global variables used in the generation.
113         */
114        private XpandGeneratorJob getGeneratorJob(
115                        HashMap<String, Object> slots,
116                        String expression, GlobalVarDef[] globalVarDefs) {
117                // add accuracy EMF packages to transformation
118                EPackage[] pcmAndAccuracyPackages = new EPackage[AbstractPCMWorkflowRunConfiguration.PCM_EPACKAGES.length + 3];
119                System.arraycopy(AbstractPCMWorkflowRunConfiguration.PCM_EPACKAGES, 0, pcmAndAccuracyPackages, 0, AbstractPCMWorkflowRunConfiguration.PCM_EPACKAGES.length);
120                pcmAndAccuracyPackages[pcmAndAccuracyPackages.length-4] = QualityPackage.eINSTANCE;
121                pcmAndAccuracyPackages[pcmAndAccuracyPackages.length-3] = QualityAnnotationPackage.eINSTANCE;
122                pcmAndAccuracyPackages[pcmAndAccuracyPackages.length-2] = ParametersPackage.eINSTANCE;
123                pcmAndAccuracyPackages[pcmAndAccuracyPackages.length-1] = PCMPackage.eINSTANCE;
124                // create job
125                XpandGeneratorJob job = new XpandGeneratorJob(
126                                slots,
127                                pcmAndAccuracyPackages,
128                                getPCMOutlets(),
129                                expression, globalVarDefs);
130                job.getAdvices().add(configuration.getCodeGenerationAdvicesFile());
131                job.setCheckProtectedRegions(true);
132 
133                return job;
134        }
135 
136        /**Creates an XPand generator job without global variables.
137         * @param slots XPand slots and their content.
138         * @param expression XPand expression starting the generation.
139         */
140        private XpandGeneratorJob getGeneratorJob(
141                        HashMap<String, Object> slots,
142                        String expression) {
143                return getGeneratorJob(slots, expression, null);
144        }
145 
146        /**
147         * @return
148         */
149        private Outlet[] getPCMOutlets() {
150                Outlet defaultOutlet = new Outlet(getBasePath());
151                Outlet interfaces = new Outlet(getBasePath());
152                interfaces.setName("INTERFACES");
153 
154                return new Outlet[]{defaultOutlet,interfaces};
155        }
156 
157        /**
158         * @return
159         */
160        private HashMap<String, Object> getSystemTransformationSlots() {
161                HashMap<String,Object> sC2 = new HashMap<String, Object>();
162                PCMResourceSetPartition pcmPartition = (PCMResourceSetPartition) this.myBlackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID);
163 
164                sC2.put("middleware",pcmPartition.getMiddlewareRepository());
165                if (configuration.isLoadMiddlewareAndCompletionFiles()) {
166                        sC2.put("featureConfig",pcmPartition.getFeatureConfig());
167                }
168                sC2.put("system",pcmPartition.getSystem());
169                sC2.put("allocation",pcmPartition.getAllocation());
170                sC2.put("usage",pcmPartition.getUsageModel());
171                return sC2;
172        }
173 
174        /**
175         * @return Creates a HashMap with all slots required for the transformation of {@link Repository}.
176         */
177        private HashMap<String, Object> getRepositoryTransformationSlots(int repositoryIndex) {
178                HashMap<String,Object> sC2 = new HashMap<String, Object>();
179                PCMResourceSetPartition pcmPartition = (PCMResourceSetPartition) this.myBlackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID);
180                sC2.put("pcmmodel",pcmPartition.getRepositories().get(repositoryIndex));
181                if (configuration.isAccuracyInfluenceAnalysisEnabled()) {
182                        sC2.put(SLOT_NAME_QUALITY_ANNOTATION_MODEL, pcmPartition.getElement(QualityFactory.eINSTANCE.createQualityRepository()).get(0));
183                }
184                return sC2;
185        }
186 
187        /**
188         * @return
189         */
190        private int getRepositoryCount() {
191                PCMResourceSetPartition pcmPartition = (PCMResourceSetPartition) this.myBlackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID);
192                return pcmPartition.getRepositories().size();
193        }
194 
195        private String getBasePath() {
196                String basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()
197                + "/" + this.configuration.getStoragePluginID() + "/" + "src";
198 
199                return basePath;
200        }
201 
202        public String getName() {
203                return "Generate SimuCom Plugin Code";
204        }
205}

[all classes][de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov