]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/services/impl/test/TestManagerServiceImpl.java
Clean up server OSGi
[gpl/argeo-slc.git] / runtime / org.argeo.slc.server / src / main / java / org / argeo / slc / services / impl / test / TestManagerServiceImpl.java
diff --git a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/services/impl/test/TestManagerServiceImpl.java b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/services/impl/test/TestManagerServiceImpl.java
deleted file mode 100644 (file)
index 59b7b37..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.argeo.slc.services.impl.test;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.core.test.tree.TreeTestResultCollection;\r
-import org.argeo.slc.dao.process.SlcExecutionDao;\r
-import org.argeo.slc.dao.test.TestRunDescriptorDao;\r
-import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao;\r
-import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
-import org.argeo.slc.msg.test.tree.AddTreeTestResultAttachmentRequest;\r
-import org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.ResultPartRequest;\r
-import org.argeo.slc.process.SlcExecution;\r
-import org.argeo.slc.services.test.TestManagerService;\r
-import org.argeo.slc.test.TestRunDescriptor;\r
-\r
-/**\r
- * Implementation of complex operations impacting the underlying data.\r
- */\r
-public class TestManagerServiceImpl implements TestManagerService {\r
-       private Log log = LogFactory.getLog(getClass());\r
-\r
-       private final TreeTestResultDao treeTestResultDao;\r
-       private final TestRunDescriptorDao testRunDescriptorDao;\r
-       private final SlcExecutionDao slcExecutionDao;\r
-       private final TreeTestResultCollectionDao treeTestResultCollectionDao;\r
-\r
-       public TestManagerServiceImpl(TreeTestResultDao treeTestResultDao,\r
-                       TestRunDescriptorDao testRunDescriptorDao,\r
-                       SlcExecutionDao slcExecutionDao,\r
-                       TreeTestResultCollectionDao treeTestResultCollectionDao) {\r
-               this.treeTestResultDao = treeTestResultDao;\r
-               this.testRunDescriptorDao = testRunDescriptorDao;\r
-               this.slcExecutionDao = slcExecutionDao;\r
-               this.treeTestResultCollectionDao = treeTestResultCollectionDao;\r
-       }\r
-\r
-       public void registerTestRunDescriptor(TestRunDescriptor testRunDescriptor) {\r
-               if (testRunDescriptor != null) {\r
-                       if (log.isTraceEnabled())\r
-                               log.trace("Registering test run descriptor #"\r
-                                               + testRunDescriptor.getTestRunUuid());\r
-                       testRunDescriptorDao.saveOrUpdate(testRunDescriptor);\r
-\r
-                       // Update tree test result collection\r
-                       // TODO: optimize\r
-\r
-                       if (testRunDescriptor.getSlcExecutionUuid() != null) {\r
-                               SlcExecution slcExecution = slcExecutionDao\r
-                                               .getSlcExecution(testRunDescriptor\r
-                                                               .getSlcExecutionUuid());\r
-                               if (slcExecution != null) {\r
-                                       String collectionId = slcExecution.getUser() != null ? slcExecution\r
-                                                       .getUser()\r
-                                                       : "default";\r
-                                       addResultToCollection(collectionId, testRunDescriptor\r
-                                                       .getTestResultUuid());\r
-                               }\r
-                       } else {\r
-                               if (log.isTraceEnabled())\r
-                                       log.trace("ResultUUID="\r
-                                                       + testRunDescriptor.getTestResultUuid());\r
-                               addResultToCollection("default", testRunDescriptor\r
-                                               .getTestResultUuid());\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void addResultToCollection(String collectionId, String resultUuid) {\r
-               // TODO: improve collections\r
-               TreeTestResultCollection ttrc = treeTestResultCollectionDao\r
-                               .getTestResultCollection(collectionId);\r
-               if (ttrc == null) {\r
-                       ttrc = new TreeTestResultCollection(collectionId);\r
-                       treeTestResultCollectionDao.create(ttrc);\r
-               }\r
-               treeTestResultCollectionDao.addResultToCollection(ttrc, resultUuid);\r
-       }\r
-\r
-       public void removeResultFromCollection(String collectionId,\r
-                       String resultUuid) {\r
-               TreeTestResultCollection ttrc = treeTestResultCollectionDao\r
-                               .getTestResultCollection(collectionId);\r
-               if (ttrc != null) {\r
-                       treeTestResultCollectionDao.removeResultFromCollection(ttrc,\r
-                                       resultUuid);\r
-               }\r
-\r
-               // Delete collection if empty\r
-               // see https://www.argeo.org/bugzilla/show_bug.cgi?id=74\r
-               if (ttrc.getResults().size() == 0) {\r
-                       treeTestResultCollectionDao.delete(ttrc);\r
-               }\r
-       }\r
-\r
-       public void createTreeTestResult(CreateTreeTestResultRequest msg) {\r
-               TreeTestResult treeTestResult = msg.getTreeTestResult();\r
-\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Creating result #" + treeTestResult.getUuid());\r
-               treeTestResultDao.create(treeTestResult);\r
-\r
-               registerTestRunDescriptor(msg.getTestRunDescriptor());\r
-\r
-               // FIXME: temporary hack before better collection management is found\r
-               if (msg.getTestRunDescriptor() == null) {\r
-                       addResultToCollection("default", treeTestResult.getUuid());\r
-               }\r
-       }\r
-\r
-       public void addResultPart(ResultPartRequest msg) {\r
-               // registerTestRunDescriptor(msg.getTestRunDescriptor());\r
-\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Adding result part to test result #"\r
-                                       + msg.getResultUuid());\r
-\r
-               treeTestResultDao.addResultPart(msg.getResultUuid(), msg.getPath(), msg\r
-                               .getResultPart(), msg.getRelatedElements());\r
-               // treeTestResultDao.updateAttributes(msg.getResultUuid(), msg\r
-               // .getAttributes());\r
-       }\r
-\r
-       public void closeTreeTestResult(CloseTreeTestResultRequest msg) {\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Closing result #" + msg.getResultUuid() + " at date "\r
-                                       + msg.getCloseDate());\r
-\r
-               treeTestResultDao.close(msg.getResultUuid(), msg.getCloseDate());\r
-       }\r
-\r
-       public void addAttachment(AddTreeTestResultAttachmentRequest msg) {\r
-               if (log.isTraceEnabled())\r
-                       log.trace("Adding attachment " + msg.getAttachment()\r
-                                       + " to result #" + msg.getResultUuid());\r
-               treeTestResultDao.addAttachment(msg.getResultUuid(), msg\r
-                               .getAttachment());\r
-\r
-       }\r
-\r
-}\r