import org.apache.commons.logging.LogFactory;\r
\r
import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureElement;\r
import org.argeo.slc.core.structure.StructureRegistry;\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
\r
TreeSPath path = treeSPathDao.getOrCreate(partStruct.path);\r
\r
+ StructureRegistry localRegistry = partStruct.result.getRegistry();\r
TreeSRegistry registry = getOrCreateTreeSRegistry(path);\r
- if (registry.getElement(path) == null) {\r
- StructureRegistry localRegistry = partStruct.result\r
- .getRegistry();\r
- if (localRegistry != null) {\r
- registry.register(path, localRegistry.getElement(path));\r
- } else {\r
- registry.register(path, new SimpleSElement(path.getName()));\r
- }\r
- }\r
+ syncPath(registry, localRegistry, path);\r
\r
if (persistedResult == null) {\r
persistedResult = new TreeTestResult();\r
}\r
}\r
\r
+ @Override\r
+ protected void postClose(TreeTestResult testResult) {\r
+ TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
+ .getTestResult(testResult.getTestResultId());\r
+\r
+ if (persistedResult != null) {\r
+ persistedResult.setCloseDate(testResult.getCloseDate());\r
+ testResultDao.update(persistedResult);\r
+ }\r
+ if (log.isDebugEnabled())\r
+ log.debug("Closed result persister for result "\r
+ + testResult.getNumericResultId());\r
+ }\r
+\r
private TreeSRegistry getOrCreateTreeSRegistry(TreeSPath path) {\r
TreeSRegistry registry = treeSRegistryDao.getTreeSRegistry(path);\r
if (registry == null) {\r
}\r
}\r
\r
- /** Sets the dao to use in order to persist the results. */\r
+ /** Sets the DAO to use in order to persist the results. */\r
public void setTestResultDao(TestResultDao testResultDao) {\r
this.testResultDao = testResultDao;\r
}\r
\r
+ /** Sets the tree structure path DAO. */\r
public void setTreeSPathDao(TreeSPathDao treeSPathDao) {\r
this.treeSPathDao = treeSPathDao;\r
}\r
\r
+ /** Sets the tree structure registry DAO. */\r
public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
this.treeSRegistryDao = treeSRegistryDao;\r
}\r
\r
+ private void syncPath(TreeSRegistry registry,\r
+ StructureRegistry localRegistry, TreeSPath path) {\r
+ if (path.getParent() != null) {\r
+ TreeSPath parent = treeSPathDao.getOrCreate(path.getParent());\r
+ syncPath(registry, localRegistry, parent);\r
+ }\r
+\r
+ if (registry.getElement(path) == null) {\r
+ if (localRegistry != null) {\r
+ registry.register(path, localRegistry.getElement(path));\r
+ } else {\r
+ registry.register(path, new SimpleSElement(path.getName()));\r
+ }\r
+ treeSRegistryDao.update(registry);\r
+ }\r
+\r
+ }\r
}\r