comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents 11bc2d6a2059
children 30b1ddadf275
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
39 * 39 *
40 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 40 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
41 */ 41 */
42 public class MainValuesService extends D4EService { 42 public class MainValuesService extends D4EService {
43 43
44 /** The logger that is used by this service.*/ 44 /** The log that is used by this service.*/
45 private static Logger logger = Logger.getLogger(MainValuesService.class); 45 private static Logger log = Logger.getLogger(MainValuesService.class);
46 46
47 /** The XPath that points to the river definition of the incoming request.*/ 47 /** The XPath that points to the river definition of the incoming request.*/
48 public static final String XPATH_RIVER = "/art:mainvalues/art:river/text()"; 48 public static final String XPATH_RIVER = "/art:mainvalues/art:river/text()";
49 49
50 /** The XPath that points to the start definition of the incoming request.*/ 50 /** The XPath that points to the start definition of the incoming request.*/
61 */ 61 */
62 public MainValuesService() { 62 public MainValuesService() {
63 } 63 }
64 64
65 private static final Document error(String msg) { 65 private static final Document error(String msg) {
66 logger.debug(msg); 66 log.debug(msg);
67 return XMLUtils.newDocument(); 67 return XMLUtils.newDocument();
68 } 68 }
69 69
70 70
71 @Override 71 @Override
72 public Document doProcess( 72 public Document doProcess(
73 Document data, 73 Document data,
74 GlobalContext context, 74 GlobalContext context,
75 CallMeta callMeta 75 CallMeta callMeta
76 ) { 76 ) {
77 logger.debug("MainValuesService.process"); 77 log.debug("MainValuesService.process");
78 78
79 this.callMeta = callMeta; 79 this.callMeta = callMeta;
80 80
81 River river = getRequestedRiver(data); 81 River river = getRequestedRiver(data);
82 if (river == null) { 82 if (river == null) {
106 * @return the River object. 106 * @return the River object.
107 */ 107 */
108 protected River getRequestedRiver(Document data) 108 protected River getRequestedRiver(Document data)
109 throws NullPointerException 109 throws NullPointerException
110 { 110 {
111 logger.debug("MainValuesService.getRequestedRiver"); 111 log.debug("MainValuesService.getRequestedRiver");
112 112
113 String riverStr = XMLUtils.xpathString( 113 String riverStr = XMLUtils.xpathString(
114 data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE); 114 data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE);
115 115
116 return riverStr != null && (riverStr = riverStr.trim()).length() > 0 116 return riverStr != null && (riverStr = riverStr.trim()).length() > 0
129 * @param river The river of the request. 129 * @param river The river of the request.
130 * 130 *
131 * @return the start and end point. 131 * @return the start and end point.
132 */ 132 */
133 protected double[] getRequestedStartEnd(Document data, River river) { 133 protected double[] getRequestedStartEnd(Document data, River river) {
134 logger.debug("MainValuesService.getStartEnd"); 134 log.debug("MainValuesService.getStartEnd");
135 135
136 String startStr = XMLUtils.xpathString( 136 String startStr = XMLUtils.xpathString(
137 data, XPATH_START, ArtifactNamespaceContext.INSTANCE); 137 data, XPATH_START, ArtifactNamespaceContext.INSTANCE);
138 138
139 String endStr = XMLUtils.xpathString( 139 String endStr = XMLUtils.xpathString(
145 145
146 try { 146 try {
147 double start = Double.parseDouble(startStr); 147 double start = Double.parseDouble(startStr);
148 double end = Double.parseDouble(endStr); 148 double end = Double.parseDouble(endStr);
149 149
150 if (logger.isDebugEnabled()) { 150 if (log.isDebugEnabled()) {
151 logger.debug("Found start: " + start); 151 log.debug("Found start: " + start);
152 logger.debug("Found end: " + end); 152 log.debug("Found end: " + end);
153 } 153 }
154 154
155 return new double[] { start, end }; 155 return new double[] { start, end };
156 } 156 }
157 catch (NumberFormatException nfe) { 157 catch (NumberFormatException nfe) {
158 logger.warn(nfe, nfe); 158 log.warn(nfe, nfe);
159 return river.determineMinMaxDistance(); 159 return river.determineMinMaxDistance();
160 } 160 }
161 } 161 }
162 162
163 163
171 * @return a document that includes the main values of the specified river 171 * @return a document that includes the main values of the specified river
172 * at the specified gauge. 172 * at the specified gauge.
173 */ 173 */
174 protected List<MainValue> getMainValues(River river, Gauge gauge) { 174 protected List<MainValue> getMainValues(River river, Gauge gauge) {
175 175
176 if (logger.isDebugEnabled()) { 176 if (log.isDebugEnabled()) {
177 logger.debug("MainValuesService.buildMainValues"); 177 log.debug("MainValuesService.buildMainValues");
178 logger.debug("River: " + river.getName()); 178 log.debug("River: " + river.getName());
179 logger.debug("Gauge: " + gauge.getName()); 179 log.debug("Gauge: " + gauge.getName());
180 } 180 }
181 181
182 List<MainValue> mainValues = gauge.getMainValues(); 182 List<MainValue> mainValues = gauge.getMainValues();
183 183
184 if (logger.isDebugEnabled()) { 184 if (log.isDebugEnabled()) {
185 logger.debug(mainValues.size() + " main values found."); 185 log.debug(mainValues.size() + " main values found.");
186 } 186 }
187 187
188 return mainValues; 188 return mainValues;
189 } 189 }
190 190
193 River river, 193 River river,
194 Gauge gauge, 194 Gauge gauge,
195 List<MainValue> mainValues, 195 List<MainValue> mainValues,
196 Object context) 196 Object context)
197 { 197 {
198 logger.debug("MainValuesService.buildDocument"); 198 log.debug("MainValuesService.buildDocument");
199 199
200 Document doc = XMLUtils.newDocument(); 200 Document doc = XMLUtils.newDocument();
201 201
202 ElementCreator cr = new ElementCreator( 202 ElementCreator cr = new ElementCreator(
203 doc, 203 doc,
231 Element root, 231 Element root,
232 River river, 232 River river,
233 Gauge gauge, 233 Gauge gauge,
234 Object context) 234 Object context)
235 { 235 {
236 logger.debug("MainValuesService.appendMetaInformation"); 236 log.debug("MainValuesService.appendMetaInformation");
237 237
238 ElementCreator cr = new ElementCreator( 238 ElementCreator cr = new ElementCreator(
239 doc, 239 doc,
240 ArtifactNamespaceContext.NAMESPACE_URI, 240 ArtifactNamespaceContext.NAMESPACE_URI,
241 ArtifactNamespaceContext.NAMESPACE_PREFIX); 241 ArtifactNamespaceContext.NAMESPACE_PREFIX);
272 Element root, 272 Element root,
273 List<MainValue> mainValues, 273 List<MainValue> mainValues,
274 Integer riverId, 274 Integer riverId,
275 Object context) 275 Object context)
276 { 276 {
277 logger.debug("MainValuesService.appendMainValues"); 277 log.debug("MainValuesService.appendMainValues");
278 278
279 ElementCreator cr = new ElementCreator( 279 ElementCreator cr = new ElementCreator(
280 doc, 280 doc,
281 ArtifactNamespaceContext.NAMESPACE_URI, 281 ArtifactNamespaceContext.NAMESPACE_URI,
282 ArtifactNamespaceContext.NAMESPACE_PREFIX); 282 ArtifactNamespaceContext.NAMESPACE_PREFIX);

http://dive4elements.wald.intevation.org