]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java
Persist path and registry
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / core / test / tree / FullHtmlTreeReport.java
index 1144e27935a66b2654cec014b2016118e956dd62..eac9fce9be1d75595fc7f646083970755a084bca 100644 (file)
@@ -5,17 +5,20 @@ import java.io.FileWriter;
 import java.io.IOException;\r
 import java.util.List;\r
 \r
+import org.argeo.slc.core.SlcException;\r
 import org.argeo.slc.core.structure.StructureAware;\r
 import org.argeo.slc.core.structure.StructureElement;\r
 import org.argeo.slc.core.structure.StructurePath;\r
 import org.argeo.slc.core.structure.StructureRegistry;\r
 import org.argeo.slc.core.structure.tree.TreeSPath;\r
+import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
 import org.argeo.slc.core.test.SimpleResultPart;\r
 import org.argeo.slc.core.test.SimpleTestResult;\r
 import org.argeo.slc.core.test.TestStatus;\r
 import org.argeo.slc.core.test.TestReport;\r
 import org.argeo.slc.core.test.TestResult;\r
 import org.argeo.slc.core.test.TestResultPart;\r
+import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
 import org.argeo.slc.dao.test.TestResultDao;\r
 \r
 /**\r
@@ -25,13 +28,16 @@ import org.argeo.slc.dao.test.TestResultDao;
  */\r
 public class FullHtmlTreeReport implements TestReport, StructureAware {\r
        private TestResultDao testResultDao;\r
+       private TreeSRegistryDao treeSRegistryDao;\r
        private File reportDir;\r
 \r
        private StructureRegistry registry;\r
 \r
        public void generateTestReport(TestResult testResult) {\r
+               \r
                if (testResultDao == null) {\r
                        TreeTestResult result = (TreeTestResult) testResult;\r
+                       initRegistry(result.getResultParts().firstKey());\r
                        generateResultPage(getResultFile(result), result);\r
                } else {\r
                        if (reportDir.exists()) {\r
@@ -48,13 +54,14 @@ public class FullHtmlTreeReport implements TestReport, StructureAware {
 \r
                        List<TestResult> list = testResultDao.listTestResults();\r
                        for (TestResult testRes : list) {\r
-                               TreeTestResult res = (TreeTestResult) testRes;\r
+                               TreeTestResult result = (TreeTestResult) testRes;\r
+                               initRegistry(result.getResultParts().firstKey());\r
 \r
-                               File file = getResultFile(res);\r
+                               File file = getResultFile(result);\r
                                index.append("<tr><td><a href=\"").append(file.getName())\r
                                                .append("\">");\r
-                               index.append(res.getTestResultId()).append("</a></td></tr>\n");\r
-                               generateResultPage(file, res);\r
+                               index.append(result.getTestResultId()).append("</a></td></tr>\n");\r
+                               generateResultPage(file, result);\r
                        }\r
 \r
                        index.append("</table>\n</body></html>");\r
@@ -153,11 +160,24 @@ public class FullHtmlTreeReport implements TestReport, StructureAware {
                this.testResultDao = testResultDao;\r
        }\r
 \r
+       public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
+               this.treeSRegistryDao = treeSRegistryDao;\r
+       }\r
+\r
        /** Sets the directory where to generate all the data. */\r
        public void setReportDir(File reportDir) {\r
                this.reportDir = reportDir;\r
        }\r
 \r
+       protected void initRegistry(TreeSPath path){\r
+               if(treeSRegistryDao != null){\r
+                       registry = treeSRegistryDao.getTreeSRegistry(path);\r
+               }\r
+               if(registry==null){\r
+                       throw new SlcException("No structure registry available");\r
+               }\r
+       }\r
+       \r
        public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
                this.registry = registry;\r
        }\r