package org.argeo.slc.hibernate.test.tree;\r
\r
+import java.util.Date;\r
import java.util.List;\r
\r
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
\r
+import org.argeo.slc.core.SlcException;\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.NumericTRId;\r
import org.argeo.slc.core.test.TestResult;\r
getHibernateTemplate().saveOrUpdate(testResult);\r
}\r
\r
- public TestResult getTestResult(TestResultId id) {\r
- NumericTRId ntrid = (NumericTRId) id;\r
+ public TreeTestResult getTestResult(String uuid) {\r
List<?> list = getHibernateTemplate().find(\r
- "from TreeTestResult where numericResultId.value=?",\r
- ntrid.getValue());\r
+ "from TreeTestResult where uuid=?", uuid);\r
if (list.size() == 0) {\r
return null;\r
} else {\r
- return (TestResult) list.get(0);\r
+ return (TreeTestResult) list.get(0);\r
}\r
\r
}\r
\r
- public List<TestResult> listTestResults() {\r
- return (List<TestResult>) getHibernateTemplate().find(\r
+ public List<TreeTestResult> listTestResults() {\r
+ return (List<TreeTestResult>) getHibernateTemplate().find(\r
"from TreeTestResult");\r
}\r
\r
public List<TreeTestResult> listResults(TreeSPath path) {\r
List<TreeTestResult> list = getHibernateTemplate().find(\r
"from TreeTestResult res where ? in indices(res.resultParts)",\r
- path);\r
+ path.getAsUniqueString());\r
return list;\r
}\r
\r
+ public void close(String id, Date closeDate) {\r
+// TreeTestResult ttr = (TreeTestResult) getHibernateTemplate().load(\r
+// TreeTestResult.class, id);\r
+ TreeTestResult ttr = getTestResult(id);\r
+ if (ttr != null) {\r
+ ttr.setCloseDate(closeDate);\r
+ getHibernateTemplate().update(ttr);\r
+ } else {\r
+ throw new SlcException("Result with id " + id\r
+ + " could not be closed because it was not found.");\r
+ }\r
+ }\r
+\r
}\r