X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FTreeTestResult.java;h=8da3e7d5a2dde3bd932a5175b592cbac6d3c77a8;hb=d5d72139e7497923c2b8e2f4d25f366d01425498;hp=3ce0c99b5a6408d324a990c048c1df93f3366357;hpb=4be456f18c71bf293632d365d790a2ef32728157;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java index 3ce0c99b5..8da3e7d5a 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java @@ -14,11 +14,10 @@ import org.argeo.slc.core.process.SlcExecution; import org.argeo.slc.core.process.SlcExecutionAware; import org.argeo.slc.core.process.SlcExecutionStep; import org.argeo.slc.core.structure.StructureAware; +import org.argeo.slc.core.structure.StructureElement; import org.argeo.slc.core.structure.StructureRegistry; import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.NumericTRId; import org.argeo.slc.core.test.TestResult; -import org.argeo.slc.core.test.TestResultId; import org.argeo.slc.core.test.TestResultListener; import org.argeo.slc.core.test.TestResultPart; @@ -26,12 +25,10 @@ import org.argeo.slc.core.test.TestResultPart; * Complex implementation of a test result compatible with a tree based * structure. */ -public class TreeTestResult implements TestResult, StructureAware, SlcExecutionAware { +public class TreeTestResult implements TestResult, StructureAware, + SlcExecutionAware { private Log log = LogFactory.getLog(TreeTestResult.class); - /** For ORM */ - private Long tid; - private NumericTRId testResultId; private List listeners = new Vector(); private TreeSPath currentPath; @@ -42,27 +39,10 @@ public class TreeTestResult implements TestResult, StructureAware, Sl private boolean isClosed = false; - private SortedMap resultParts = new TreeMap(); - private SortedMap pathNames = new TreeMap(); - - private StructureRegistry registry; - - public TestResultId getTestResultId() { - return testResultId; - } + private String uuid; - /** - * Use of a NumericTRId is required by Hibernate. It may - * change in the future. - */ - public NumericTRId getNumericResultId() { - return testResultId; - } - - /** Sets the test result id as a numeric test result id. */ - public void setNumericResultId(NumericTRId testResultId) { - this.testResultId = testResultId; - } + private SortedMap resultParts = new TreeMap(); + private SortedMap elements = new TreeMap(); /** Sets the list of listeners. */ public void setListeners(List listeners) { @@ -90,9 +70,25 @@ public class TreeTestResult implements TestResult, StructureAware, Sl } } - public void notifyCurrentPath(StructureRegistry registry, TreeSPath path) { + public void notifyCurrentPath(StructureRegistry registry, + TreeSPath path) { + if (registry != null) { + for (TreeSPath p : path.getHierarchyAsList()) { + if (!elements.containsKey(p)) { + StructureElement elem = registry.getElement(p); + if (elem != null) { + elements.put(p, elem); + } + } else { + if (log.isTraceEnabled()) + log.trace("An element is already registered for path " + + p + " and was not updated"); + } + + } + } + currentPath = (TreeSPath) path; - this.registry = registry; } /** Gets the current path. */ @@ -112,7 +108,7 @@ public class TreeTestResult implements TestResult, StructureAware, Sl public void close() { if (isClosed) { - throw new SlcException("Test Result #" + getTestResultId() + throw new SlcException("Test Result #" + getUuid() + " alredy closed."); } closeDate = new Date(); @@ -125,27 +121,9 @@ public class TreeTestResult implements TestResult, StructureAware, Sl } isClosed = true; - log.info("Test Result #" + getTestResultId() + " closed."); - } - - Long getTid() { - return tid; + log.info("Test Result #" + getUuid() + " closed."); } - void setTid(Long tid) { - this.tid = tid; - } - - /** Gets the related registry (can be null). */ - public StructureRegistry getRegistry() { - return registry; - } - - /** Sets the related registry. */ -// public void setRegistry(StructureRegistry registry) { -// this.registry = registry; -// } - public Date getCloseDate() { return closeDate; } @@ -158,9 +136,25 @@ public class TreeTestResult implements TestResult, StructureAware, Sl public void notifySlcExecution(SlcExecution slcExecution) { currentSlcExecutionUuid = slcExecution.getUuid(); SlcExecutionStep step = slcExecution.currentStep(); - if(step!=null){ + if (step != null) { currentSlcExecutionStepUuid = step.getUuid(); } } + public SortedMap getElements() { + return elements; + } + + public void setElements(SortedMap pathNames) { + this.elements = pathNames; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + }