comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeCurveArtifact.java @ 4211:47b7325eafeb

merged
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 22 Oct 2012 17:07:02 +0200
parents b87d76a6da70
children 8c51c43e59ca
comparison
equal deleted inserted replaced
4210:e47559908acc 4211:47b7325eafeb
1 package de.intevation.flys.artifacts; 1 package de.intevation.flys.artifacts;
2 2
3 import java.math.BigDecimal;
3 import java.util.ArrayList; 4 import java.util.ArrayList;
4 import java.util.List; 5 import java.util.List;
5 6
6 import org.apache.log4j.Logger; 7 import org.apache.log4j.Logger;
7 8
40 public static final String XPATH_RIVER = "/art:action/art:river/@art:name"; 41 public static final String XPATH_RIVER = "/art:action/art:river/@art:name";
41 public static final String XPATH_GAUGE = "/art:action/art:gauge/@art:reference"; 42 public static final String XPATH_GAUGE = "/art:action/art:gauge/@art:reference";
42 public static final String NAME = "gaugedischargecurve"; 43 public static final String NAME = "gaugedischargecurve";
43 public static final String STATIC_STATE_NAME = "state.gaugedischargecurve.static"; 44 public static final String STATIC_STATE_NAME = "state.gaugedischargecurve.static";
44 public static final String UIPROVIDER = "gauge_discharge_curve"; 45 public static final String UIPROVIDER = "gauge_discharge_curve";
46 public static final String GAUGE_DISCHARGE_CURVE_FACET =
47 "gauge_discharge_curve";
48 public static final String GAUGE_DISCHARGE_CURVE_AT_EXPORT_FACET =
49 "gauge_discharge_curve_at_export";
50 public static final String GAUGE_DISCHARGE_CURVE_OUT =
51 "discharge_curve";
52 public static final String GAUGE_DISCHARGE_CURVE_AT_EXPORT_OUT =
53 "computed_dischargecurve_at_export";
54
55 private Facet atexportfacet;
56 private Facet curvefacet;
45 57
46 /** 58 /**
47 * Setup initializes the data by extracting the river and gauge from 59 * Setup initializes the data by extracting the river and gauge from
48 * the XML Document. 60 * the XML Document.
49 */ 61 */
72 "String", rivername)); 84 "String", rivername));
73 addData("reference_gauge", new DefaultStateData("reference_gauge", 85 addData("reference_gauge", new DefaultStateData("reference_gauge",
74 Resources.getMsg(callmeta, 86 Resources.getMsg(callmeta,
75 "facet.gauge_discharge_curve.reference_gauge", 87 "facet.gauge_discharge_curve.reference_gauge",
76 "Gauge official number"), 88 "Gauge official number"),
77 "Double", gaugeref)); 89 "Long", gaugeref));
78 90
79 Gauge gauge = FLYSUtils.getReferenceGauge(this); 91 Gauge gauge = FLYSUtils.getReferenceGauge(this);
80 String gaugename = ""; 92 String gaugename = "";
93 Double gaugelocation = null;
81 if (gauge != null) { 94 if (gauge != null) {
82 gaugename = gauge.getName(); 95 gaugename = gauge.getName();
96 BigDecimal station = gauge.getStation();
97 if (station != null) {
98 gaugelocation = station.doubleValue();
99 }
83 } 100 }
84 101
85 addData("gauge_name", new DefaultStateData("gauge_name", 102 addData("gauge_name", new DefaultStateData("gauge_name",
86 Resources.getMsg(callmeta, 103 Resources.getMsg(callmeta,
87 "facet.gauge_discharge_curve.gauge_name", 104 "facet.gauge_discharge_curve.gauge_name",
88 "Name of the gauge"), 105 "Name of the gauge"),
89 "String", gaugename)); 106 "String", gaugename));
90 107
108 if (gaugelocation != null) {
109 addData("ld_locations", new DefaultStateData("ld_locations",
110 Resources.getMsg(callmeta,
111 "facet.gauge_discharge_curve.gauge_location",
112 "Location of the gauge"),
113 "Double", gaugelocation.toString()));
114 }
115
91 String description = Resources.format(callmeta, 116 String description = Resources.format(callmeta,
92 "facet.gauge_discharge_curve.description", 117 "facet.gauge_discharge_curve.description",
93 "Discharge curve on gauge", 118 "Discharge curve on gauge",
94 rivername, 119 rivername,
95 gaugename); 120 gaugename);
96 121
97 Facet gfacet = new GaugeDischargeCurveFacet(description); 122 List<Facet> fs = new ArrayList<Facet>(2);
123 curvefacet = new GaugeDischargeCurveFacet(
124 GAUGE_DISCHARGE_CURVE_FACET, description);
125 fs.add(curvefacet);
98 126
99 List<Facet> fs = new ArrayList<Facet>(1); 127 description = Resources.format(callmeta,
100 fs.add(gfacet); 128 "facet.gauge_discharge_curve_at_export.description",
129 "Discharge curve AT export on gauge",
130 rivername,
131 gaugename);
132 atexportfacet = new GaugeDischargeCurveFacet(
133 GAUGE_DISCHARGE_CURVE_AT_EXPORT_FACET, description);
134 fs.add(atexportfacet);
101 135
102 addFacets(STATIC_STATE_NAME, fs); 136 addFacets(STATIC_STATE_NAME, fs);
103 137
104 super.setup(identifier, factory, context, callmeta, data); 138 super.setup(identifier, factory, context, callmeta, data);
105 } 139 }
110 } 144 }
111 145
112 @Override 146 @Override
113 protected void initStaticState() { 147 protected void initStaticState() {
114 StaticState state = new StaticState(STATIC_STATE_NAME); 148 StaticState state = new StaticState(STATIC_STATE_NAME);
115 List<Facet> fs = facets.get(STATIC_STATE_NAME); 149
150 List<Facet> fs = new ArrayList<Facet>(1);
151 fs.add(curvefacet);
152
116 DefaultOutput output = new DefaultOutput( 153 DefaultOutput output = new DefaultOutput(
117 "discharge_curve", 154 GAUGE_DISCHARGE_CURVE_OUT,
118 "output.discharge_curve", "image/png", 155 "output.discharge_curve",
156 "image/png",
119 fs, 157 fs,
120 "chart"); 158 "chart");
159 state.addOutput(output);
121 160
161 fs = new ArrayList<Facet>(1);
162 fs.add(atexportfacet);
163 output = new DefaultOutput(
164 GAUGE_DISCHARGE_CURVE_AT_EXPORT_OUT,
165 "output.computed_dischargecurve_at_export",
166 "text/plain",
167 fs,
168 "export");
122 state.addOutput(output); 169 state.addOutput(output);
170
123 state.setUIProvider(UIPROVIDER); 171 state.setUIProvider(UIPROVIDER);
124 setStaticState(state); 172 setStaticState(state);
125 } 173 }
126 } 174 }

http://dive4elements.wald.intevation.org