Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java @ 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 09 Oct 2009 07:54:48 +0000 |
parents | ef157bd2fa92 |
children | 4896d4f94bdc |
comparison
equal
deleted
inserted
replaced
170:7be22e76c270 | 171:7fb9441dd8af |
---|---|
19 import de.intevation.gnv.geobackend.base.Result; | 19 import de.intevation.gnv.geobackend.base.Result; |
20 import de.intevation.gnv.transition.exception.TransitionException; | 20 import de.intevation.gnv.transition.exception.TransitionException; |
21 | 21 |
22 /** | 22 /** |
23 * @author Tim Englich <tim.englich@intevation.de> | 23 * @author Tim Englich <tim.englich@intevation.de> |
24 * | 24 * |
25 */ | 25 */ |
26 public abstract class OutputTransitionBase extends TransitionBase implements | 26 public abstract class OutputTransitionBase extends TransitionBase implements |
27 OutputTransition { | 27 OutputTransition { |
28 | 28 |
29 | |
30 /** | 29 /** |
31 * The UID of this Class | 30 * The UID of this Class |
32 */ | 31 */ |
33 private static final long serialVersionUID = -1718732895737303823L; | 32 private static final long serialVersionUID = -1718732895737303823L; |
34 | 33 |
35 /** | 34 /** |
36 * the logger, used to log exceptions and additonaly information | 35 * the logger, used to log exceptions and additonaly information |
37 */ | 36 */ |
38 private static Logger log = Logger.getLogger(OutputTransitionBase.class); | 37 private static Logger log = Logger.getLogger(OutputTransitionBase.class); |
39 | 38 |
40 | |
41 /** | 39 /** |
42 * The different Outputmodes which are provided by an OutputTransition | 40 * The different Outputmodes which are provided by an OutputTransition |
43 */ | 41 */ |
44 protected Collection<OutputMode> outputModes = null; | 42 protected Collection<OutputMode> outputModes = null; |
45 | 43 |
46 /** | 44 /** |
47 * Constructor | 45 * Constructor |
48 */ | 46 */ |
49 public OutputTransitionBase() { | 47 public OutputTransitionBase() { |
50 super(); | 48 super(); |
55 */ | 53 */ |
56 public Collection<OutputMode> getOutputModes() { | 54 public Collection<OutputMode> getOutputModes() { |
57 log.debug("OutputTransitionBase.getOutputModes"); | 55 log.debug("OutputTransitionBase.getOutputModes"); |
58 return this.outputModes; | 56 return this.outputModes; |
59 } | 57 } |
58 | |
60 /** | 59 /** |
61 * @see de.intevation.gnv.transition.Transition#validate() | 60 * @see de.intevation.gnv.transition.Transition#validate() |
62 */ | 61 */ |
63 public boolean validate() { | 62 public boolean validate() { |
64 log.debug("OutputTransitionBase.validate"); | 63 log.debug("OutputTransitionBase.validate"); |
70 */ | 69 */ |
71 @Override | 70 @Override |
72 public void setup(Node configuration) { | 71 public void setup(Node configuration) { |
73 log.debug("OutputTransitionBase.setup"); | 72 log.debug("OutputTransitionBase.setup"); |
74 super.setup(configuration); | 73 super.setup(configuration); |
75 NodeList outputModeList = Config.getNodeSetXPath(configuration, "outputsModes/outputsMode"); | 74 NodeList outputModeList = Config.getNodeSetXPath(configuration, |
76 if (outputModeList != null){ | 75 "outputsModes/outputsMode"); |
77 log.debug(outputModeList.getLength()+ " were found."); | 76 if (outputModeList != null) { |
78 this.outputModes = new ArrayList<OutputMode>(outputModeList.getLength()); | 77 log.debug(outputModeList.getLength() + " were found."); |
79 for (int i = 0; i < outputModeList.getLength(); i++){ | 78 this.outputModes = new ArrayList<OutputMode>(outputModeList |
79 .getLength()); | |
80 for (int i = 0; i < outputModeList.getLength(); i++) { | |
80 Node currentNode = outputModeList.item(i); | 81 Node currentNode = outputModeList.item(i); |
81 String name = Config.getStringXPath(currentNode, "@name"); | 82 String name = Config.getStringXPath(currentNode, "@name"); |
82 String description = Config.getStringXPath(currentNode, "@description"); | 83 String description = Config.getStringXPath(currentNode, |
83 String mimeType = Config.getStringXPath(currentNode, "@mime-type"); | 84 "@description"); |
84 | 85 String mimeType = Config.getStringXPath(currentNode, |
85 NodeList inputValuesList = Config.getNodeSetXPath(currentNode, "parameters/inputvalue"); | 86 "@mime-type"); |
87 | |
88 NodeList inputValuesList = Config.getNodeSetXPath(currentNode, | |
89 "parameters/inputvalue"); | |
86 Collection<InputValue> inputParameters = null; | 90 Collection<InputValue> inputParameters = null; |
87 if (inputValuesList != null){ | 91 if (inputValuesList != null) { |
88 inputParameters = new ArrayList<InputValue>(inputValuesList.getLength()); | 92 inputParameters = new ArrayList<InputValue>(inputValuesList |
89 for (int j = 0 ; j < inputValuesList.getLength(); j++){ | 93 .getLength()); |
94 for (int j = 0; j < inputValuesList.getLength(); j++) { | |
90 Node currentInputValuesNode = inputValuesList.item(j); | 95 Node currentInputValuesNode = inputValuesList.item(j); |
91 String inputValueName = Config.getStringXPath(currentInputValuesNode, "@name"); | 96 String inputValueName = Config.getStringXPath( |
92 String inputValueType = Config.getStringXPath(currentInputValuesNode, "@type"); | 97 currentInputValuesNode, "@name"); |
93 String defaultValue = Config.getStringXPath(currentInputValuesNode, "@value"); | 98 String inputValueType = Config.getStringXPath( |
99 currentInputValuesNode, "@type"); | |
100 String defaultValue = Config.getStringXPath( | |
101 currentInputValuesNode, "@value"); | |
94 boolean isMultiselect = false; | 102 boolean isMultiselect = false; |
95 InputValue inputValue = new DefaultInputValue(inputValueName, inputValueType, defaultValue, isMultiselect); | 103 InputValue inputValue = new DefaultInputValue( |
104 inputValueName, inputValueType, defaultValue, | |
105 isMultiselect); | |
96 inputParameters.add(inputValue); | 106 inputParameters.add(inputValue); |
97 } | 107 } |
98 } | 108 } |
99 | 109 |
100 OutputMode outputMode = new DefaultOutputMode(name, description, mimeType,inputParameters); | 110 OutputMode outputMode = new DefaultOutputMode(name, |
111 description, mimeType, inputParameters); | |
101 log.debug(outputMode.toString()); | 112 log.debug(outputMode.toString()); |
102 this.outputModes.add(outputMode); | 113 this.outputModes.add(outputMode); |
103 | 114 |
104 } | 115 } |
105 } | 116 } |
106 } | 117 } |
107 | 118 |
108 /** | 119 /** |
109 * @see de.intevation.gnv.transition.TransitionBase#advance() | 120 * @see de.intevation.gnv.transition.TransitionBase#advance() |
110 */ | 121 */ |
111 @Override | 122 @Override |
112 public void advance(String uuid, CallMeta callMeta) throws TransitionException { | 123 public void advance(String uuid, CallMeta callMeta) |
124 throws TransitionException { | |
113 log.debug("OutputTransitionBase.advance"); | 125 log.debug("OutputTransitionBase.advance"); |
114 if (this.getChartResult(uuid) == null){ | 126 if (this.getChartResult(uuid) == null) { |
115 super.advance(uuid, callMeta); | 127 super.advance(uuid, callMeta); |
116 } | 128 } |
117 } | 129 } |
118 | 130 |
119 /** | 131 /** |
120 * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.util.Collection, java.io.OutputStream) | 132 * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, |
133 * java.util.Collection, java.io.OutputStream) | |
121 */ | 134 */ |
122 public void out(String outputMode, Collection<InputData> inputData, | 135 public void out(String outputMode, Collection<InputData> inputData, |
123 OutputStream outputStream) throws TransitionException { | 136 OutputStream outputStream) throws TransitionException { |
124 } | 137 } |
125 | 138 |
126 /** | 139 /** |
127 * @return | 140 * @return |
128 */ | 141 */ |
129 protected Collection<Result> getChartResult(String uuid) { | 142 protected Collection<Result> getChartResult(String uuid) { |
130 log.debug("OutputTransitionBase.getChartResult"); | 143 log.debug("OutputTransitionBase.getChartResult"); |
131 if (CacheFactory.getInstance().isInitialized()){ | 144 if (CacheFactory.getInstance().isInitialized()) { |
132 String key = uuid+super.getID(); | 145 String key = uuid + super.getID(); |
133 log.debug("Hash for Queryelements: "+key); | 146 log.debug("Hash for Queryelements: " + key); |
134 Element value = CacheFactory.getInstance().getCache().get(key); | 147 Element value = CacheFactory.getInstance().getCache().get(key); |
135 if (value != null){ | 148 if (value != null) { |
136 return (Collection<Result>)(value.getObjectValue()); | 149 return (Collection<Result>) (value.getObjectValue()); |
137 } | 150 } |
138 } | 151 } |
139 return null; | 152 return null; |
140 } | 153 } |
141 | 154 |
142 /** | 155 /** |
143 * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, java.lang.String) | 156 * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, |
157 * java.lang.String) | |
144 */ | 158 */ |
145 @Override | 159 @Override |
146 protected void purifyResult(Collection<Result> result, String uuid) { | 160 protected void purifyResult(Collection<Result> result, String uuid) { |
147 log.debug("OutputTransitionBase.purifyResult"); | 161 log.debug("OutputTransitionBase.purifyResult"); |
148 if (CacheFactory.getInstance().isInitialized()){ | 162 if (CacheFactory.getInstance().isInitialized()) { |
149 String key = uuid+super.getID(); | 163 String key = uuid + super.getID(); |
150 log.debug("Hash for Queryelements: "+key); | 164 log.debug("Hash for Queryelements: " + key); |
151 CacheFactory.getInstance().getCache().put(new Element(key, result)); | 165 CacheFactory.getInstance().getCache().put(new Element(key, result)); |
152 } | 166 } |
153 } | 167 } |
154 | 168 |
155 } | 169 } |