comparison artifacts/src/main/java/org/dive4elements/river/artifacts/GaugeDischargeArtifact.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 d3a4b0d5bcd8
children c494f9a61490
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
47 */ 47 */
48 public class GaugeDischargeArtifact 48 public class GaugeDischargeArtifact
49 extends WINFOArtifact 49 extends WINFOArtifact
50 implements FacetTypes 50 implements FacetTypes
51 { 51 {
52 /** The logger for this class. */ 52 /** The log for this class. */
53 private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class); 53 private static Logger log = Logger.getLogger(GaugeDischargeArtifact.class);
54 54
55 /** The name of the artifact. */ 55 /** The name of the artifact. */
56 public static final String ARTIFACT_NAME = "gaugedischarge"; 56 public static final String ARTIFACT_NAME = "gaugedischarge";
57 57
58 /** The name a facet should have */ 58 /** The name a facet should have */
60 60
61 /** 61 /**
62 * Trivial Constructor. 62 * Trivial Constructor.
63 */ 63 */
64 public GaugeDischargeArtifact() { 64 public GaugeDischargeArtifact() {
65 logger.debug("GaugeDischargeArtifact.GaugeDischargeArtifact()"); 65 log.debug("GaugeDischargeArtifact.GaugeDischargeArtifact()");
66 } 66 }
67 67
68 68
69 /** 69 /**
70 * Gets called from factory, to set things up. 70 * Gets called from factory, to set things up.
79 Object context, 79 Object context,
80 CallMeta callMeta, 80 CallMeta callMeta,
81 Document data, 81 Document data,
82 List<Class> loadFacets) 82 List<Class> loadFacets)
83 { 83 {
84 logger.debug("GaugeDischargeArtifact.setup"); 84 log.debug("GaugeDischargeArtifact.setup");
85 String ids = StaticD4EArtifact.getDatacageIDValue(data); 85 String ids = StaticD4EArtifact.getDatacageIDValue(data);
86 addStringData("ids", ids); 86 addStringData("ids", ids);
87 logger.debug("id for gaugedischarge: " + ids); 87 log.debug("id for gaugedischarge: " + ids);
88 String[] splitIds = ids.split(";"); 88 String[] splitIds = ids.split(";");
89 /* We assume that if an id's string with a ; is given that the 89 /* We assume that if an id's string with a ; is given that the
90 * format is <gauge_name>;<discharge_table_id>;<facet_desc> 90 * format is <gauge_name>;<discharge_table_id>;<facet_desc>
91 * so that a specific discharge table can be selected */ 91 * so that a specific discharge table can be selected */
92 if (splitIds.length > 2) { 92 if (splitIds.length > 2) {
105 /** 105 /**
106 * Setup state and facet, copy from master artifact. 106 * Setup state and facet, copy from master artifact.
107 */ 107 */
108 @Override 108 @Override
109 protected void initialize(Artifact art, Object context, CallMeta meta) { 109 protected void initialize(Artifact art, Object context, CallMeta meta) {
110 logger.debug("GaugeDischargeArtifact.initialize"); 110 log.debug("GaugeDischargeArtifact.initialize");
111 List<Facet> fs = new ArrayList<Facet>(); 111 List<Facet> fs = new ArrayList<Facet>();
112 D4EArtifact artifact = (D4EArtifact) art; 112 D4EArtifact artifact = (D4EArtifact) art;
113 importData(artifact, "river"); 113 importData(artifact, "river");
114 114
115 // Get the location(s) 115 // Get the location(s)
119 addStringData("ld_mode", "distance"); 119 addStringData("ld_mode", "distance");
120 120
121 DefaultState state = (DefaultState) getCurrentState(context); 121 DefaultState state = (DefaultState) getCurrentState(context);
122 state.computeInit(this, hash(), context, meta, fs); 122 state.computeInit(this, hash(), context, meta, fs);
123 if (!fs.isEmpty()) { 123 if (!fs.isEmpty()) {
124 logger.debug("Facets to add in GaugeDischargeArtifact.initialize. (" 124 log.debug("Facets to add in GaugeDischargeArtifact.initialize. ("
125 + state.getID() + "/ " + getCurrentStateId() + ")."); 125 + state.getID() + "/ " + getCurrentStateId() + ").");
126 addFacets(getCurrentStateId(), fs); 126 addFacets(getCurrentStateId(), fs);
127 } 127 }
128 else { 128 else {
129 logger.debug("No facets to add in GaugeDischargeArtifact.initialize (" 129 log.debug("No facets to add in GaugeDischargeArtifact.initialize ("
130 + state.getID() + "/ "+getCurrentStateId()+")."); 130 + state.getID() + "/ "+getCurrentStateId()+").");
131 } 131 }
132 } 132 }
133 133
134 134
159 return error(new WQKms[0], "no.river.selected"); 159 return error(new WQKms[0], "no.river.selected");
160 } 160 }
161 /* 161 /*
162 // This one would allow to automatically pick the right Gauge. 162 // This one would allow to automatically pick the right Gauge.
163 double [] distance = RiverUtils.getKmRange(this); 163 double [] distance = RiverUtils.getKmRange(this);
164 logger.debug("getDischargeCurveData: get range"); 164 log.debug("getDischargeCurveData: get range");
165 165
166 if (distance == null) { 166 if (distance == null) {
167 return error(new WQKms[0], "no.range.found"); 167 return error(new WQKms[0], "no.range.found");
168 } 168 }
169 169
170 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]); 170 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]);
171 logger.debug("getDischargeCurveData: got " + gauges.size() + " gauges"); 171 log.debug("getDischargeCurveData: got " + gauges.size() + " gauges");
172 172
173 if (gauges.isEmpty()) { 173 if (gauges.isEmpty()) {
174 return error(new WQKms[0], "no.gauge.selected"); 174 return error(new WQKms[0], "no.gauge.selected");
175 } 175 }
176 176
177 String [] names = new String[gauges.size()]; 177 String [] names = new String[gauges.size()];
178 178
179 for (int i = 0; i < names.length; ++i) { 179 for (int i = 0; i < names.length; ++i) {
180 names[i] = gauges.get(i).getName(); 180 names[i] = gauges.get(i).getName();
181 logger.debug("getDischargeCurveData: name " + names[i]); 181 log.debug("getDischargeCurveData: name " + names[i]);
182 } 182 }
183 */ 183 */
184 184
185 Map<String, double [][]> map; 185 Map<String, double [][]> map;
186 186
191 * so that a specific discharge table can be selected */ 191 * so that a specific discharge table can be selected */
192 int tableId = 0; 192 int tableId = 0;
193 try { 193 try {
194 tableId = Integer.parseInt(ids[1]); 194 tableId = Integer.parseInt(ids[1]);
195 } catch (NumberFormatException e) { 195 } catch (NumberFormatException e) {
196 logger.error("Discharge tables ids string is wrong." + 196 log.error("Discharge tables ids string is wrong." +
197 " Fromat is <gauge_name>;<discharge_table_id>;<facet_desc>" + 197 " Fromat is <gauge_name>;<discharge_table_id>;<facet_desc>" +
198 " Fix your Datacage!"); 198 " Fix your Datacage!");
199 // Let's rather break down completly then show the wrong data. 199 // Let's rather break down completly then show the wrong data.
200 return null; 200 return null;
201 } 201 }
212 Gauge gauge = river.determineGaugeByName(getGaugeName()); 212 Gauge gauge = river.determineGaugeByName(getGaugeName());
213 213
214 String name = getGaugeName(); 214 String name = getGaugeName();
215 double [][] values = map.get(name); 215 double [][] values = map.get(name);
216 if (values == null) { 216 if (values == null) {
217 logger.error("No values for this gauge / discharge found."); 217 log.error("No values for this gauge / discharge found.");
218 return error(new WQKms[0], "no.gauge.found"); 218 return error(new WQKms[0], "no.gauge.found");
219 } 219 }
220 for (int i = 0 ; i < values[0].length; i++) { 220 for (int i = 0 ; i < values[0].length; i++) {
221 values[0][i] += gauge.getDatum().doubleValue(); 221 values[0][i] += gauge.getDatum().doubleValue();
222 } 222 }

http://dive4elements.wald.intevation.org