comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/states/DurationCurveState.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java@7887112c37cc
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.artifacts.states;
2
3 import java.util.List;
4
5 import org.apache.log4j.Logger;
6
7 import org.dive4elements.artifacts.CallContext;
8
9 import org.dive4elements.artifactdatabase.state.Facet;
10
11 import org.dive4elements.river.artifacts.access.RangeAccess;
12 import org.dive4elements.river.artifacts.FLYSArtifact;
13 import org.dive4elements.river.artifacts.WINFOArtifact;
14 import org.dive4elements.river.artifacts.ChartArtifact;
15
16 import org.dive4elements.river.artifacts.model.DurationCurveFacet;
17 import org.dive4elements.river.artifacts.model.FacetTypes;
18 import org.dive4elements.river.artifacts.model.WQDay;
19
20 import org.dive4elements.river.artifacts.model.DataFacet;
21 import org.dive4elements.river.artifacts.model.ReportFacet;
22 import org.dive4elements.river.artifacts.model.EmptyFacet;
23 import org.dive4elements.river.artifacts.model.CalculationResult;
24
25 import org.dive4elements.river.artifacts.resources.Resources;
26
27 import org.dive4elements.river.utils.FLYSUtils;
28
29
30 /**
31 * The final state that will be reached after the duration curve calculation
32 * mode has been chosen.
33 *
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
35 */
36 public class DurationCurveState
37 extends DefaultState
38 implements FacetTypes
39 {
40 /** The logger that is used in this state. */
41 private static Logger logger = Logger.getLogger(DurationCurveState.class);
42
43 public DurationCurveState() {
44 }
45
46
47 @Override
48 public Object computeAdvance(
49 FLYSArtifact artifact,
50 String hash,
51 CallContext context,
52 List<Facet> facets,
53 Object old
54 ) {
55 if (artifact instanceof WINFOArtifact) {
56 WINFOArtifact winfo = (WINFOArtifact)artifact;
57
58 CalculationResult res;
59
60 if (old instanceof CalculationResult) {
61 res = (CalculationResult)old;
62 }
63 else {
64 res = winfo.getDurationCurveData();
65 }
66
67 WQDay wqday = (WQDay)res.getData();
68
69 if (wqday != null && facets != null) {
70 RangeAccess rangeAccess = new RangeAccess(winfo, context);
71 // Create an i18ed name for a (w or q) duration curve facet.
72 Object[] args = new Object[] {
73 FLYSUtils.getRiver(winfo).getName(),
74 rangeAccess.getLocations()[0]
75 };
76
77 String nameW = Resources.getMsg(
78 context.getMeta(),
79 "chart.duration.curve.curve.w",
80 "",
81 args);
82
83 String nameQ = Resources.getMsg(
84 context.getMeta(),
85 "chart.duration.curve.curve.q",
86 "",
87 args);
88
89 Facet w = new DurationCurveFacet(DURATION_W, nameW);
90 Facet q = new DurationCurveFacet(DURATION_Q, nameQ);
91
92 facets.add(w);
93 facets.add(q);
94
95 facets.add(new DataFacet(CSV, "CSV data"));
96 facets.add(new DataFacet(PDF, "PDF data"));
97
98 if (res.getReport().hasProblems()) {
99 facets.add(new ReportFacet());
100 }
101 }
102
103 return res;
104 }
105 else if (artifact instanceof ChartArtifact) {
106 ChartArtifact chart = (ChartArtifact)artifact;
107 facets.add(new EmptyFacet());
108 return null;
109 }
110 return null;
111 }
112 }
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org