X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FTreeTestResult.java;h=fb1b0130c951027a29f576381bd38357d47d5476;hb=5469796ed10ab0ddb8f7bf1cb7ba663676b7d73d;hp=3c5be7305e3547c33683abcf59bbfe59898b5662;hpb=872809aa7f951e0cda4d6cf04d5af7b7066cbf88;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java index 3c5be7305..fb1b0130c 100644 --- a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java +++ b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java @@ -3,6 +3,7 @@ package org.argeo.slc.core.test.tree; import java.util.List; import java.util.SortedMap; import java.util.TreeMap; +import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -18,32 +19,44 @@ import org.argeo.slc.core.test.TestResultId; import org.argeo.slc.core.test.TestResultListener; 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 { private Log log = LogFactory.getLog(TreeTestResult.class); /** For ORM */ private Long tid; private NumericTRId testResultId; - private List listeners; + private List listeners = new Vector(); private TreeSPath currentPath; - + private boolean isClosed = false; private SortedMap resultParts = new TreeMap(); + private StructureRegistry registry; + public TestResultId getTestResultId() { return testResultId; } + /** + * 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; } + /** Sets the list of listeners.*/ public void setListeners(List listeners) { this.listeners = listeners; } @@ -69,25 +82,30 @@ public class TreeTestResult implements TestResult, StructureAware { public void notifyCurrentPath(StructureRegistry registry, StructurePath path) { currentPath = (TreeSPath) path; + this.registry = registry; } + /** Gets the current path.*/ public TreeSPath getCurrentPath() { return currentPath; } + /** Gets all the results structured as a map of PartSubLists. */ public SortedMap getResultParts() { return resultParts; } + /** Used by ORM systems. */ void setResultParts(SortedMap resultParts) { this.resultParts = resultParts; } public void close() { - if(isClosed){ - throw new SlcException("Test Result #"+getTestResultId()+" alredy closed."); + if (isClosed) { + throw new SlcException("Test Result #" + getTestResultId() + + " alredy closed."); } - + synchronized (listeners) { for (TestResultListener listener : listeners) { listener.close(); @@ -95,7 +113,7 @@ public class TreeTestResult implements TestResult, StructureAware { listeners.clear(); } isClosed = true; - log.info("Test Result #"+getTestResultId()+" closed."); + log.info("Test Result #" + getTestResultId() + " closed."); } Long getTid() { @@ -106,4 +124,14 @@ public class TreeTestResult implements TestResult, StructureAware { 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; + } + }