X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FTreeTestResultPersister.java;h=ca92b49084e9f045fcc5ed824e2d1b0987a2b7d5;hb=b5c4e0c9c2fcf788a56d6ce72989fe15182e057d;hp=0c32a1a4cfd82caf5a743400e3844c4a66237e24;hpb=6eb8dbec55c0cb31407907860ba6de627243b8af;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultPersister.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultPersister.java index 0c32a1a4c..ca92b4908 100644 --- a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultPersister.java +++ b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultPersister.java @@ -4,7 +4,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.StructureElement; import org.argeo.slc.core.structure.StructureRegistry; import org.argeo.slc.core.structure.tree.TreeSPath; import org.argeo.slc.core.structure.tree.TreeSRegistry; @@ -32,16 +31,9 @@ public class TreeTestResultPersister extends AsynchronousTreeTestResultListener TreeSPath path = treeSPathDao.getOrCreate(partStruct.path); + StructureRegistry localRegistry = partStruct.result.getRegistry(); TreeSRegistry registry = getOrCreateTreeSRegistry(path); - if (registry.getElement(path) == null) { - StructureRegistry localRegistry = partStruct.result - .getRegistry(); - if (localRegistry != null) { - registry.register(path, localRegistry.getElement(path)); - } else { - registry.register(path, new SimpleSElement(path.getName())); - } - } + syncPath(registry, localRegistry, path); if (persistedResult == null) { persistedResult = new TreeTestResult(); @@ -76,6 +68,20 @@ public class TreeTestResultPersister extends AsynchronousTreeTestResultListener } } + @Override + protected void postClose(TreeTestResult testResult) { + TreeTestResult persistedResult = (TreeTestResult) testResultDao + .getTestResult(testResult.getTestResultId()); + + if (persistedResult != null) { + persistedResult.setCloseDate(testResult.getCloseDate()); + testResultDao.update(persistedResult); + } + if (log.isDebugEnabled()) + log.debug("Closed result persister for result " + + testResult.getNumericResultId()); + } + private TreeSRegistry getOrCreateTreeSRegistry(TreeSPath path) { TreeSRegistry registry = treeSRegistryDao.getTreeSRegistry(path); if (registry == null) { @@ -89,17 +95,36 @@ public class TreeTestResultPersister extends AsynchronousTreeTestResultListener } } - /** Sets the dao to use in order to persist the results. */ + /** Sets the DAO to use in order to persist the results. */ public void setTestResultDao(TestResultDao testResultDao) { this.testResultDao = testResultDao; } + /** Sets the tree structure path DAO. */ public void setTreeSPathDao(TreeSPathDao treeSPathDao) { this.treeSPathDao = treeSPathDao; } + /** Sets the tree structure registry DAO. */ public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) { this.treeSRegistryDao = treeSRegistryDao; } + private void syncPath(TreeSRegistry registry, + StructureRegistry localRegistry, TreeSPath path) { + if (path.getParent() != null) { + TreeSPath parent = treeSPathDao.getOrCreate(path.getParent()); + syncPath(registry, localRegistry, parent); + } + + if (registry.getElement(path) == null) { + if (localRegistry != null) { + registry.register(path, localRegistry.getElement(path)); + } else { + registry.register(path, new SimpleSElement(path.getName())); + } + treeSRegistryDao.update(registry); + } + + } }