]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
TreeTestResult persistence independent from TreeSPath and registry (at last!)
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index 3ce0c99b5a6408d324a990c048c1df93f3366357..36233e9942a2d321cb73b39d5d86842638adb275 100644 (file)
@@ -14,6 +14,7 @@ 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
@@ -26,7 +27,8 @@ 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
@@ -90,7 +92,19 @@ 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 (!pathNames.containsKey(p)) {\r
+                                       StructureElement elem = registry.getElement(p);\r
+                                       if (elem != null) {\r
+                                               pathNames.put(p, elem.getLabel());\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
                currentPath = (TreeSPath) path;\r
                this.registry = registry;\r
        }\r
@@ -142,10 +156,9 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>, Sl
        }\r
 \r
        /** Sets the related registry. */\r
-//     public void setRegistry(StructureRegistry<TreeSPath> registry) {\r
-//             this.registry = registry;\r
-//     }\r
-\r
+       // public void setRegistry(StructureRegistry<TreeSPath> registry) {\r
+       // this.registry = registry;\r
+       // }\r
        public Date getCloseDate() {\r
                return closeDate;\r
        }\r
@@ -158,9 +171,17 @@ 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, String> getPathNames() {\r
+               return pathNames;\r
+       }\r
+\r
+       public void setPathNames(SortedMap<TreeSPath, String> pathNames) {\r
+               this.pathNames = pathNames;\r
+       }\r
+\r
 }\r