1 package org
.argeo
.slc
.services
.impl
.test
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
6 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultCollection
;
7 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
8 import org
.argeo
.slc
.dao
.test
.TestRunDescriptorDao
;
9 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultCollectionDao
;
10 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultDao
;
11 import org
.argeo
.slc
.msg
.test
.tree
.AddTreeTestResultAttachmentRequest
;
12 import org
.argeo
.slc
.msg
.test
.tree
.CloseTreeTestResultRequest
;
13 import org
.argeo
.slc
.msg
.test
.tree
.CreateTreeTestResultRequest
;
14 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
15 import org
.argeo
.slc
.process
.SlcExecution
;
16 import org
.argeo
.slc
.services
.test
.TestManagerService
;
17 import org
.argeo
.slc
.test
.TestRunDescriptor
;
19 /** Implementation of complex operations impacting the underlying data. */
20 public class TestManagerServiceImpl
implements TestManagerService
{
21 private Log log
= LogFactory
.getLog(getClass());
23 private final TreeTestResultDao treeTestResultDao
;
24 private final TestRunDescriptorDao testRunDescriptorDao
;
25 private final SlcExecutionDao slcExecutionDao
;
26 private final TreeTestResultCollectionDao treeTestResultCollectionDao
;
28 public TestManagerServiceImpl(TreeTestResultDao treeTestResultDao
,
29 TestRunDescriptorDao testRunDescriptorDao
,
30 SlcExecutionDao slcExecutionDao
,
31 TreeTestResultCollectionDao treeTestResultCollectionDao
) {
32 this.treeTestResultDao
= treeTestResultDao
;
33 this.testRunDescriptorDao
= testRunDescriptorDao
;
34 this.slcExecutionDao
= slcExecutionDao
;
35 this.treeTestResultCollectionDao
= treeTestResultCollectionDao
;
38 public void registerTestRunDescriptor(TestRunDescriptor testRunDescriptor
) {
39 if (testRunDescriptor
!= null) {
40 if (log
.isTraceEnabled())
41 log
.trace("Registering test run descriptor #"
42 + testRunDescriptor
.getTestRunUuid());
43 testRunDescriptorDao
.saveOrUpdate(testRunDescriptor
);
45 // Update tree test result collection
48 if (testRunDescriptor
.getSlcExecutionUuid() != null) {
49 SlcExecution slcExecution
= slcExecutionDao
50 .getSlcExecution(testRunDescriptor
51 .getSlcExecutionUuid());
52 if (slcExecution
!= null) {
53 String collectionId
= slcExecution
.getUser() != null ? slcExecution
56 addResultToCollection(collectionId
, testRunDescriptor
57 .getTestResultUuid());
62 + testRunDescriptor
.getTestResultUuid());
63 addResultToCollection("default", testRunDescriptor
64 .getTestResultUuid());
69 public void addResultToCollection(String collectionId
, String resultUuid
) {
70 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
71 .getTestResultCollection(collectionId
);
73 ttrc
= new TreeTestResultCollection(collectionId
);
74 treeTestResultCollectionDao
.create(ttrc
);
76 treeTestResultCollectionDao
.addResultToCollection(ttrc
, resultUuid
);
79 public void removeResultFromCollection(String collectionId
,
81 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
82 .getTestResultCollection(collectionId
);
84 treeTestResultCollectionDao
.removeResultFromCollection(ttrc
,
88 // Delete collection if empty
89 // see https://www.argeo.org/bugzilla/show_bug.cgi?id=74
90 if (ttrc
.getResults().size() == 0) {
91 treeTestResultCollectionDao
.delete(ttrc
);
95 public void createTreeTestResult(CreateTreeTestResultRequest msg
) {
96 TreeTestResult treeTestResult
= msg
.getTreeTestResult();
98 if (log
.isTraceEnabled())
99 log
.trace("Creating result #" + treeTestResult
.getUuid());
100 treeTestResultDao
.create(treeTestResult
);
102 registerTestRunDescriptor(msg
.getTestRunDescriptor());
105 public void addResultPart(ResultPartRequest msg
) {
106 // registerTestRunDescriptor(msg.getTestRunDescriptor());
108 if (log
.isTraceEnabled())
109 log
.trace("Adding result part to test result #"
110 + msg
.getResultUuid());
112 treeTestResultDao
.addResultPart(msg
.getResultUuid(), msg
.getPath(), msg
113 .getResultPart(), msg
.getRelatedElements());
114 // treeTestResultDao.updateAttributes(msg.getResultUuid(), msg
115 // .getAttributes());
118 public void closeTreeTestResult(CloseTreeTestResultRequest msg
) {
119 if (log
.isTraceEnabled())
120 log
.trace("Closing result #" + msg
.getResultUuid() + " at date "
121 + msg
.getCloseDate());
123 treeTestResultDao
.close(msg
.getResultUuid(), msg
.getCloseDate());
126 public void addAttachment(AddTreeTestResultAttachmentRequest msg
) {
127 if (log
.isTraceEnabled())
128 log
.trace("Adding attachment " + msg
.getAttachment()
129 + " to result #" + msg
.getResultUuid());
130 treeTestResultDao
.addAttachment(msg
.getResultUuid(), msg