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

COVERAGE SUMMARY FOR SOURCE FILE [QVTConfigurationHelper.java]

nameclass, %method, %block, %line, %
QVTConfigurationHelper.java0%   (0/1)0%   (0/10)0%   (0/211)0%   (0/48)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QVTConfigurationHelper0%   (0/1)0%   (0/10)0%   (0/211)0%   (0/48)
QVTConfigurationHelper (): void 0%   (0/1)0%   (0/3)0%   (0/1)
createQVTScript (String, Collection, String, String): QVTRScript 0%   (0/1)0%   (0/38)0%   (0/11)
createResourceToInputPartition (MDSDBlackboard, String, URI): ModelLocation 0%   (0/1)0%   (0/17)0%   (0/3)
createTransformationID (CompletionConfiguration, Transformation): String 0%   (0/1)0%   (0/27)0%   (0/4)
getHotTraceFileURI (String): URI 0%   (0/1)0%   (0/11)0%   (0/4)
getMetaModelsFromBlackboard (MDSDBlackboard, String): Collection 0%   (0/1)0%   (0/12)0%   (0/3)
getMetaModelsFromFile (URI): Collection 0%   (0/1)0%   (0/35)0%   (0/8)
getModelsFromBlackboard (MDSDBlackboard, String): ModelLocation [] 0%   (0/1)0%   (0/41)0%   (0/7)
getTraceFileURI (String): URI 0%   (0/1)0%   (0/11)0%   (0/4)
loadResourceToInputPartition (MDSDBlackboard, String, URI): ModelLocation 0%   (0/1)0%   (0/16)0%   (0/3)

1package de.uka.ipd.sdq.cip.configuration;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5 
6import org.eclipse.emf.common.util.TreeIterator;
7import org.eclipse.emf.common.util.URI;
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.emf.ecore.EPackage;
10import org.eclipse.emf.ecore.EPackage.Registry;
11import org.eclipse.emf.ecore.resource.Resource;
12import org.eclipse.emf.ecore.resource.ResourceSet;
13import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
14 
15import de.uka.ipd.sdq.cip.workflow.jobs.PrepareTransformationsJob;
16import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard;
17import de.uka.ipd.sdq.workflow.mdsd.blackboard.ModelLocation;
18import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition;
19import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.QVTRScript;
20import de.uka.ipd.sdq.workflow.mdsd.emf.qvtr.QVTRScriptInfo;
21 
22public class QVTConfigurationHelper {
23 
24        public static Collection<Object> getMetaModelsFromBlackboard(MDSDBlackboard blackboard, String modelPartitionID) {
25                ResourceSetPartition partition = blackboard.getPartition(modelPartitionID);
26                Registry registry = partition.getResourceSet().getPackageRegistry();
27                return registry.values();
28        }
29        
30        public static Collection<Object> getMetaModelsFromFile(URI metamodelURI) {
31                ArrayList<Object> list = new ArrayList<Object>();
32                ResourceSet rset = new ResourceSetImpl();
33                Resource resource = rset.getResource(metamodelURI,true);
34                TreeIterator<EObject> iterator = resource.getAllContents();
35                for(EObject object = null; iterator.hasNext(); object = iterator.next() ) {
36                        if(object instanceof EPackage)
37                                list.add(object);
38                }
39                
40                return list;
41        }
42        
43        /**
44         * Build the location objects out of the blackboards PCM model partition.
45         * 
46         * @return        The prepared model locations for the PCM models.
47         */
48        public static ModelLocation[] getModelsFromBlackboard(MDSDBlackboard blackboard, String modelPartitionID) {
49                
50                ArrayList<ModelLocation> modelLocations = new ArrayList<ModelLocation>();
51                ResourceSetPartition partition = blackboard.getPartition(modelPartitionID);
52                partition.resolveAllProxies();
53                for (Resource r : partition.getResourceSet().getResources()) {
54                        ModelLocation location = new ModelLocation(modelPartitionID, r.getURI());
55                        modelLocations.add(location);
56                }
57                
58                return modelLocations.toArray(new ModelLocation[]{});
59        }
60        
61        public static URI getTraceFileURI (String projectID) {
62                String tracesFolder = PrepareTransformationsJob.getTracesFolder(
63                                projectID).getFullPath().toString();
64                URI tracesURI = URI.createPlatformResourceURI(tracesFolder, false);
65                return tracesURI;
66        }
67        
68        public static URI getHotTraceFileURI (String projectID) {
69                String tracesFolder = PrepareTransformationsJob.getHOTTracesFolder(
70                                projectID).getFullPath().toString();
71                URI tracesURI = URI.createPlatformResourceURI(tracesFolder, false);
72                return tracesURI;
73        }
74        
75        public static ModelLocation createResourceToInputPartition(MDSDBlackboard blackboard, String modelPartitionID, URI modelURI) {
76                ResourceSetPartition resourceSetPartition = blackboard.getPartition(modelPartitionID);
77                Resource r = resourceSetPartition.getResourceSet().createResource(modelURI);                        
78                return new ModelLocation(modelPartitionID, r.getURI());
79        }
80        
81        public static ModelLocation loadResourceToInputPartition(MDSDBlackboard blackboard, String modelPartitionID, URI modelURI) {
82                ResourceSetPartition resourceSetPartition = blackboard.getPartition(modelPartitionID);
83                Resource r = resourceSetPartition.loadModel(modelURI);                        
84                return new ModelLocation(modelPartitionID, r.getURI());
85        }
86        
87        public static String createTransformationID(CompletionConfiguration completionConfiguration, Transformation transformation) {
88                
89                URI qvtFileURI = URI.createURI(transformation.getQVTFileURI());
90                int index = qvtFileURI.lastSegment().indexOf('.');
91                
92                return qvtFileURI.lastSegment().substring(0, index) + "_" +
93                        completionConfiguration.getTransformations().indexOf(transformation);
94        }
95        
96        public static QVTRScript createQVTScript(String script, Collection<Object> metaModels, String transformation, String direction) {
97                QVTRScript qvtrScript = new QVTRScript();
98                qvtrScript.setQVTFile(script);
99                qvtrScript.setMetaModels(metaModels);
100                
101                QVTRScriptInfo scriptinfo = new QVTRScriptInfo(qvtrScript);
102                if(transformation == null)
103                        transformation = scriptinfo.getTransformations()[0];
104                if(direction == null)
105                        direction = scriptinfo.getDirections(transformation)[1];
106                
107                qvtrScript.setTransformationName(transformation);
108                qvtrScript.setTransformationDirection(direction);
109                
110                return qvtrScript;
111        }
112}

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