Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java @ 6726:b68798973da2
Cosmetics, docs.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 31 Jul 2013 11:32:33 +0200 |
parents | af13ceeba52a |
children | 963ede7b32bb |
comparison
equal
deleted
inserted
replaced
6725:7ea933f9c6ea | 6726:b68798973da2 |
---|---|
20 import org.dive4elements.artifacts.common.utils.XMLUtils; | 20 import org.dive4elements.artifacts.common.utils.XMLUtils; |
21 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; | 21 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; |
22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; | 22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; |
23 | 23 |
24 | 24 |
25 /** Service delivering info about sediment loads. */ | |
25 public class SedimentLoadInfoService | 26 public class SedimentLoadInfoService |
26 extends D4EService | 27 extends D4EService |
27 { | 28 { |
28 /** The logger used in this service. */ | 29 /** The logger used in this service. */ |
29 private static Logger logger = Logger.getLogger(SedimentLoadInfoService.class); | 30 private static Logger logger = Logger.getLogger(SedimentLoadInfoService.class); |
31 public static final String RIVER_XPATH = "/art:river/text()"; | 32 public static final String RIVER_XPATH = "/art:river/text()"; |
32 public static final String TYPE_XPATH = "/art:river/art:type/text()"; | 33 public static final String TYPE_XPATH = "/art:river/art:type/text()"; |
33 public static final String FROM_XPATH = "/art:river/art:location/art:from/text()"; | 34 public static final String FROM_XPATH = "/art:river/art:location/art:from/text()"; |
34 public static final String TO_XPATH = "/art:river/art:location/art:to/text()"; | 35 public static final String TO_XPATH = "/art:river/art:location/art:to/text()"; |
35 | 36 |
37 /** | |
38 * Create document with sedimentload infos, | |
39 * constrained by contents in data. | |
40 */ | |
36 @Override | 41 @Override |
37 protected Document doProcess( | 42 protected Document doProcess( |
38 Document data, | 43 Document data, |
39 GlobalContext globalContext, | 44 GlobalContext globalContext, |
40 CallMeta callMeta) { | 45 CallMeta callMeta) { |
52 ArtifactNamespaceContext.INSTANCE); | 57 ArtifactNamespaceContext.INSTANCE); |
53 String to = XMLUtils.xpathString( | 58 String to = XMLUtils.xpathString( |
54 data, | 59 data, |
55 TO_XPATH, | 60 TO_XPATH, |
56 ArtifactNamespaceContext.INSTANCE); | 61 ArtifactNamespaceContext.INSTANCE); |
57 double f, t; | 62 double fromD, toD; |
58 try { | 63 try { |
59 f = Double.parseDouble(from); | 64 fromD = Double.parseDouble(from); |
60 t = Double.parseDouble(to); | 65 toD = Double.parseDouble(to); |
61 } | 66 } |
62 catch (NumberFormatException nfe) { | 67 catch (NumberFormatException nfe) { |
63 logger.warn("Invalid locations. Cannot return sediment loads."); | 68 logger.warn("Invalid locations. Cannot return sediment loads."); |
64 return XMLUtils.newDocument(); | 69 return XMLUtils.newDocument(); |
65 } | 70 } |
66 | 71 |
67 SedimentLoad[] loads = SedimentLoadFactory.getLoads(river, type, f, t); | 72 SedimentLoad[] loads = |
73 SedimentLoadFactory.getLoads(river, type, fromD, toD); | |
68 return buildDocument(loads); | 74 return buildDocument(loads); |
69 } | 75 } |
70 | 76 |
71 protected Document buildDocument(SedimentLoad[] loads) { | 77 protected Document buildDocument(SedimentLoad[] loads) { |
72 Document result = XMLUtils.newDocument(); | 78 Document result = XMLUtils.newDocument(); |
96 } | 102 } |
97 result.appendChild(all); | 103 result.appendChild(all); |
98 return result; | 104 return result; |
99 } | 105 } |
100 } | 106 } |
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |