- roots[0] = new ResultFolder(null,\r
- SlcJcrResultUtils.getMyResultParentNode(session),\r
- "My results");\r
- Node otherResultsPar = session.getNode(SlcJcrResultUtils\r
- .getSlcResultsBasePath(session));\r
- roots[1] = new SimpleNodeFolder(null, otherResultsPar,\r
- "All results");\r
- return roots;\r
+ if (session.nodeExists(SlcJcrResultUtils\r
+ .getSlcResultsBasePath(session))) {\r
+ ResultParent[] roots = new ResultParent[5];\r
+\r
+ // My results\r
+ roots[0] = new ParentNodeFolder(null,\r
+ SlcJcrResultUtils.getMyResultParentNode(session),\r
+ "My results");\r
+\r
+ // today\r
+ Calendar cal = Calendar.getInstance();\r
+ String relPath = JcrUtils.dateAsPath(cal);\r
+ List<String> datePathes = new ArrayList<String>();\r
+ datePathes.add(relPath);\r
+ roots[1] = new VirtualFolder(null,\r
+ ResultParentUtils.getResultsForDates(session,\r
+ datePathes), "Today");\r
+\r
+ // Yesterday\r
+ cal = Calendar.getInstance();\r
+ cal.add(Calendar.DAY_OF_YEAR, -1);\r
+ relPath = JcrUtils.dateAsPath(cal);\r
+ datePathes = new ArrayList<String>();\r
+ datePathes.add(relPath);\r
+ roots[2] = new VirtualFolder(null,\r
+ ResultParentUtils.getResultsForDates(session,\r
+ datePathes), "Yesterday");\r
+ // Last 7 days\r
+\r
+ cal = Calendar.getInstance();\r
+ datePathes = new ArrayList<String>();\r
+\r
+ for (int i = 0; i < 7; i++) {\r
+ cal.add(Calendar.DAY_OF_YEAR, -i);\r
+ relPath = JcrUtils.dateAsPath(cal);\r
+ datePathes.add(relPath);\r
+ }\r
+ roots[3] = new VirtualFolder(null,\r
+ ResultParentUtils.getResultsForDates(session,\r
+ datePathes), "Last 7 days");\r
+\r
+ // All results\r
+ Node otherResultsPar = session.getNode(SlcJcrResultUtils\r
+ .getSlcResultsBasePath(session));\r
+ roots[4] = new ParentNodeFolder(null, otherResultsPar,\r
+ "All results");\r
+ return roots;\r
+ } else\r
+ // no test has yet been processed, we leave the viewer blank\r
+ return null;\r