annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MiddleBedHeight.java @ 3187:1e2733f749b5

SQ: Added specialized outlier test for the S/Q relation. flys-artifacts/trunk@4802 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Jun 2012 16:00:59 +0000
parents 250a370c377d
children b888c5eb65b3
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;
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
13 import de.intevation.flys.artifacts.MINFOArtifact;
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
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
22 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
23
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 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
25
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 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
29 FLYSArtifact artifact,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 String hash,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 CallContext context,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 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
33 Object old
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 ) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 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
36
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
37 List<Facet> newFacets = new ArrayList<Facet>();
2709
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 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
40 ? (CalculationResult) old
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
41 : new MiddleBedHeightCalculation().calculate((MINFOArtifact) artifact);
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
42
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 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
44 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
45 }
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 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
48
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 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
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 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
52 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
53
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 for (MiddleBedHeightData d: data) {
2715
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
55 if (d.getStartYear() == d.getEndYear()) {
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
56 newFacets.add(new MiddleBedHeightFacet(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
57 idx,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
58 MIDDLE_BED_HEIGHT_SINGLE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
59 d.getSoundingName(context),
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
60 ComputeType.ADVANCE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
61 id,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
62 hash
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
63 ));
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
64 }
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
65 else {
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
66 newFacets.add(new MiddleBedHeightFacet(
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
67 idx,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
68 MIDDLE_BED_HEIGHT_EPOCH,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
69 d.getSoundingName(context),
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
70 ComputeType.ADVANCE,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
71 id,
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
72 hash
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
73 ));
250a370c377d Added chart generator for middle bed height charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2713
diff changeset
74 }
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
75
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
76 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
77 }
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
78
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 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
80 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
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 // 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
83
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 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
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 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
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 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
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 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
91 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org