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

COVERAGE SUMMARY FOR SOURCE FILE [QVTRConfigurationJob.java]

nameclass, %method, %block, %line, %
QVTRConfigurationJob.java0%   (0/1)0%   (0/7)0%   (0/248)0%   (0/65)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QVTRConfigurationJob0%   (0/1)0%   (0/7)0%   (0/248)0%   (0/65)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
QVTRConfigurationJob (QVTRTransformationJobConfiguration, CompletionConfigura... 0%   (0/1)0%   (0/24)0%   (0/9)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/183)0%   (0/45)
getJobConfiguration (): QVTRTransformationJobConfiguration 0%   (0/1)0%   (0/3)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
rollback (IProgressMonitor): void 0%   (0/1)0%   (0/24)0%   (0/6)
setBlackboard (MDSDBlackboard): void 0%   (0/1)0%   (0/4)0%   (0/2)

1package de.uka.ipd.sdq.cip.workflow.jobs;
2 
3import java.io.FileNotFoundException;
4import java.io.FileOutputStream;
5import java.io.PrintStream;
6import java.util.Collection;
7 
8import org.eclipse.core.runtime.CoreException;
9import org.eclipse.core.runtime.IProgressMonitor;
10import org.eclipse.emf.common.util.URI;
11 
12import de.uka.ipd.sdq.cip.configuration.CompletionConfiguration;
13import de.uka.ipd.sdq.cip.configuration.QVTConfigurationHelper;
14import de.uka.ipd.sdq.cip.configuration.Transformation;
15import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob;
16import de.uka.ipd.sdq.workflow.exceptions.JobFailedException;
17import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException;
18import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException;
19import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard;
20import de.uka.ipd.sdq.workflow.mdsd.blackboard.ModelLocation;
21import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.QVTRScript;
22import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.jobs.QVTRTransformationJobConfiguration;
23 
24public class QVTRConfigurationJob implements
25                IBlackboardInteractingJob<MDSDBlackboard> {
26 
27        private CompletionConfiguration completionConfiguration = null;
28        private Transformation transformation = null;
29        private QVTRTransformationJobConfiguration jobConfiguration = null;
30        private MDSDBlackboard blackboard = null;
31        
32        public QVTRConfigurationJob(QVTRTransformationJobConfiguration jobConfiguration, 
33                        CompletionConfiguration completionConfiguration, Transformation transformation) {
34                
35                this.jobConfiguration = jobConfiguration;
36                this.transformation = transformation;
37                this.completionConfiguration = completionConfiguration;
38                
39        }
40        
41        @Override
42        public void execute(IProgressMonitor monitor) throws JobFailedException,
43                        UserCanceledException {
44                
45                assert (completionConfiguration != null);
46                assert (transformation != null);
47                assert (jobConfiguration != null);
48                
49                String modelPartitionID = completionConfiguration.getInputPartitionName();
50                
51                // get the models to work with
52                ModelLocation[] inputModelLocations = QVTConfigurationHelper.getModelsFromBlackboard(blackboard, modelPartitionID);
53                
54                // get meta models needed for qvt script
55                Collection<Object> metamodels = QVTConfigurationHelper.getMetaModelsFromBlackboard(blackboard, modelPartitionID);
56                
57                ModelLocation[] outputModelLocations = new ModelLocation[] {
58                                QVTConfigurationHelper.createResourceToInputPartition(
59                                                blackboard, 
60                                                modelPartitionID,
61                                                URI.createURI(PrepareTransformationsJob.
62                                                                getModelFolder(completionConfiguration.getProjectID()).
63                                                                getFile("output.xmi").getFullPath().toPortableString()))};
64                
65                ModelLocation[] configModelLocations = null;
66                if(transformation.getConfigFileURI() != null && !transformation.getConfigFileURI().isEmpty()) {
67                        
68                        configModelLocations = new ModelLocation[] { 
69                                        QVTConfigurationHelper.loadResourceToInputPartition(
70                                                        blackboard, 
71                                                        modelPartitionID, 
72                                                        URI.createURI(transformation.getConfigFileURI()))};
73                        
74                        metamodels.addAll(QVTConfigurationHelper.getMetaModelsFromFile(
75                                        URI.createURI(transformation.getMetamodelFileURI())));
76                }
77                
78                QVTRScript qvtrScript = QVTConfigurationHelper.createQVTScript(transformation.getQVTFileURI(), metamodels, null, null);
79                
80                URI traceFileURI = QVTConfigurationHelper.getTraceFileURI(completionConfiguration.getProjectID());
81                
82                Boolean isDebug = completionConfiguration.getDebug();
83                
84                PrintStream extendedDebuggingLog = null;
85                if(isDebug) {
86                        try {
87                                extendedDebuggingLog = new PrintStream(
88                                                new FileOutputStream (
89                                                PrepareTransformationsJob.
90                                                getLogFolder(completionConfiguration.getProjectID()).
91                                                getFile(QVTConfigurationHelper.
92                                                                createTransformationID(completionConfiguration, transformation) + 
93                                                                ".log").
94                                                getRawLocation().toOSString()),true);
95                                
96                        } catch (FileNotFoundException e) {
97                                throw new JobFailedException("Could not create extended logging output", e);
98                        }
99                }
100                
101                
102                // set the job configuration
103                jobConfiguration.setDebug(isDebug);
104                jobConfiguration.addModelLocationSets(inputModelLocations);
105                jobConfiguration.addModelLocationSets(outputModelLocations);
106                if(configModelLocations != null)
107                        jobConfiguration.addModelLocationSets(configModelLocations);
108                jobConfiguration.setTraceFileURI(traceFileURI);
109                jobConfiguration.setExtendedDebuggingLog(extendedDebuggingLog);
110                jobConfiguration.setQVTRScript(qvtrScript);
111                
112                
113        }
114        
115        public QVTRTransformationJobConfiguration getJobConfiguration() {
116                return jobConfiguration;
117        }
118        
119        @Override
120        public void setBlackboard(MDSDBlackboard blackboard) {
121                this.blackboard = blackboard;
122        }
123 
124        @Override
125        public String getName() {
126                return "Configure QVTR transformation";
127        }
128 
129        @Override
130        public void rollback(IProgressMonitor monitor)
131                        throws RollbackFailedException {
132                if(jobConfiguration.getExtendedDebuggingLog() != null)
133                        jobConfiguration.getExtendedDebuggingLog().close();
134                
135                try {
136                        PrepareTransformationsJob.
137                        getLogFolder(completionConfiguration.getProjectID()).refreshLocal(1, monitor);
138                } catch (CoreException e) {
139                        throw new RollbackFailedException("Could not refresh workspace", e);
140                }
141        }
142 
143}

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