]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
c333bf79f691baebd486faabcbd48d2a4a1b8b05
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
1 package org.argeo.slc.core.test.tree;
2
3 import java.util.List;
4 import java.util.SortedMap;
5 import java.util.TreeMap;
6
7 import org.argeo.slc.core.SlcException;
8 import org.argeo.slc.core.structure.StructureAware;
9 import org.argeo.slc.core.structure.StructurePath;
10 import org.argeo.slc.core.structure.StructureRegistry;
11 import org.argeo.slc.core.structure.tree.TreeSPath;
12 import org.argeo.slc.core.test.NumericTRId;
13 import org.argeo.slc.core.test.TestResult;
14 import org.argeo.slc.core.test.TestResultId;
15 import org.argeo.slc.core.test.TestResultListener;
16 import org.argeo.slc.core.test.TestResultPart;
17
18 public class TreeTestResult implements TestResult, StructureAware {
19 /** For ORM */
20 private Long tid;
21
22 private NumericTRId testResultId;
23 private List<TestResultListener> listeners;
24
25 private TreeSPath currentPath;
26
27 private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();
28
29
30
31 public TestResultId getTestResultId() {
32 return testResultId;
33 }
34
35 public NumericTRId getNumericResultId() {
36 return testResultId;
37 }
38
39 public void setNumericResultId(NumericTRId testResultId) {
40 this.testResultId = testResultId;
41 }
42
43 public void setListeners(List<TestResultListener> listeners) {
44 this.listeners = listeners;
45 }
46
47 public void addResultPart(TestResultPart part) {
48 if (currentPath == null) {
49 throw new SlcException("No current path set.");
50 }
51 PartSubList subList = resultParts.get(currentPath);
52 if (subList == null) {
53 subList = new PartSubList();
54 resultParts.put(currentPath, subList);
55 }
56 subList.getParts().add(part);
57
58 // notify listeners
59 for (TestResultListener listener : listeners) {
60 listener.resultPartAdded(this, part);
61 }
62 }
63
64 public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {
65 currentPath = (TreeSPath) path;
66 }
67
68 public TreeSPath getCurrentPath() {
69 return currentPath;
70 }
71
72 public SortedMap<TreeSPath, PartSubList> getResultParts() {
73 return resultParts;
74 }
75
76 void setResultParts(SortedMap<TreeSPath, PartSubList> resultParts) {
77 this.resultParts = resultParts;
78 }
79
80 Long getTid() {
81 return tid;
82 }
83
84 void setTid(Long tid) {
85 this.tid = tid;
86 }
87
88 }