annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/QSectorFacet.java @ 8369:a5bd0a5b8efd

Use the CURRENT_KM constant from injectors.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 02 Oct 2014 13:57:50 +0200
parents e4606eae8ea5
children 0a5239a1e46e
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
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4507
diff changeset
13 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4507
diff changeset
14 import org.dive4elements.artifacts.CallContext;
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4507
diff changeset
16 import org.dive4elements.river.artifacts.QSectorArtifact;
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4507
diff changeset
18 import org.dive4elements.artifactdatabase.state.DefaultFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4507
diff changeset
19 import org.dive4elements.artifactdatabase.state.Facet;
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
8369
a5bd0a5b8efd Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents: 8202
diff changeset
21 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
22
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
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 * 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
26 */
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 public class QSectorFacet
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 extends DefaultFacet
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 {
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 /** Logger for this class. */
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
31 private static final Logger log = Logger.getLogger(QSectorFacet.class);
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
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 * Trivial Constructor.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 */
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 public QSectorFacet() {
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 }
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 * Trivial Constructor for a QSectorFacet.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 *
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 * @param index Database-Index to use.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 * @param name Name (~type) of Facet.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 * @param description Description of Facet.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 */
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 public QSectorFacet(int index, String name, String description) {
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 super(index, name, description);
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 }
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 * Get List of QSector for river from Artifact.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 *
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 * @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
57 * @param context Ignored.
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 */
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 @Override
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 public Object getData(Artifact artifact, CallContext context) {
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 QSectorArtifact qsectorArtifact = (QSectorArtifact) artifact;
4507
976ff4b74b96 QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3576
diff changeset
62 if (qsectorArtifact == null || context == null ||
8369
a5bd0a5b8efd Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents: 8202
diff changeset
63 context.getContextValue(CURRENT_KM) == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
64 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
65 return null;
976ff4b74b96 QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3576
diff changeset
66 }
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 double currentKm =
8369
a5bd0a5b8efd Use the CURRENT_KM constant from injectors.
Raimund Renkert <rrenkert@intevation.de>
parents: 8202
diff changeset
68 ((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
69 return qsectorArtifact.getQSectors(currentKm, context);
3573
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 }
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 /** Do a deep copy. */
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 @Override
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 public Facet deepCopy() {
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 QSectorFacet copy = new QSectorFacet();
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 copy.set(this);
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 return copy;
374c2d70b982 Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org