]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultPersister.java
Unique launch
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / dao / test / tree / TreeTestResultPersister.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc.dao.test.tree;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21
22 import org.argeo.slc.core.test.tree.TreeTestResult;
23 import org.argeo.slc.test.TestResultListener;
24 import org.argeo.slc.test.TestResultPart;
25
26 /**
27 * Listener persisting tree-based results.
28 *
29 * @see TreeTestResult
30 */
31 @Deprecated
32 public class TreeTestResultPersister implements
33 TestResultListener<TreeTestResult> {
34 private static Log log = LogFactory.getLog(TreeTestResultPersister.class);
35
36 private TreeTestResultDao testResultDao;
37
38 public void resultPartAdded(TreeTestResult testResult,
39 TestResultPart testResultPart) {
40 try {
41 TreeTestResult persistedResult = testResultDao
42 .getTestResult(testResult.getUuid());
43
44 if (persistedResult == null) {
45 testResultDao.create(testResult);
46 } else {
47 testResultDao.update(testResult);
48 }
49 } catch (Exception e) {
50 log.error("Could not persist result part " + testResultPart
51 + " for result " + testResult.getUuid());
52 }
53 }
54
55 public void close(TreeTestResult testResult) {
56 TreeTestResult persistedResult = (TreeTestResult) testResultDao
57 .getTestResult(testResult.getUuid());
58
59 if (persistedResult != null) {
60 persistedResult.setCloseDate(testResult.getCloseDate());
61 testResultDao.update(persistedResult);
62 }
63 if (log.isDebugEnabled())
64 log.debug("Closed result persister for result "
65 + testResult.getUuid());
66 }
67
68 /** Sets the DAO to use in order to persist the results. */
69 public void setTestResultDao(TreeTestResultDao testResultDao) {
70 this.testResultDao = testResultDao;
71 }
72 }