]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/ResultPartRequest.java
Unique launch
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / msg / test / tree / ResultPartRequest.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.msg.test.tree;
18
19 import java.io.Serializable;
20 import java.util.Map;
21 import java.util.SortedMap;
22
23 import org.argeo.slc.SlcException;
24 import org.argeo.slc.core.structure.tree.TreeSPath;
25 import org.argeo.slc.core.test.SimpleResultPart;
26 import org.argeo.slc.core.test.tree.PartSubList;
27 import org.argeo.slc.core.test.tree.TreeTestResult;
28 import org.argeo.slc.structure.StructureElement;
29 import org.argeo.slc.test.TestRunDescriptor;
30
31 public class ResultPartRequest implements Serializable {
32 private static final long serialVersionUID = -6430135988577074226L;
33 private String resultUuid;
34 private SimpleResultPart resultPart;
35 private TreeSPath path;
36 private Map<TreeSPath, StructureElement> relatedElements;
37 private TestRunDescriptor testRunDescriptor;
38 private Map<String, String> attributes;
39
40 public ResultPartRequest() {
41
42 }
43
44 public ResultPartRequest(TreeTestResult ttr, TreeSPath path,
45 SimpleResultPart resultPart) {
46 resultUuid = ttr.getUuid();
47 this.resultPart = resultPart;
48 this.path = (path != null ? path : ttr.getCurrentPath());
49 relatedElements = ttr.getRelatedElements(this.path);
50 if (ttr.getCurrentTestRun() != null)
51 testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun());
52 attributes = ttr.getAttributes();
53 }
54
55 public ResultPartRequest(TreeTestResult ttr) {
56 resultUuid = ttr.getUuid();
57 this.path = ttr.getCurrentPath();
58
59 PartSubList lst = ttr.getResultParts().get(path);
60 if (lst.getParts().size() < 1) {
61 throw new SlcException("Cannot find part for path " + path
62 + " in result " + resultUuid);
63 }
64
65 this.resultPart = (SimpleResultPart) lst.getParts().get(
66 lst.getParts().size() - 1);
67 relatedElements = ttr.getRelatedElements(path);
68 if (ttr.getCurrentTestRun() != null)
69 testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun());
70 }
71
72 public String getResultUuid() {
73 return resultUuid;
74 }
75
76 public void setResultUuid(String resultUuid) {
77 this.resultUuid = resultUuid;
78 }
79
80 public SimpleResultPart getResultPart() {
81 return resultPart;
82 }
83
84 public void setResultPart(SimpleResultPart resultPart) {
85 this.resultPart = resultPart;
86 }
87
88 public TreeSPath getPath() {
89 return path;
90 }
91
92 public void setPath(TreeSPath path) {
93 this.path = path;
94 }
95
96 public TestRunDescriptor getTestRunDescriptor() {
97 return testRunDescriptor;
98 }
99
100 public void setTestRunDescriptor(TestRunDescriptor testRunDescriptor) {
101 this.testRunDescriptor = testRunDescriptor;
102 }
103
104 public Map<TreeSPath, StructureElement> getRelatedElements() {
105 return relatedElements;
106 }
107
108 public void setRelatedElements(
109 Map<TreeSPath, StructureElement> relatedElements) {
110 this.relatedElements = relatedElements;
111 }
112
113 public Map<String, String> getAttributes() {
114 return attributes;
115 }
116
117 public void setAttributes(SortedMap<String, String> attributes) {
118 this.attributes = attributes;
119 }
120
121 @Override
122 public String toString() {
123 return getClass().getSimpleName() + "#" + resultUuid + " " + path;
124 }
125 }