annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java @ 2228:4db19a88bddb

Implemented the first step of Calculation6; create Facets for each calculation results. flys-artifacts/trunk@3868 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 01 Feb 2012 14:48:00 +0000
parents ebbb18ed78c4
children 7335c526befd
rev   line source
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
3 import java.util.List;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.w3c.dom.Element;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
7 import org.apache.log4j.Logger;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
8
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.Artifact;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.CallContext;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
14 import de.intevation.artifactdatabase.state.Facet;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
16 import de.intevation.flys.artifacts.FLYSArtifact;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
17 import de.intevation.flys.artifacts.WINFOArtifact;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
18 import de.intevation.flys.artifacts.model.CalculationResult;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
19 import de.intevation.flys.artifacts.model.FacetTypes;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
20 import de.intevation.flys.artifacts.model.HistoricalDischargeFacet;
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
21 import de.intevation.flys.artifacts.model.WQTimerange;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /**
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 */
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
27 public class HistoricalDischargeComputeState
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
28 extends DefaultState
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
29 implements FacetTypes
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
30 {
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
31
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
32 private static final Logger logger =
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
33 Logger.getLogger(HistoricalDischargeComputeState.class);
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
34
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 @Override
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 protected void appendItems(
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 Artifact artifact,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 ElementCreator creator,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 String name,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 CallContext context,
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 Element select
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 ) {
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 // TODO IMPLEMENT ME
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 }
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
46
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
47
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
48 @Override
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
49 public Object computeAdvance(
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
50 FLYSArtifact artifact,
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
51 String hash,
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
52 CallContext context,
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
53 List<Facet> facets,
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
54 Object old
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
55 ) {
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
56 logger.debug("HistoricalDischargeComputeState.computeAdvance");
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
57
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
58 WINFOArtifact winfo = (WINFOArtifact) artifact;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
59
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
60 CalculationResult res = old instanceof CalculationResult
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
61 ? (CalculationResult) old
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
62 : winfo.getHistoricalDischargeData();
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
63
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
64 if (facets == null) {
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
65 return res;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
66 }
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
67
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
68 WQTimerange[] data = (WQTimerange[]) res.getData();
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
69 if (data == null || data.length == 0) {
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
70 logger.warn("Historical Discharge calculation has no results!");
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
71 return res;
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
72 }
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
73
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
74 prepareFacets(facets, data);
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
75
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
76 return res;
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2191
diff changeset
77 }
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
78
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
79
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
80 protected void prepareFacets(List<Facet> facets, WQTimerange[] wqts) {
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
81 int i = 0;
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
82
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
83 for (WQTimerange wqt: wqts) {
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
84 logger.debug("Prepare facet for: " + wqt.getName());
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
85
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
86 // TODO CREATE BETTER TITLE FOR FACETS
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
87
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
88 facets.add(new HistoricalDischargeFacet(
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
89 i++,
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
90 HISTORICAL_DISCHARGE_Q,
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
91 wqt.getName()));
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
92 }
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
93 }
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org