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