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
import org.argeo.slc.dao.structure.tree.TreeSPathDao;\r
import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
import org.argeo.slc.dao.test.TestResultDao;\r
+import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
\r
/**\r
* Listener persisting tree-based results.\r
public class TreeTestResultPersister extends AsynchronousTreeTestResultListener {\r
private static Log log = LogFactory.getLog(TreeTestResultPersister.class);\r
\r
- private TestResultDao testResultDao;\r
+ private TreeTestResultDao testResultDao;\r
private TreeSPathDao treeSPathDao;\r
private TreeSRegistryDao treeSRegistryDao;\r
\r
@Override\r
protected void resultPartAdded(PartStruct partStruct) {\r
try {\r
- TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
+ TreeTestResult persistedResult = testResultDao\r
.getTestResult(partStruct.resultId);\r
-\r
+ \r
+ if(persistedResult==null){\r
+ testResultDao.create(partStruct.result);\r
+ }\r
+ else{\r
+ testResultDao.update(partStruct.result);\r
+ }\r
+/*\r
TreeSPath path = treeSPathDao.getOrCreate(partStruct.path);\r
\r
- StructureRegistry localRegistry = partStruct.result.getRegistry();\r
+ StructureRegistry<TreeSPath> localRegistry = partStruct.result\r
+ .getRegistry();\r
TreeSRegistry registry = getOrCreateTreeSRegistry(path);\r
- syncPath(registry, localRegistry, path);\r
+ treeSRegistryDao.syncPath(registry, localRegistry, path);\r
\r
if (persistedResult == null) {\r
persistedResult = new TreeTestResult();\r
log.trace("Part: " + partStruct.part);\r
}\r
testResultDao.update(persistedResult);\r
- }\r
+ }*/\r
} catch (Exception e) {\r
log.error("Could not persist part for result #"\r
+ partStruct.resultId, e);\r
TreeSRegistry registry = treeSRegistryDao.getActiveTreeSRegistry();\r
if (registry == null) {\r
registry = new TreeSRegistry();\r
- TreeSPath root = treeSPathDao.getOrCreate(path.getRoot());\r
registry.setStatus(TreeSRegistry.STATUS_ACTIVE);\r
treeSRegistryDao.create(registry);\r
return treeSRegistryDao.getActiveTreeSRegistry();\r
}\r
\r
/** Sets the DAO to use in order to persist the results. */\r
- public void setTestResultDao(TestResultDao testResultDao) {\r
+ public void setTestResultDao(TreeTestResultDao testResultDao) {\r
this.testResultDao = testResultDao;\r
}\r
\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