annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MiddleBedHeight.java @ 5074:90b9b80ffbbf dami

Fix example run script to work with the new packaging
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 20 Feb 2013 18:50:13 +0100
parents a3dc382bc1ca
children
rev   line source
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
3 import java.util.ArrayList;
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.CallContext;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifactdatabase.state.Facet;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.artifacts.FLYSArtifact;
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
13 import de.intevation.flys.artifacts.access.BedHeightAccess;
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
14 import de.intevation.flys.artifacts.model.CalculationResult;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
15 import de.intevation.flys.artifacts.model.DataFacet;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
16 import de.intevation.flys.artifacts.model.FacetTypes;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
17 import de.intevation.flys.artifacts.model.MiddleBedHeightData;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
18 import de.intevation.flys.artifacts.model.MiddleBedHeightFacet;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
19 import de.intevation.flys.artifacts.model.MiddleBedHeightCalculation;
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
4582
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3232
diff changeset
22 /** State in which Middle Bed Heights are generated. */
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
23 public class MiddleBedHeight extends DefaultState implements FacetTypes {
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
4582
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3232
diff changeset
25 /** Private logger. */
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 private static final Logger logger = Logger.getLogger(MiddleBedHeight.class);
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public Object computeAdvance(
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 FLYSArtifact artifact,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 String hash,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 CallContext context,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 List<Facet> facets,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 Object old
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 ) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 logger.debug("MiddleBedHeight.computeAdvance");
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
39 List<Facet> newFacets = new ArrayList<Facet>();
3232
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
40
4826
a3dc382bc1ca BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4582
diff changeset
41 BedHeightAccess access = new BedHeightAccess(artifact, context);
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
43 CalculationResult res = old instanceof CalculationResult
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
44 ? (CalculationResult) old
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2715
diff changeset
45 : new MiddleBedHeightCalculation().calculate(access);
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
46
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
47 if (facets == null || res == null) {
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
48 return res;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
49 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
50
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
51 MiddleBedHeightData[] data = (MiddleBedHeightData[]) res.getData();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
52
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
53 logger.debug("Calculated " + data.length + " MiddleBedHeightData objects");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
54
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
55 String id = getID();
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
56 int idx = 0;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
57
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
58 for (MiddleBedHeightData d: data) {
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
59 if (d.getStartYear() == d.getEndYear()) {
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
60 newFacets.add(new MiddleBedHeightFacet(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
61 idx,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
62 MIDDLE_BED_HEIGHT_SINGLE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
63 d.getSoundingName(context),
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
64 ComputeType.ADVANCE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
65 id,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
66 hash
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
67 ));
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
68 }
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
69 else {
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
70 newFacets.add(new MiddleBedHeightFacet(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
71 idx,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
72 MIDDLE_BED_HEIGHT_EPOCH,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
73 d.getSoundingName(context),
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
74 ComputeType.ADVANCE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
75 id,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
76 hash
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
77 ));
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
78 }
2713
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
79
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
80 idx++;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
81 }
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
82
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
83 Facet csv = new DataFacet(
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
84 CSV, "CSV data", ComputeType.ADVANCE, hash, id);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
85
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
86 // TODO ADD PDF FACET
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
87
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
88 newFacets.add(csv);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
89
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
90 logger.debug("Created " + newFacets.size() + " new Facets.");
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
91
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
92 facets.addAll(newFacets);
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
93
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
94 return res;
b60751cfdd6c Start MINFO middle bed height calculation in the relevant state and creates facets for chart and csv.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
95 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org