comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java @ 3468:f37e7e8907cb

merged flys-artifacts/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:39 +0200
parents c1f445b94d03
children 5fb103635427
comparison
equal deleted inserted replaced
3387:5ffad8bde8ad 3468:f37e7e8907cb
1 package de.intevation.flys.artifacts.states;
2
3 import java.util.List;
4
5 import org.apache.log4j.Logger;
6
7 import de.intevation.artifacts.CallContext;
8
9 import de.intevation.artifactdatabase.state.Facet;
10
11 import de.intevation.flys.artifacts.FLYSArtifact;
12 import de.intevation.flys.artifacts.WINFOArtifact;
13 import de.intevation.flys.artifacts.ChartArtifact;
14
15 import de.intevation.flys.artifacts.model.FacetTypes;
16 import de.intevation.flys.artifacts.model.WaterlevelFacet;
17 import de.intevation.flys.artifacts.model.DataFacet;
18 import de.intevation.flys.artifacts.model.ReportFacet;
19 import de.intevation.flys.artifacts.model.EmptyFacet;
20 import de.intevation.flys.artifacts.model.WQKms;
21 import de.intevation.flys.artifacts.model.CalculationResult;
22
23 import de.intevation.flys.artifacts.resources.Resources;
24
25 import de.intevation.flys.utils.FLYSUtils;
26
27 /**
28 * The final state that will be reached after the discharge curve calculation
29 * mode has been chosen.
30 *
31 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
32 */
33 public class ComputedDischargeCurveState
34 extends DefaultState
35 implements FacetTypes
36 {
37 /** The logger that is used in this state.*/
38 private static Logger logger =
39 Logger.getLogger(ComputedDischargeCurveState.class);
40
41 public ComputedDischargeCurveState() {
42 }
43
44
45 /**
46 * Get computed discharge curve data from cache (if available) or
47 * compute anew. Create Waterlevel and DataFacets.
48 */
49 @Override
50 public Object computeAdvance(
51 FLYSArtifact artifact,
52 String hash,
53 CallContext context,
54 List<Facet> facets,
55 Object old
56 ) {
57 logger.debug("ComputedDischargeCurveState.computeAdvance");
58 if(artifact instanceof WINFOArtifact) {
59 WINFOArtifact winfo = (WINFOArtifact)artifact;
60
61 CalculationResult res = old instanceof CalculationResult
62 ? (CalculationResult)old
63 : winfo.getComputedDischargeCurveData();
64
65 WQKms [] wqkms = (WQKms [])res.getData();
66
67 if (facets != null && wqkms.length > 0) {
68 for (int i = 0; i < wqkms.length; ++i) {
69
70 Object[] args = new Object[] {
71 FLYSUtils.getRiver(winfo).getName(),
72 wqkms[i].getName()
73 };
74
75 String name = Resources.getMsg(
76 context.getMeta(),
77 "chart.computed.discharge.curve.curve.label",
78 "",
79 args);
80
81 facets.add(new WaterlevelFacet(i, COMPUTED_DISCHARGE_Q, name));
82 facets.add(new WaterlevelFacet(i, AT, "AT data"));
83 }
84
85 facets.add(new DataFacet(CSV, "CSV data"));
86 facets.add(new DataFacet(PDF, "PDF data"));
87
88 if (res.getReport().hasProblems()) {
89 facets.add(new ReportFacet());
90 }
91 }
92
93 return res;
94 }
95 else if(artifact instanceof ChartArtifact) {
96 ChartArtifact chart = (ChartArtifact)artifact;
97 facets.add(new EmptyFacet());
98 return null;
99 }
100 return null;
101 }
102 }
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org