StructureRegistry localRegistry = partStruct.result.getRegistry();\r
TreeSRegistry registry = getOrCreateTreeSRegistry(path);\r
syncPath(registry, localRegistry, path);\r
- treeSRegistryDao.update(registry);\r
\r
if (persistedResult == null) {\r
persistedResult = new TreeTestResult();\r
} else {\r
registry.register(path, new SimpleSElement(path.getName()));\r
}\r
+ treeSRegistryDao.update(registry);\r
}\r
\r
if (path.getParent() != null) {\r
\r
import java.io.File;\r
import java.io.FileOutputStream;\r
+import java.io.IOException;\r
import java.io.InputStream;\r
import java.text.SimpleDateFormat;\r
+import java.util.Comparator;\r
import java.util.List;\r
+import java.util.SortedSet;\r
+import java.util.TreeSet;\r
\r
-import org.dbunit.dataset.IDataSet;\r
-import org.dbunit.dataset.xml.FlatXmlDataSet;\r
-import org.hsqldb.lib.FileUtil;\r
-\r
-import org.apache.commons.io.FileUtils;\r
import org.apache.commons.io.IOUtils;\r
\r
import org.argeo.slc.core.SlcException;\r
reportDir.mkdirs();\r
\r
resourceToFile("index.html");\r
- resourceToFile("style.css");\r
\r
ResultsList index = new ResultsList(this);\r
List<TestResult> list = testResultDao.listTestResults();\r
- for (TestResult testRes : list) {\r
+ SortedSet<TestResult> sortedSet = new TreeSet<TestResult>(\r
+ new Comparator<TestResult>() {\r
+\r
+ public int compare(TestResult o1, TestResult o2) {\r
+ if (o1.getCloseDate() == null\r
+ || o2.getCloseDate() == null)\r
+ return 0;\r
+ // inverse date order (last first)\r
+ return o2.getCloseDate().compareTo(\r
+ o1.getCloseDate());\r
+ }\r
+\r
+ });\r
+ sortedSet.addAll(list);\r
+ for (TestResult testRes : sortedSet) {\r
TreeTestResult result = (TreeTestResult) testRes;\r
\r
index.addTestResult(result);\r
return reportDir;\r
}\r
\r
+ void addStyles(StringBuffer buf){\r
+ try {\r
+ buf.append("<style type=\"text/css\">\n");\r
+ InputStream in = FullHtmlTreeReport.class\r
+ .getResourceAsStream("style.css");\r
+ String styles = IOUtils.toString(in);\r
+ IOUtils.closeQuietly(in);\r
+ buf.append(styles);\r
+ buf.append("\n</style>\n");\r
+ } catch (IOException e) {\r
+ throw new SlcException("Cannot load styles", e);\r
+ }\r
+ }\r
+ \r
private void resourceToFile(String resourceName) {\r
try {\r
File file = new File(getReportDir() + File.separator + resourceName);\r
import java.util.SortedMap;\r
import java.util.TreeMap;\r
\r
-import javax.swing.tree.TreePath;\r
-\r
import org.apache.commons.io.FileUtils;\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
StringBuffer buf = new StringBuffer("");\r
buf.append("<html>\n");\r
buf.append("<header>");\r
- buf.append("<title>Result #").append(result.getTestResultId()).append(\r
- "</title>\n");\r
- buf\r
- .append("<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>");\r
+ buf.append("<title>Result #").append(result.getTestResultId());\r
+ buf.append("</title>\n");\r
+ report.addStyles(buf);\r
buf.append("</header>\n");\r
\r
buf.append("<body>\n");\r
\r
// Header\r
+ buf.append("<a name=\"top\"/>\n");\r
buf.append("<h1>Result #").append(result.getTestResultId()).append(\r
"</h1>\n");\r
buf.append(report.sdf.format(result.getCloseDate()));\r
buf.append("<p>\n");\r
buf.append("<a name=\"").append(anchor(path)).append("\"></a>");\r
buf.append("<h2>");\r
- String description = path.getName();\r
- if (registry != null) {\r
- StructureElement element = registry.getElement(path);\r
- if (element != null) {\r
- description = element.getDescription();\r
- }\r
- }\r
- buf.append(description);\r
+ describedPath(path, registry, buf);\r
buf.append("</h2>");\r
\r
PartSubList subList = (PartSubList) result.getResultParts().get(\r
path);\r
buf.append("<table border=0>\n");\r
+ int displayedIndex = 1;// for display only\r
for (TestResultPart part : subList.getParts()) {\r
SimpleResultPart sPart = (SimpleResultPart) part;\r
String clss = "";\r
} else {\r
clss = "failed";\r
}\r
- buf.append("<tr><td class=\"").append(clss).append("\">");\r
+ buf.append("<tr>");\r
+ buf.append("<td><b>").append(displayedIndex)\r
+ .append("</b></td>");\r
+ buf.append("<td class=\"").append(clss).append("\">");\r
\r
buf.append(sPart.getMessage());\r
- buf.append("</td></tr>\n");\r
+ buf.append("</td>");\r
+ buf.append("</tr>\n");\r
+\r
+ displayedIndex++;\r
}\r
buf.append("</table>\n");\r
+ buf.append("<a class=\"nav\" href=\"#top\">top</a>\n");\r
+ buf.append("<hr/>\n");\r
}\r
}\r
\r
return path.getAsUniqueString().replace(path.getSeparator(), '_');\r
}\r
\r
- private String describedPath(TreePath path, StructureRegistry registry) {\r
- StringBuffer buf = new StringBuffer("");\r
- return buf.toString();\r
+ private void describedPath(TreeSPath path, StructureRegistry registry,\r
+ StringBuffer buf) {\r
+ // StringBuffer buf = new StringBuffer("");\r
+ if (path.getParent() != null) {\r
+ describedPath(path.getParent(), registry, buf);\r
+ }\r
+ String description = path.getName();\r
+ if (registry != null) {\r
+ StructureElement element = registry.getElement(path);\r
+ if (element != null) {\r
+ description = element.getDescription();\r
+ }\r
+ }\r
+ buf.append('/').append(description);\r
}\r
}\r
buf.append("<html><header><title>Results</title></header><body>");\r
buf.append("<header>");\r
buf.append("<title>Results</title>\n");\r
- buf\r
- .append("<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>");\r
+ report.addStyles(buf);\r
buf.append("</header>\n");\r
buf.append("<body>\n");\r
\r
buf.append("<h1>Results</h1>\n");\r
buf.append("<table border=\"0\" cellspacing=\"1\">\n");\r
+ buf.append("<tr><th>Date</th><th>Result Id</th></tr>\n");\r
}\r
\r
void addTestResult(TreeTestResult result) {\r
<head>\r
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">\r
<title>SLC test results</title>\r
-<link href="style.css" rel="stylesheet" type="text/css"/>\r
</head>\r
-<frameset cols="20%,80%">\r
+<frameset cols="30%,70%">\r
<frame src="slc-resultsList.html" name="navigation">\r
<frame src="about:blank" name="main">\r
<noframes>\r
-/* Generic Selectors */\r
body {\r
font-family: sans-serif;\r
font-size: 12px;\r
background-color: white;\r
}\r
\r
-li {\r
- list-style-type: none;\r
-}\r
-\r
h1 {\r
font-family: sans-serif;\r
font-size: 16px;\r
margin: 0px;\r
}\r
\r
-img {\r
- border: none;\r
-}\r
-\r
-div {\r
- font-size: 100%;\r
-}\r
-\r
-tr.list:hover {\r
- background-color: lightgrey;\r
-}\r
-\r
-td.list {\r
- border-top: 1px solid lighgrey;\r
- padding: 2px 20px 2px 2px;\r
- padding-right: 15px;\r
-}\r
-\r
th {\r
font-size: 12px;\r
padding: 2px 20px 2px 2px;\r
color: red;\r
}\r
\r
-/**************** Pseudo classes ****************/\r
a {\r
text-decoration: none;\r
}\r