1 package org
.argeo
.slc
.services
.test
.impl
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
6 import org
.argeo
.slc
.core
.process
.SlcExecution
;
7 import org
.argeo
.slc
.core
.test
.TestRunDescriptor
;
8 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
9 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultCollection
;
10 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
11 import org
.argeo
.slc
.dao
.test
.TestRunDescriptorDao
;
12 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultCollectionDao
;
13 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultDao
;
14 import org
.argeo
.slc
.services
.test
.TestManagerService
;
16 public class TestManagerServiceImpl
implements TestManagerService
{
17 private Log log
= LogFactory
.getLog(getClass());
19 private final TreeTestResultDao treeTestResultDao
;
20 private final TestRunDescriptorDao testRunDescriptorDao
;
21 private final SlcExecutionDao slcExecutionDao
;
22 private final TreeTestResultCollectionDao treeTestResultCollectionDao
;
24 public TestManagerServiceImpl(TreeTestResultDao treeTestResultDao
,
25 TestRunDescriptorDao testRunDescriptorDao
,
26 SlcExecutionDao slcExecutionDao
,
27 TreeTestResultCollectionDao treeTestResultCollectionDao
) {
28 this.treeTestResultDao
= treeTestResultDao
;
29 this.testRunDescriptorDao
= testRunDescriptorDao
;
30 this.slcExecutionDao
= slcExecutionDao
;
31 this.treeTestResultCollectionDao
= treeTestResultCollectionDao
;
34 public void registerTestRunDescriptor(TestRunDescriptor testRunDescriptor
) {
35 if (testRunDescriptor
!= null) {
36 if (log
.isDebugEnabled())
37 log
.debug("Updating test run descriptor with id "
38 + testRunDescriptor
.getTestRunUuid());
40 testRunDescriptorDao
.saveOrUpdate(testRunDescriptor
);
42 // Update tree test result collection
45 if (testRunDescriptor
.getSlcExecutionUuid() != null) {
46 SlcExecution slcExecution
= slcExecutionDao
47 .getSlcExecution(testRunDescriptor
48 .getSlcExecutionUuid());
49 if (slcExecution
!= null) {
50 addResultToCollection(slcExecution
.getUser(),
51 testRunDescriptor
.getTestResultUuid());
57 public void addResultToCollection(String collectionId
, String resultUuid
) {
58 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
59 .getTestResultCollection(collectionId
);
61 ttrc
= new TreeTestResultCollection(collectionId
);
62 treeTestResultCollectionDao
.create(ttrc
);
64 TreeTestResult ttr
= treeTestResultDao
.getTestResult(resultUuid
);
65 ttrc
.getResults().add(ttr
);
66 treeTestResultCollectionDao
.update(ttrc
);
69 public void removeResultFromCollection(String collectionId
,
71 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
72 .getTestResultCollection(collectionId
);
74 TreeTestResult ttr
= treeTestResultDao
.getTestResult(resultUuid
);
75 if (ttrc
.getResults().remove(ttr
)) {
76 treeTestResultCollectionDao
.update(ttrc
);