Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/QSectorFacet.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
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:
5863
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:
5863
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:
4507
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
9726 | 11 import org.apache.logging.log4j.Logger; |
12 import org.apache.logging.log4j.LogManager; | |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
14 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
15 import org.dive4elements.artifacts.CallContext; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
17 import org.dive4elements.river.artifacts.QSectorArtifact; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
19 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
20 import org.dive4elements.artifactdatabase.state.Facet; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 |
8369
a5bd0a5b8efd
Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents:
8202
diff
changeset
|
22 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; |
a5bd0a5b8efd
Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents:
8202
diff
changeset
|
23 |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 * Facet to access QSector that where added by user. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 public class QSectorFacet |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 extends DefaultFacet |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 /** Logger for this class. */ |
9726 | 32 private static final Logger log = LogManager.getLogger(QSectorFacet.class); |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 * Trivial Constructor. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 public QSectorFacet() { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 * Trivial Constructor for a QSectorFacet. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 * |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 * @param index Database-Index to use. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 * @param name Name (~type) of Facet. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 * @param description Description of Facet. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 public QSectorFacet(int index, String name, String description) { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 super(index, name, description); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 * Get List of QSector for river from Artifact. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 * |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 * @param artifact (QSector-)Artifact to query for list of QSector. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 * @param context Ignored. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 @Override |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 public Object getData(Artifact artifact, CallContext context) { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 QSectorArtifact qsectorArtifact = (QSectorArtifact) artifact; |
4507
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
63 if (qsectorArtifact == null || context == null || |
8369
a5bd0a5b8efd
Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents:
8202
diff
changeset
|
64 context.getContextValue(CURRENT_KM) == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
65 log.error("No artifact, context or currentKm in QSectorFacet"); |
4507
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
66 return null; |
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
67 } |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 double currentKm = |
8369
a5bd0a5b8efd
Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents:
8202
diff
changeset
|
69 ((Double)context.getContextValue(CURRENT_KM)).doubleValue(); |
3576
6442f317a0c7
i18n and renderering of qsectors in w/q diag.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3573
diff
changeset
|
70 return qsectorArtifact.getQSectors(currentKm, context); |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 /** Do a deep copy. */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 @Override |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 public Facet deepCopy() { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 QSectorFacet copy = new QSectorFacet(); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 copy.set(this); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 return copy; |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |