comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeInfoService.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 fe03337c8011
children 5e38e2924c07
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
33 * 33 *
34 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 34 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
35 */ 35 */
36 public class DischargeInfoService extends D4EService { 36 public class DischargeInfoService extends D4EService {
37 37
38 /** The logger used in this service. */ 38 /** The log used in this service. */
39 private static Logger logger = Logger.getLogger(DischargeInfoService.class); 39 private static Logger log = Logger.getLogger(DischargeInfoService.class);
40 40
41 public static final String GAUGE_XPATH = "/art:gauge/text()"; 41 public static final String GAUGE_XPATH = "/art:gauge/text()";
42 42
43 public static final String RIVER_NAME_XPATH = "/art:gauge/art:river/text()"; 43 public static final String RIVER_NAME_XPATH = "/art:gauge/art:river/text()";
44 44
50 public Document doProcess( 50 public Document doProcess(
51 Document data, 51 Document data,
52 GlobalContext globalContext, 52 GlobalContext globalContext,
53 CallMeta callMeta 53 CallMeta callMeta
54 ) { 54 ) {
55 if (logger.isDebugEnabled()) { 55 if (log.isDebugEnabled()) {
56 logger.debug("DischargeInfoService.process"); 56 log.debug("DischargeInfoService.process");
57 logger.debug(XMLUtils.toString(data)); 57 log.debug(XMLUtils.toString(data));
58 } 58 }
59 59
60 String gaugeNumber = XMLUtils.xpathString( 60 String gaugeNumber = XMLUtils.xpathString(
61 data, GAUGE_XPATH, ArtifactNamespaceContext.INSTANCE); 61 data, GAUGE_XPATH, ArtifactNamespaceContext.INSTANCE);
62 62
63 String river = XMLUtils.xpathString( 63 String river = XMLUtils.xpathString(
64 data, RIVER_NAME_XPATH, ArtifactNamespaceContext.INSTANCE); 64 data, RIVER_NAME_XPATH, ArtifactNamespaceContext.INSTANCE);
65 65
66 if (gaugeNumber == null || 66 if (gaugeNumber == null ||
67 (gaugeNumber = gaugeNumber.trim()).length() == 0) { 67 (gaugeNumber = gaugeNumber.trim()).length() == 0) {
68 logger.warn("No gauge specified. Cannot return discharge info."); 68 log.warn("No gauge specified. Cannot return discharge info.");
69 return XMLUtils.newDocument(); 69 return XMLUtils.newDocument();
70 } 70 }
71 71
72 logger.debug("Getting discharge for gauge: " + gaugeNumber + " at river: " + river); 72 log.debug("Getting discharge for gauge: " + gaugeNumber + " at river: " + river);
73 73
74 long gn; 74 long gn;
75 try { 75 try {
76 gn = Long.parseLong(gaugeNumber); 76 gn = Long.parseLong(gaugeNumber);
77 } 77 }
78 catch (NumberFormatException nfe) { 78 catch (NumberFormatException nfe) {
79 logger.warn("Invalid gauge number. Cannot return discharge info."); 79 log.warn("Invalid gauge number. Cannot return discharge info.");
80 return XMLUtils.newDocument(); 80 return XMLUtils.newDocument();
81 } 81 }
82 82
83 Gauge gauge; 83 Gauge gauge;
84 if (river == null || river.isEmpty()) { 84 if (river == null || river.isEmpty()) {
86 } else { 86 } else {
87 gauge = Gauge.getGaugeByOfficialNumber(gn, river); 87 gauge = Gauge.getGaugeByOfficialNumber(gn, river);
88 } 88 }
89 89
90 if (gauge == null) { 90 if (gauge == null) {
91 logger.warn("No such gauge found."); 91 log.warn("No such gauge found.");
92 return XMLUtils.newDocument(); 92 return XMLUtils.newDocument();
93 } 93 }
94 94
95 logger.debug("Found gauge: " + gauge.getName() + " id: " + gauge.getId()); 95 log.debug("Found gauge: " + gauge.getName() + " id: " + gauge.getId());
96 96
97 return buildDocument(gauge); 97 return buildDocument(gauge);
98 } 98 }
99 99
100 100
102 Document result = XMLUtils.newDocument(); 102 Document result = XMLUtils.newDocument();
103 103
104 List<DischargeTable> tables = gauge.getDischargeTables(); 104 List<DischargeTable> tables = gauge.getDischargeTables();
105 Collections.sort(tables); 105 Collections.sort(tables);
106 106
107 logger.debug("# of tables:" + tables.size()); 107 log.debug("# of tables:" + tables.size());
108 108
109 Element all = result.createElement("discharges"); 109 Element all = result.createElement("discharges");
110 for (DischargeTable dt: tables) { 110 for (DischargeTable dt: tables) {
111 if (dt.getKind() == DischargeTables.MASTER) { 111 if (dt.getKind() == DischargeTables.MASTER) {
112 continue; 112 continue;
116 116
117 // Get time interval. 117 // Get time interval.
118 TimeInterval ti = dt.getTimeInterval(); 118 TimeInterval ti = dt.getTimeInterval();
119 119
120 if (ti == null) { 120 if (ti == null) {
121 logger.warn("DischargeTable has no TimeInterval set!"); 121 log.warn("DischargeTable has no TimeInterval set!");
122 continue; 122 continue;
123 } 123 }
124 124
125 Date startTime = ti.getStartTime(); 125 Date startTime = ti.getStartTime();
126 Date stopTime = ti.getStopTime(); 126 Date stopTime = ti.getStopTime();

http://dive4elements.wald.intevation.org