Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWQKmsArtifact.java @ 9425:3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 15:31:02 +0200 |
parents | 23264d1a528f |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5859
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:
5859
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5859
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:
5859
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:
5859
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5859
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
9 package org.dive4elements.river.artifacts; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
11 import java.io.Serializable; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.util.ArrayList; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import java.util.List; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
16 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
17 import org.dive4elements.artifactdatabase.state.FacetActivity; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
18 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
19 import org.dive4elements.artifacts.ArtifactFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
20 import org.dive4elements.artifacts.CallContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
21 import org.dive4elements.artifacts.CallMeta; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
22 import org.dive4elements.artifacts.common.utils.XMLUtils; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
24 import org.dive4elements.river.artifacts.model.WKms; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.WKmsFactory; |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.WQKms; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.WQKmsFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5803
diff
changeset
|
28 import org.dive4elements.river.artifacts.states.DefaultState; |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
29 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
30 import org.w3c.dom.Document; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 * Artifact to access additional "waterlevel/discharge"-type of data, like |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 * fixation measurements. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 * |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
36 * This artifact neglects (Static)D4EArtifacts capabilities of interaction |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 * with the StateEngine by overriding the getState*-methods. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 */ |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
39 public class StaticWQKmsArtifact extends StaticD4EArtifact implements FacetTypes, WaterLineArtifact { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
40 /** The log for this class. */ |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
41 private static Logger log = Logger.getLogger(StaticWQKmsArtifact.class); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
43 public static final String STATIC_STATE_NAME = "state.additional_wqkms.static"; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
45 private static final String NAME = "staticwqkms"; |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
46 |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
47 static { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
48 // TODO: Move to configuration. |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
49 FacetActivity.Registry.getInstance().register(NAME, new FacetActivity() { |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
50 @Override |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
51 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String outputName) { |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
52 final String fname = facet.getName(); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
53 return (fname.equals(STATIC_WQKMS) || fname.equals(STATIC_WQKMS_W)); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
54 } |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
55 }); |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
56 } |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 * Trivial Constructor. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 public StaticWQKmsArtifact() { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
62 log.debug("StaticWQKmsArtifact.StaticWQKmsArtifact"); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 * Gets called from factory, to set things up. |
6598
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
67 * |
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
68 * If the id's string starts with official- it will be treated as |
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
69 * an Artifact containing official data for the according special |
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
70 * case handling. |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 @Override |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
73 public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data, |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
74 final List<Class> loadFacets) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
75 log.debug("StaticWQKmsArtifact.setup"); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
77 // Store the 'ids' (from datacage). |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
78 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
79 log.debug("StaticWQKmsArtifact.setup" + XMLUtils.toString(data)); |
3405
b0ba96bbf01d
Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
80 } |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
82 final String code = getDatacageIDValue(data); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
83 addStringData("ids", code); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 if (code != null) { |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
85 final String[] parts = code.split("-"); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 |
6598
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
87 if (parts.length >= 1) { |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
88 final boolean official = parts[0].toLowerCase().startsWith("official"); |
7637
49a92f7e2017
issue1020: Do not set a data with value null, this breaks stuff further
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7619
diff
changeset
|
89 addStringData("official", official ? "1" : "0"); |
6598
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
90 } |
ca56c4e6a755
Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents:
6000
diff
changeset
|
91 |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 if (parts.length >= 4) { |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
93 final int col = Integer.parseInt(parts[2]); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
94 final int wst = Integer.parseInt(parts[3]); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 |
1900
64ffc371afe7
Adjusted implementation to match implementation in StaticWKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1825
diff
changeset
|
96 addStringData("col_pos", parts[2]); |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
97 addStringData("wst_id", parts[3]); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
101 // Do this AFTER we have set the col_pos etc. |
7842
8d5ca5175038
Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents:
7637
diff
changeset
|
102 super.setup(identifier, factory, context, callMeta, data, loadFacets); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 * Called via setup. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 * |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
108 * @param artifact |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
109 * The master-artifact. |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 @Override |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
112 protected void initialize(final Artifact artifact, final Object context, final CallMeta meta) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
113 log.debug("StaticWQKmsArtifact.initialize"); |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
114 final D4EArtifact flys = (D4EArtifact) artifact; |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
115 // TODO: The river is of no interest, so far., also use importData |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
116 importData(flys, "river"); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
118 final List<Facet> fs = new ArrayList<>(); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
120 final DefaultState state = (DefaultState) getCurrentState(context); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
121 state.computeInit(this, hash(), context, meta, fs); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2763
diff
changeset
|
122 if (!fs.isEmpty()) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
123 log.debug("Facets to add in StaticWQKmsArtifact.initialize ."); |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3556
diff
changeset
|
124 addFacets(getCurrentStateId(), fs); |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
125 } else { |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
126 log.debug("No facets to add in StaticWQKmsArtifact.initialize (" + state.getID() + ")."); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
127 } |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 * Get WQKms from factory. |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
132 * |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 * @return WQKms according to parameterization (can be null); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 */ |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
135 public WQKms getWQKms() { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
136 log.debug("StaticWQKmsArtifact.getWQKms"); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
138 final int col = Integer.parseInt(getDataAsString("col_pos")); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
139 final int wst = Integer.parseInt(getDataAsString("wst_id")); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
140 |
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
141 /** TODO do not run twice against db to do this. */ |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
142 final String wkmsName = WKmsFactory.getWKmsName(col, wst); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
143 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
144 final WQKms res = WQKmsFactory.getWQKms(col, wst); |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
145 res.setName(wkmsName); |
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
146 return res; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 |
8876
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
149 /** |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
150 * Get WQKms from factory. |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
151 * |
8876
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
152 * @return WQKms according to parameterization (can be null); |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
153 */ |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
154 public WQKms getWQKms(final double from, final double to) { |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
155 log.debug("StaticWQKmsArtifact.getWQKms"); |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
156 |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
157 final int col = Integer.parseInt(getDataAsString("col_pos")); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
158 final int wst = Integer.parseInt(getDataAsString("wst_id")); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
159 |
8876
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
160 /** TODO do not run twice against db to do this. */ |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
161 final String wkmsName = WKmsFactory.getWKmsName(col, wst); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
162 |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
163 final WQKms res = WQKmsFactory.getWQKms(col, wst, from, to); |
8876
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
164 res.setName(wkmsName); |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
165 return res; |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
166 } |
23264d1a528f
Allow access to staticwqkms data; also allow to acces by km range
gernotbelger
parents:
8856
diff
changeset
|
167 |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
168 /** Return specific name. */ |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
169 @Override |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
170 public String getName() { |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
171 return NAME; |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
172 } |
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
173 |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
174 /** |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
175 * Get points of line describing the surface of water at cross section. |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
176 * |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
177 * @param idx |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
178 * Index of facet and in wkms array. |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
179 * @param csl |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
180 * FastCrossSectionLine to compute water surface agains. |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
181 * @param next |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
182 * The km of the next crosssectionline. |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
183 * @param prev |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
184 * The km of the previous crosssectionline. |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
185 * @param context |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
186 * Ignored in this implementation. |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
187 * |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
188 * @return an array holding coordinates of points of surface of water ( |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
189 * in the form {{x1, x2}, {y1, y2}} ). |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
190 */ |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
191 @Override |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
192 public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex, |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
193 final double nextKm, final double prevKm, final CallContext context) { |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
194 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
195 final WKms wkms = getWQKms(); |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
196 |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
197 // Find W at km. |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
198 final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm); |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
199 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
200 if (Double.isNaN(wAtKm)) { |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
201 log.warn("Waterlevel at km " + currentKm + " unknown."); |
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
202 return Double.NaN; |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
203 } |
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
204 |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
205 return wAtKm; |
5798
febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
206 } |
2124
a202a9e048a5
Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1900
diff
changeset
|
207 // TODO implement deepCopy. |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8876
diff
changeset
|
208 } |