]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/ant/test/ParentContextType.java
Introduce org.argeo.slc.lib.detached
[gpl/argeo-slc.git] / runtime / org.argeo.slc.launcher / src / main / java / org / argeo / slc / ant / test / ParentContextType.java
1 package org.argeo.slc.ant.test;
2
3 import java.util.Collection;
4 import java.util.List;
5 import java.util.Map;
6 import java.util.Vector;
7
8 import org.apache.tools.ant.types.DataType;
9
10 import org.argeo.slc.ant.spring.MapArg;
11 import org.argeo.slc.core.SlcException;
12 import org.argeo.slc.core.test.context.ContextAware;
13 import org.argeo.slc.core.test.context.ContextUtils;
14 import org.argeo.slc.core.test.context.ParentContextAware;
15
16 public class ParentContextType extends DataType implements ParentContextAware {
17 private MapArg values = null;
18 private MapArg expectedValues = null;
19
20 private String contextAnyFlag = DEFAULT_ANY_FLAG;
21 private String contextSkipFlag = DEFAULT_SKIP_FLAG;
22
23 private String basedon = null;
24
25 private List<ContextAware> children = new Vector<ContextAware>();
26
27 public MapArg createValues() {
28 values = new MapArg();
29 return values;
30 }
31
32 public MapArg createExpectedValues() {
33 expectedValues = new MapArg();
34 return expectedValues;
35 }
36
37 public void addChildContext(ContextAware contextAware) {
38 children.add(contextAware);
39 }
40
41 public Collection<ContextAware> getChildContexts() {
42 return children;
43 }
44
45 public String getContextAnyFlag() {
46 return contextAnyFlag;
47 }
48
49 public void setContextAnyFlag(String contextAnyFlag) {
50 this.contextAnyFlag = contextAnyFlag;
51 }
52
53 public String getContextSkipFlag() {
54 return contextSkipFlag;
55 }
56
57 public void setContextSkipFlag(String contextSkipFlag) {
58 this.contextSkipFlag = contextSkipFlag;
59 }
60
61 public Map<String, Object> getExpectedValues() {
62 if (expectedValues == null)
63 expectedValues = new MapArg();
64 if (basedon != null) {
65 Map<String, Object> map = getBaseContext().getExpectedValues();
66 ContextUtils.putNotContained(expectedValues.getMap(), map);
67 }
68 return expectedValues.getMap();
69 }
70
71 public Map<String, Object> getValues() {
72 if (values == null)
73 values = new MapArg();
74 if (basedon != null) {
75 Map<String, Object> map = getBaseContext().getValues();
76 ContextUtils.putNotContained(values.getMap(), map);
77 }
78 return values.getMap();
79 }
80
81 private ParentContextType getBaseContext() {
82 return (ParentContextType) getProject().getReference(basedon);
83 }
84
85 public void setValues(Map<String, Object> values) {
86 throw new SlcException("Cannot override values map.");
87 }
88
89 public void setUpdateValues(Map<String, Object> overrideValues) {
90 getValues().putAll(overrideValues);
91 }
92
93 public void setUpdateExpectedValues(
94 Map<String, Object> overrideExpectedValues) {
95 getExpectedValues().putAll(overrideExpectedValues);
96 }
97
98 public void setBasedon(String basedon) {
99 this.basedon = basedon;
100 }
101
102 }