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
44 SlcExecution slcExecution
= slcExecutionDao
45 .getSlcExecution(testRunDescriptor
.getSlcExecutionUuid());
46 if (slcExecution
!= null) {
47 addResultToCollection(slcExecution
.getUser(), testRunDescriptor
48 .getTestResultUuid());
53 public void addResultToCollection(String collectionId
, String resultUuid
) {
54 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
55 .getTestResultCollection(collectionId
);
57 ttrc
= new TreeTestResultCollection(collectionId
);
58 treeTestResultCollectionDao
.create(ttrc
);
60 TreeTestResult ttr
= treeTestResultDao
.getTestResult(resultUuid
);
61 ttrc
.getResults().add(ttr
);
62 treeTestResultCollectionDao
.update(ttrc
);
65 public void removeResultFromCollection(String collectionId
,
67 TreeTestResultCollection ttrc
= treeTestResultCollectionDao
68 .getTestResultCollection(collectionId
);
70 TreeTestResult ttr
= treeTestResultDao
.getTestResult(resultUuid
);
71 if (ttrc
.getResults().remove(ttr
)) {
72 treeTestResultCollectionDao
.update(ttrc
);