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

COVERAGE SUMMARY FOR SOURCE FILE [MemoryExperimentDAO.java]

nameclass, %method, %block, %line, %
MemoryExperimentDAO.java100% (1/1)38%  (3/8)35%  (47/134)39%  (11/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MemoryExperimentDAO100% (1/1)38%  (3/8)35%  (47/134)39%  (11/28)
findByExperimentName (String): Collection 0%   (0/1)0%   (0/29)0%   (0/5)
get (long): Experiment 0%   (0/1)0%   (0/7)0%   (0/1)
removeExperiment (Experiment, boolean): void 0%   (0/1)0%   (0/49)0%   (0/9)
store (Experiment): void 0%   (0/1)0%   (0/1)0%   (0/1)
storeAll (): void 0%   (0/1)0%   (0/1)0%   (0/1)
MemoryExperimentDAO (MemoryDAOFactory): void 100% (1/1)100% (14/14)100% (5/5)
addExperiment (String): Experiment 100% (1/1)100% (28/28)100% (5/5)
getExperiments (): Collection 100% (1/1)100% (5/5)100% (1/1)

1package de.uka.ipd.sdq.sensorframework.dao.memory;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Collections;
6import java.util.HashMap;
7 
8import de.uka.ipd.sdq.sensorframework.entities.Experiment;
9import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
10import de.uka.ipd.sdq.sensorframework.entities.Sensor;
11import de.uka.ipd.sdq.sensorframework.entities.dao.IExperimentDAO;
12import de.uka.ipd.sdq.sensorframework.entities.impl.ExperimentImpl;
13 
14/**
15 * @author Steffen Becker
16 *
17 */
18public class MemoryExperimentDAO implements IExperimentDAO {
19 
20        private long nextID = 0;
21        private HashMap<Long, Experiment> index = new HashMap<Long, Experiment>();
22        
23        private MemoryDAOFactory factory;
24 
25        public MemoryExperimentDAO(MemoryDAOFactory memoryDAOFactory) {
26                this.factory = memoryDAOFactory;
27        }
28 
29        public synchronized Experiment addExperiment(String p_experimentname) {
30                ExperimentImpl result = new ExperimentImpl(factory);
31                result.setExperimentID(nextID++);
32                result.setExperimentName(p_experimentname);
33                
34                index.put(result.getExperimentID(),result);
35                
36                return result;
37        }
38 
39        public synchronized Experiment get(long id) {
40                return index.get(id);
41        }
42 
43        public synchronized Collection<Experiment> getExperiments() {
44                return Collections.unmodifiableCollection(index.values());
45        }
46 
47        /** {@inheritDoc}*/
48        public synchronized Collection<Experiment> findByExperimentName(String searchKey) {
49                ArrayList<Experiment> result = new ArrayList<Experiment>();
50                for (Experiment e:this.index.values()){
51                        if (e.getExperimentName().equals(searchKey))
52                                result.add(e);
53                }
54                return Collections.unmodifiableCollection(result);
55        }
56 
57        public void store(Experiment e) {
58        }
59 
60        public synchronized void removeExperiment(Experiment experiment, boolean doCascade) {
61                if (experiment == null) {
62                        return;
63                }
64                
65                if ( doCascade == true ) {
66                        //remove all experiment runs
67                        for (ExperimentRun expRun:experiment.getExperimentRuns()) {
68                                factory.createExperimentRunDAO().removeExperimentRun(expRun, true);
69                        }
70                        //remove all sensors
71                        for (Sensor sensor:experiment.getSensors()) {
72                                factory.createSensorDAO().removeSensor(sensor, true);
73                        }
74                }
75                index.remove(experiment.getExperimentID());
76        }
77        
78        public void storeAll() {
79                // Nothing to do here
80        }
81        
82}

[all classes][de.uka.ipd.sdq.sensorframework.dao.memory]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov