+\r
+ @SuppressWarnings("unchecked")\r
+ public List<TreeTestResult> listResults(String collectionId,\r
+ Map<String, String> attributes) {\r
+ List<TreeTestResult> list;\r
+\r
+ if (collectionId == null) {\r
+ if (attributes == null || attributes.size() == 0)\r
+ list = getHibernateTemplate().find("from TreeTestResult");\r
+ else if (attributes.size() == 1) {\r
+ Map.Entry<String, String> entry = attributes.entrySet()\r
+ .iterator().next();\r
+ Object[] args = { entry.getKey(), entry.getValue() };\r
+ list = getHibernateTemplate().find(\r
+ "select ttr from TreeTestResult ttr"\r
+ + " where attributes[?]=?", args);\r
+ } else {\r
+ throw new SlcException(\r
+ "Multiple attributes filter are currently not supported.");\r
+ }\r
+ } else {\r
+ if (attributes == null || attributes.size() == 0)\r
+ list = getHibernateTemplate()\r
+ .find(\r
+ "select ttr "\r
+ + " from TreeTestResult ttr, TreeTestResultCollection ttrc "\r
+ + " where ttr in elements(ttrc.results) and ttrc.id=?",\r
+ collectionId);\r
+ else if (attributes.size() == 1) {\r
+ Map.Entry<String, String> entry = attributes.entrySet()\r
+ .iterator().next();\r
+ Object[] args = { collectionId, entry.getKey(),\r
+ entry.getValue() };\r
+ list = getHibernateTemplate()\r
+ .find(\r
+ "select ttr from TreeTestResult ttr, TreeTestResultCollection ttrc "\r
+ + " where ttr in elements(ttrc.results) and ttrc.id=?"\r
+ + " and attributes[?]=?", args);\r
+ } else {\r
+ throw new SlcException(\r
+ "Multiple attributes filter are currently not supported.");\r
+ }\r
+ }\r
+ return list;\r
+ }\r