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

COVERAGE SUMMARY FOR SOURCE FILE [ApplyConnectorCompletionsJob.java]

nameclass, %method, %block, %line, %
ApplyConnectorCompletionsJob.java0%   (0/3)0%   (0/13)0%   (0/251)0%   (0/60)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApplyConnectorCompletionsJob0%   (0/1)0%   (0/9)0%   (0/201)0%   (0/53)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/2)
ApplyConnectorCompletionsJob (AbstractSimulationWorkflowConfiguration): void 0%   (0/1)0%   (0/6)0%   (0/3)
access$1 (ApplyConnectorCompletionsJob, PCMAndCompletionModelHolder, Resource... 0%   (0/1)0%   (0/5)0%   (0/1)
access$2 (ApplyConnectorCompletionsJob): AbstractSimulationWorkflowConfiguration 0%   (0/1)0%   (0/3)0%   (0/1)
addMiddleware (PCMAndCompletionModelHolder, ResourceContainer): void 0%   (0/1)0%   (0/77)0%   (0/13)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/99)0%   (0/29)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
rollback (IProgressMonitor): void 0%   (0/1)0%   (0/1)0%   (0/1)
setBlackboard (MDSDBlackboard): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class ApplyConnectorCompletionsJob$10%   (0/1)0%   (0/2)0%   (0/18)0%   (0/4)
ApplyConnectorCompletionsJob$1 (ApplyConnectorCompletionsJob, EClassifier, EO... 0%   (0/1)0%   (0/11)0%   (0/2)
transform (ResourceContainer): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class ApplyConnectorCompletionsJob$20%   (0/1)0%   (0/2)0%   (0/32)0%   (0/6)
ApplyConnectorCompletionsJob$2 (ApplyConnectorCompletionsJob, EClassifier, EO... 0%   (0/1)0%   (0/14)0%   (0/2)
transform (AssemblyConnector): void 0%   (0/1)0%   (0/18)0%   (0/4)

1package de.uka.ipd.sdq.pcm.transformations;
2 
3import org.apache.log4j.Logger;
4import org.eclipse.core.resources.IFolder;
5import org.eclipse.core.resources.IProject;
6import org.eclipse.core.runtime.IProgressMonitor;
7import org.eclipse.emf.common.util.URI;
8import org.eclipse.emf.ecore.resource.Resource;
9 
10import de.uka.ipd.sdq.codegen.simucontroller.SimuControllerPlugin;
11import de.uka.ipd.sdq.codegen.simucontroller.runconfig.AbstractSimulationWorkflowConfiguration;
12import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition;
13import de.uka.ipd.sdq.workflow.pcm.jobs.CreatePluginProjectJob;
14import de.uka.ipd.sdq.workflow.pcm.jobs.LoadMiddlewareConfigurationIntoBlackboardJob;
15import de.uka.ipd.sdq.workflow.pcm.jobs.LoadPCMModelsIntoBlackboardJob;
16import de.uka.ipd.sdq.featureconfig.Configuration;
17import de.uka.ipd.sdq.pcm.allocation.AllocationContext;
18import de.uka.ipd.sdq.pcm.allocation.AllocationFactory;
19import de.uka.ipd.sdq.pcm.core.composition.AssemblyConnector;
20import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext;
21import de.uka.ipd.sdq.pcm.core.composition.CompositionFactory;
22import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage;
23import de.uka.ipd.sdq.pcm.repository.Repository;
24import de.uka.ipd.sdq.pcm.repository.RepositoryFactory;
25import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
26import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage;
27import de.uka.ipd.sdq.pcm.transformations.builder.connectors.ConnectorReplacingBuilder;
28import de.uka.ipd.sdq.pcm.transformations.builder.util.PCMAndCompletionModelHolder;
29import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob;
30import de.uka.ipd.sdq.workflow.exceptions.JobFailedException;
31import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException;
32import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException;
33import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard;
34import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition;
35 
36public class ApplyConnectorCompletionsJob 
37implements IBlackboardInteractingJob<MDSDBlackboard> {
38 
39        private static Logger logger = Logger.getLogger(ApplyConnectorCompletionsJob.class);
40        
41        public static final String COMPLETION_REPOSITORY_PARTITION = "de.uka.ipd.sdq.pcm.completionRepositoryPartition";
42        
43        private MDSDBlackboard blackboard;
44        private AbstractSimulationWorkflowConfiguration configuration;
45                
46        public ApplyConnectorCompletionsJob(AbstractSimulationWorkflowConfiguration configuration) {
47                super();
48                
49                this.configuration = configuration;
50        }
51        
52        public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException {
53 
54                PCMResourceSetPartition pcmModels = (PCMResourceSetPartition) blackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID);
55                ResourceSetPartition middlewareRepository = blackboard.getPartition(LoadMiddlewareConfigurationIntoBlackboardJob.MIDDLEWARE_PARTITION_ID);
56                
57                logger.info("Create completion repository...");
58                ResourceSetPartition completionRepositoryPartition = new ResourceSetPartition();
59                Repository completionRepository = RepositoryFactory.eINSTANCE.createRepository();
60                completionRepository.setEntityName("CompletionsRepository");
61                String tempDir = SimuControllerPlugin.getDefault().getStateLocation().append("temp").toOSString();
62                
63//                IProject project = CreatePluginProjectJob.getProject(configuration.getStoragePluginID());
64//                IFolder modelFolder = project.getFolder("model");
65//                URI u = pcmModels.getAllocation().eResource().getURI().trimSegments(1);
66//                u = u.appendSegment("completions.repository");
67//                
68//                
69//                String modelBasePath = modelFolder.getLocation().toOSString();
70//                String tempDir = modelBasePath;
71                
72//                u
73                Resource r = completionRepositoryPartition.getResourceSet().createResource(URI.createFileURI(tempDir));
74                r.getContents().add(completionRepository);
75                this.blackboard.addPartition(COMPLETION_REPOSITORY_PARTITION, completionRepositoryPartition);
76                
77                final PCMAndCompletionModelHolder models = new PCMAndCompletionModelHolder(
78                                pcmModels.getResourceTypeRepository(),
79                                null,
80                                pcmModels.getSystem(),
81                                pcmModels.getAllocation(),
82                                null,
83                                completionRepository,
84                                (Repository)middlewareRepository.getResourceSet().getResources().get(0).getContents().get(0)
85                                );
86                
87                final Configuration featureConfiguration = pcmModels.getFeatureConfig();
88                
89                new AllInstancesTransformer<ResourceContainer>(
90                                ResourceenvironmentPackage.eINSTANCE.getResourceContainer(),
91                                models.getAllocation().getTargetResourceEnvironment_Allocation()) {
92 
93                                        @Override
94                                        protected void transform(ResourceContainer object) {
95                                                addMiddleware(models, object);
96                                        }
97                        
98                }.transform();
99                
100                logger.info("Replace connectors with completions...");
101                new AllInstancesTransformer<AssemblyConnector>(
102                                CompositionPackage.eINSTANCE.getAssemblyConnector(),
103                                models.getSystem()) {
104 
105                                        @Override
106                                        protected void transform(AssemblyConnector connector) {
107                                                if ( configuration.getSimulateLinkingResources() ) {
108                                                        ConnectorReplacingBuilder replacer = new ConnectorReplacingBuilder(models,connector,featureConfiguration.getDefaultConfig());
109                                                        replacer.build();
110                                                }
111                                        }
112                        
113                }.transform();
114        }
115 
116        /**
117         * Creates a middleware component instance and allocates it to the given resource container
118         */
119        private void addMiddleware(PCMAndCompletionModelHolder models, ResourceContainer resContainer) {
120                AssemblyContext ctx = CompositionFactory.eINSTANCE.createAssemblyContext();
121                ctx.setEntityName("AssCtx Middleware "+resContainer.getEntityName());
122                ctx.setEncapsulatedComponent__AssemblyContext(models.getMiddlewareRepository().getComponents__Repository().get(0)); // TODO: Parameterise me!
123                models.getSystem().getAssemblyContexts__ComposedStructure().add(ctx);
124                
125                models.getSystem().getAssemblyContexts__ComposedStructure().add(ctx);
126                AllocationContext allocCtx = AllocationFactory.eINSTANCE.createAllocationContext();
127                allocCtx.setEntityName("AllocCtx Middleware "+resContainer.getEntityName());
128                allocCtx.setAssemblyContext_AllocationContext(ctx);
129                allocCtx.setResourceContainer_AllocationContext(resContainer);
130                models.getAllocation().getAllocationContexts_Allocation().add(allocCtx);
131                
132                logger.info("Added middleware component >"+ctx.getEncapsulatedComponent__AssemblyContext().getEntityName()+
133                                "< to resource container >"+resContainer.getEntityName()+"<");
134        }
135 
136        public void setBlackboard(MDSDBlackboard blackboard) {
137                this.blackboard = blackboard;
138        }
139 
140        public String getName() {
141                return "Add connector completions job";
142        }
143 
144        public void rollback(IProgressMonitor monitor)
145                        throws RollbackFailedException {
146                // Nothing to do here
147        }
148}

[all classes][de.uka.ipd.sdq.pcm.transformations]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov