Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisPeriodsFacet.java @ 9415:9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
The facets also put the valid station range into their xml-metadata
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:27:53 +0200 |
parents | e4606eae8ea5 |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.fixings; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
11 import org.apache.log4j.Logger; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
12 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
13 import org.dive4elements.artifacts.CallContext; |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
14 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
15 import org.dive4elements.river.artifacts.model.CalculationResult; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
16 import org.dive4elements.river.artifacts.model.DateRange; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4866
diff
changeset
|
19 import org.dive4elements.river.utils.KMIndex; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
20 |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 * Facet to show W values for Q values at km for a date. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 * |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 */ |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
26 public class FixAnalysisPeriodsFacet extends FixingsFacet implements FacetTypes { |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
27 |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
28 private static final long serialVersionUID = 1L; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
30 /** House log. */ |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
31 private static Logger log = Logger.getLogger(FixAnalysisPeriodsFacet.class); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 /** Trivial Constructor. */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 public FixAnalysisPeriodsFacet() { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
37 public FixAnalysisPeriodsFacet(final int index, final String name, final String description) { |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
38 super(index, name, description, ComputeType.ADVANCE, null, null); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 * Returns the data this facet requires. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 * |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
44 * @param artifact |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
45 * the owner artifact. |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
46 * @param context |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
47 * the CallContext (ignored). |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 * |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 * @return the data. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 @Override |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
52 public Object getData(final Artifact artifact, final CallContext context) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
53 log.debug("FixAnalysisPeriodsFacet.getData"); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
55 if (artifact instanceof D4EArtifact) { |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
56 final D4EArtifact flys = (D4EArtifact) artifact; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
58 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
59 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
60 final FixAnalysisResult result = (FixAnalysisResult) res.getData(); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
61 final double currentKm = getCurrentKm(context); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
62 |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
63 final KMIndex<AnalysisPeriod[]> kmPeriods = result.getAnalysisPeriods(); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
64 final KMIndex.Entry<AnalysisPeriod[]> kmPeriodsEntry = kmPeriods.binarySearch(currentKm); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
65 if (kmPeriodsEntry == null) |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
66 return null; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
68 final AnalysisPeriod[] periods = kmPeriodsEntry.getValue(); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
69 if (periods == null) |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 return null; |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
71 |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
72 final DateRange[] dates = new DateRange[periods.length]; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 for (int i = 0; i < periods.length; i++) { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 dates[i] = periods[i].getDateRange(); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 } |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
76 |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 return dates; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
79 |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
80 log.debug("Not an instance of FixationArtifact."); |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
81 return null; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 * Create a deep copy of this Facet. |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
86 * |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 * @return a deep copy. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 @Override |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 public FixAnalysisPeriodsFacet deepCopy() { |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
91 final FixAnalysisPeriodsFacet copy = new FixAnalysisPeriodsFacet(); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 copy.set(this); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 return copy; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 } |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8202
diff
changeset
|
95 } |