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
.TreeTestResultCollection
;
6 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
7 import org
.argeo
.slc
.dao
.test
.TestRunDescriptorDao
;
8 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultCollectionDao
;
9 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultDao
;
10 import org
.argeo
.slc
.process
.SlcExecution
;
11 import org
.argeo
.slc
.services
.test
.TestManagerService
;
12 import org
.argeo
.slc
.test
.TestRunDescriptor
;
14 /** Implementation of complex operations impacting the underlying data. */
15 public class TestManagerServiceImpl
implements TestManagerService
{
16 private Log log
= LogFactory
.getLog(getClass());
18 private final TreeTestResultDao treeTestResultDao
;
19 private final TestRunDescriptorDao testRunDescriptorDao
;
20 private final SlcExecutionDao slcExecutionDao
;
21 private final TreeTestResultCollectionDao treeTestResultCollectionDao
;
23 public TestManagerServiceImpl(TreeTestResultDao treeTestResultDao
,
24 TestRunDescriptorDao testRunDescriptorDao
,
25 SlcExecutionDao slcExecutionDao
,
26 TreeTestResultCollectionDao treeTestResultCollectionDao
) {
27 this.treeTestResultDao
= treeTestResultDao
;
28 this.testRunDescriptorDao
= testRunDescriptorDao
;
29 this.slcExecutionDao
= slcExecutionDao
;
30 this.treeTestResultCollectionDao
= treeTestResultCollectionDao
;
33 public void registerTestRunDescriptor(TestRunDescriptor testRunDescriptor
) {
34 if (testRunDescriptor
!= null) {
35 testRunDescriptorDao
.saveOrUpdate(testRunDescriptor
);
37 // Update tree test result collection
40 if (testRunDescriptor
.getSlcExecutionUuid() != null) {
41 SlcExecution slcExecution
= slcExecutionDao
42 .getSlcExecution(testRunDescriptor
43 .getSlcExecutionUuid());
44 if (slcExecution
!= null) {
45 String collectionId
= slcExecution
.getUser() != null ? slcExecution
48 addResultToCollection(collectionId
, testRunDescriptor
49 .getTestResultUuid());
55 public void addResultToCollection(String collectionId
, String resultUuid
) {
56 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
57 .getTestResultCollection(collectionId
);
59 ttrc
= new TreeTestResultCollection(collectionId
);
60 treeTestResultCollectionDao
.create(ttrc
);
62 treeTestResultCollectionDao
.addResultToCollection(ttrc
, resultUuid
);
65 public void removeResultFromCollection(String collectionId
,
67 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
68 .getTestResultCollection(collectionId
);
70 treeTestResultCollectionDao
.removeResultFromCollection(ttrc
,
74 // Delete collection if empty
75 // see https://www.argeo.org/bugzilla/show_bug.cgi?id=74
76 if (ttrc
.getResults().size() == 0) {
77 treeTestResultCollectionDao
.delete(ttrc
);