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

COVERAGE SUMMARY FOR SOURCE FILE [AnalysisProxy.java]

nameclass, %method, %block, %line, %
AnalysisProxy.java0%   (0/1)0%   (0/12)0%   (0/187)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AnalysisProxy0%   (0/1)0%   (0/12)0%   (0/187)0%   (0/41)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/3)
AnalysisProxy (DSEWorkflowConfiguration, DSEConstantsContainer$QualityAttribu... 0%   (0/1)0%   (0/18)0%   (0/7)
analyse (PCMPhenotype, IProgressMonitor): void 0%   (0/1)0%   (0/33)0%   (0/6)
getCriterions (): List 0%   (0/1)0%   (0/4)0%   (0/1)
getDecoratedAnalysis (): IAnalysis 0%   (0/1)0%   (0/20)0%   (0/5)
getQualityAttribute (): DSEConstantsContainer$QualityAttribute 0%   (0/1)0%   (0/4)0%   (0/1)
hasObjectivePerUsageScenario (): boolean 0%   (0/1)0%   (0/11)0%   (0/3)
hasStatisticResults (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
initialise (DSEWorkflowConfiguration): void 0%   (0/1)0%   (0/4)0%   (0/2)
loadDecoratedAnalysis (): IAnalysis 0%   (0/1)0%   (0/75)0%   (0/9)
retrieveResultsFor (PCMPhenotype, Criterion): IAnalysisResult 0%   (0/1)0%   (0/6)0%   (0/1)
setBlackboard (MDSDBlackboard): void 0%   (0/1)0%   (0/4)0%   (0/2)

1package de.uka.ipd.sdq.dsexplore.analysis;
2 
3import java.util.List;
4 
5import org.apache.log4j.Logger;
6import org.eclipse.core.runtime.CoreException;
7import org.eclipse.core.runtime.IConfigurationElement;
8import org.eclipse.core.runtime.IExtension;
9import org.eclipse.core.runtime.IProgressMonitor;
10import org.eclipse.core.runtime.Status;
11import org.opt4j.core.Criterion;
12 
13import de.uka.ipd.sdq.dsexplore.helper.ExtensionHelper;
14import de.uka.ipd.sdq.dsexplore.launch.DSELaunch;
15import de.uka.ipd.sdq.dsexplore.launch.DSEWorkflowConfiguration;
16import de.uka.ipd.sdq.dsexplore.launch.DSEConstantsContainer.QualityAttribute;
17import de.uka.ipd.sdq.workflow.exceptions.JobFailedException;
18import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException;
19import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard;
20 
21/** Singleton */
22public class AnalysisProxy implements IAnalysis {
23 
24        private DSEWorkflowConfiguration configuration;
25        
26        private QualityAttribute qualityAttribute;
27        
28        IAnalysis ana = null;
29        
30        //TODO: Quickfix to reset the Loggers. Refactor!
31        private DSELaunch dseLaunch;
32 
33        /**Name of the analysis extension to load, e.g. LQN solver. */ 
34        private String methodName;
35 
36        private MDSDBlackboard blackboard;
37 
38        /** Logger for log4j. */
39        private static Logger logger = 
40                Logger.getLogger("de.uka.ipd.sdq.dsexplore.analysis.AnalysisProxy");
41 
42        public AnalysisProxy(DSEWorkflowConfiguration configuration,  QualityAttribute qualityAttribute, DSELaunch dseLaunch, String methodName) {
43                this.initialise(configuration);
44                this.qualityAttribute = qualityAttribute;
45                this.dseLaunch = dseLaunch;
46                this.methodName = methodName;
47        }
48 
49        @Override
50        public void analyse(PCMPhenotype pheno, IProgressMonitor monitor) throws CoreException, UserCanceledException, AnalysisFailedException, JobFailedException {
51                IAnalysis ana = getDecoratedAnalysis();
52                
53                logger.debug("Starting analysis of "+qualityAttribute.getPrettyName());
54                ana.analyse(pheno, monitor);
55                logger.debug("Finished analysis of "+qualityAttribute.getPrettyName());
56                dseLaunch.resetLoggers();
57 
58        }
59        
60        private IAnalysis getDecoratedAnalysis() throws CoreException {
61                if (ana == null){
62                        ana = this.loadDecoratedAnalysis();
63                        ana.setBlackboard(blackboard);
64                        ana.initialise(configuration);
65 
66                } 
67                return ana;
68        }
69        
70        private IAnalysis loadDecoratedAnalysis() throws CoreException{
71                // obtain the extension of the choosen analysis method 
72                IExtension[] extensions = ExtensionHelper.loadAnalysisExtensions();
73                for (IExtension ext : extensions) {
74                        IConfigurationElement[] elements = ext.getConfigurationElements();
75                        for (IConfigurationElement element : elements) {
76                                if (element.getName().equals("analysis")) { 
77                                        // if extension fits to analysis method
78                                        if (element.getAttribute("name").equals(methodName)) { 
79                                                // obtain an analysis method instance  
80                                                ana = (IAnalysis)ExtensionHelper.loadExecutableAttribute(element, "delegate");
81                                                return ana;
82                                        }
83                                }
84                        }
85                }
86                throw new CoreException(new Status(Status.ERROR, "de.uka.ipd.sdq.dsexplore", "Cannot load analysis extension for "+methodName)); 
87        }
88 
89        @Override
90        public void initialise(DSEWorkflowConfiguration configuration) {
91                this.configuration = configuration;
92        }
93 
94 
95        @Override
96        public QualityAttribute getQualityAttribute() throws CoreException {
97                return getDecoratedAnalysis().getQualityAttribute();
98}
99 
100        @Override
101        public boolean hasStatisticResults() throws CoreException {
102                return this.getDecoratedAnalysis().hasStatisticResults();
103        }
104 
105        @Override
106        public List<Criterion> getCriterions() throws CoreException {
107                return getDecoratedAnalysis().getCriterions();
108        }
109 
110        @Override
111        public IAnalysisResult retrieveResultsFor(PCMPhenotype pheno, Criterion criterion)
112                        throws CoreException, AnalysisFailedException {
113                return getDecoratedAnalysis().retrieveResultsFor(pheno, criterion);
114        }
115 
116        @Override
117        public boolean hasObjectivePerUsageScenario() throws CoreException {
118                if (ana != null){
119                        ana = loadDecoratedAnalysis();
120                }
121                //ana may be not initialised
122                return ana.hasObjectivePerUsageScenario();
123        }
124 
125        @Override
126        public void setBlackboard(MDSDBlackboard blackboard) {
127                this.blackboard = blackboard;
128        }
129 
130}

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