2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.slc
.msg
.test
.tree
;
19 import java
.io
.Serializable
;
21 import java
.util
.SortedMap
;
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
;
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
;
40 public ResultPartRequest() {
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();
55 public ResultPartRequest(TreeTestResult ttr
) {
56 resultUuid
= ttr
.getUuid();
57 this.path
= ttr
.getCurrentPath();
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
);
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());
72 public String
getResultUuid() {
76 public void setResultUuid(String resultUuid
) {
77 this.resultUuid
= resultUuid
;
80 public SimpleResultPart
getResultPart() {
84 public void setResultPart(SimpleResultPart resultPart
) {
85 this.resultPart
= resultPart
;
88 public TreeSPath
getPath() {
92 public void setPath(TreeSPath path
) {
96 public TestRunDescriptor
getTestRunDescriptor() {
97 return testRunDescriptor
;
100 public void setTestRunDescriptor(TestRunDescriptor testRunDescriptor
) {
101 this.testRunDescriptor
= testRunDescriptor
;
104 public Map
<TreeSPath
, StructureElement
> getRelatedElements() {
105 return relatedElements
;
108 public void setRelatedElements(
109 Map
<TreeSPath
, StructureElement
> relatedElements
) {
110 this.relatedElements
= relatedElements
;
113 public Map
<String
, String
> getAttributes() {
117 public void setAttributes(SortedMap
<String
, String
> attributes
) {
118 this.attributes
= attributes
;
122 public String
toString() {
123 return getClass().getSimpleName() + "#" + resultUuid
+ " " + path
;