Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/QSectorFacet.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/QSectorFacet.java@bd047b71ab37 |
children | 4897a58c8746 |
rev | line source |
---|---|
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
1 package org.dive4elements.river.artifacts.model; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
5 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
6 import org.dive4elements.artifacts.CallContext; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
8 import org.dive4elements.river.artifacts.QSectorArtifact; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
10 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4507
diff
changeset
|
11 import org.dive4elements.artifactdatabase.state.Facet; |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 * 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
|
16 */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 public class QSectorFacet |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 extends DefaultFacet |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 /** Logger for this class. */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 private static final Logger logger = Logger.getLogger(QSectorFacet.class); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
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 * Trivial Constructor. |
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 QSectorFacet() { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 } |
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 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 * Trivial Constructor for a QSectorFacet. |
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 * @param index Database-Index to use. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 * @param name Name (~type) of Facet. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 * @param description Description of Facet. |
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(int index, String name, String description) { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 super(index, name, description); |
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 /** |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 * Get List of QSector for river from Artifact. |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 * |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 * @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
|
47 * @param context Ignored. |
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 @Override |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 public Object getData(Artifact artifact, CallContext context) { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 QSectorArtifact qsectorArtifact = (QSectorArtifact) artifact; |
4507
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
52 if (qsectorArtifact == null || context == null || |
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
53 context.getContextValue("currentKm") == null) { |
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
54 logger.error("No artifact, context or currentKm in QSectorFacet"); |
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
55 return null; |
976ff4b74b96
QSectorFacet: Guard access to curentKm in context.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3576
diff
changeset
|
56 } |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 double currentKm = |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 ((Double)context.getContextValue("currentKm")).doubleValue(); |
3576
6442f317a0c7
i18n and renderering of qsectors in w/q diag.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3573
diff
changeset
|
59 return qsectorArtifact.getQSectors(currentKm, context); |
3573
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 } |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 /** Do a deep copy. */ |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 @Override |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 public Facet deepCopy() { |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 QSectorFacet copy = new QSectorFacet(); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 copy.set(this); |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 return copy; |
374c2d70b982
Added stub of QSector-Artifact-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |