X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FFullHtmlTreeReport.java;h=dd418477d9d661f8b0140044d4040561b7078568;hb=5469796ed10ab0ddb8f7bf1cb7ba663676b7d73d;hp=1144e27935a66b2654cec014b2016118e956dd62;hpb=6b1db6edae28268550c1ff26291cde6ac45c6463;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java index 1144e2793..dd418477d 100644 --- a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java +++ b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java @@ -5,17 +5,17 @@ import java.io.FileWriter; import java.io.IOException; import java.util.List; +import org.argeo.slc.core.SlcException; import org.argeo.slc.core.structure.StructureAware; import org.argeo.slc.core.structure.StructureElement; import org.argeo.slc.core.structure.StructurePath; import org.argeo.slc.core.structure.StructureRegistry; import org.argeo.slc.core.structure.tree.TreeSPath; import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.SimpleTestResult; -import org.argeo.slc.core.test.TestStatus; import org.argeo.slc.core.test.TestReport; import org.argeo.slc.core.test.TestResult; import org.argeo.slc.core.test.TestResultPart; +import org.argeo.slc.dao.structure.tree.TreeSRegistryDao; import org.argeo.slc.dao.test.TestResultDao; /** @@ -25,13 +25,16 @@ import org.argeo.slc.dao.test.TestResultDao; */ public class FullHtmlTreeReport implements TestReport, StructureAware { private TestResultDao testResultDao; + private TreeSRegistryDao treeSRegistryDao; private File reportDir; private StructureRegistry registry; public void generateTestReport(TestResult testResult) { + if (testResultDao == null) { TreeTestResult result = (TreeTestResult) testResult; + initRegistry(result.getResultParts().firstKey()); generateResultPage(getResultFile(result), result); } else { if (reportDir.exists()) { @@ -48,13 +51,14 @@ public class FullHtmlTreeReport implements TestReport, StructureAware { List list = testResultDao.listTestResults(); for (TestResult testRes : list) { - TreeTestResult res = (TreeTestResult) testRes; + TreeTestResult result = (TreeTestResult) testRes; + initRegistry(result.getResultParts().firstKey()); - File file = getResultFile(res); + File file = getResultFile(result); index.append(""); - index.append(res.getTestResultId()).append("\n"); - generateResultPage(file, res); + index.append(result.getTestResultId()).append("\n"); + generateResultPage(file, result); } index.append("\n"); @@ -148,16 +152,30 @@ public class FullHtmlTreeReport implements TestReport, StructureAware { + result.getTestResultId() + ".html"); } - /** Sets the dao to use to extract all data. */ + /** Sets the DAO to use to extract all data. */ public void setTestResultDao(TestResultDao testResultDao) { this.testResultDao = testResultDao; } + /** Sets the tree structure registry DAO.*/ + public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) { + this.treeSRegistryDao = treeSRegistryDao; + } + /** Sets the directory where to generate all the data. */ public void setReportDir(File reportDir) { this.reportDir = reportDir; } + private void initRegistry(TreeSPath path){ + if(treeSRegistryDao != null){ + registry = treeSRegistryDao.getTreeSRegistry(path); + } + if(registry==null){ + throw new SlcException("No structure registry available"); + } + } + public void notifyCurrentPath(StructureRegistry registry, StructurePath path) { this.registry = registry; }