Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java@05eeedc5b156 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.model.fixings; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import org.dive4elements.artifacts.Artifact; | |
6 import org.dive4elements.artifacts.CallContext; | |
7 import org.dive4elements.river.artifacts.FLYSArtifact; | |
8 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9 import org.dive4elements.river.artifacts.model.FacetTypes; | |
10 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
11 import org.dive4elements.river.utils.KMIndex; | |
12 | |
13 | |
14 /** | |
15 * Facet to show W values for Q values at km for a date. | |
16 * | |
17 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
18 */ | |
19 public class FixReferenceEventsFacet | |
20 extends FixingsFacet | |
21 implements FacetTypes { | |
22 | |
23 /** House logger. */ | |
24 private static Logger logger = Logger.getLogger(FixReferenceEventsFacet.class); | |
25 | |
26 /** Trivial Constructor. */ | |
27 public FixReferenceEventsFacet() { | |
28 } | |
29 | |
30 | |
31 /** | |
32 * @param name | |
33 */ | |
34 public FixReferenceEventsFacet(int index, String name, String description) { | |
35 super(index, | |
36 name, | |
37 description, | |
38 ComputeType.ADVANCE, | |
39 null, | |
40 null); | |
41 } | |
42 | |
43 | |
44 /** | |
45 * Returns the data this facet requires. | |
46 * | |
47 * @param artifact the owner artifact. | |
48 * @param context the CallContext (ignored). | |
49 * | |
50 * @return the data. | |
51 */ | |
52 @Override | |
53 public Object getData(Artifact artifact, CallContext context) { | |
54 logger.debug("FixReferenceEventsFacet.getData"); | |
55 | |
56 if (artifact instanceof FLYSArtifact) { | |
57 FLYSArtifact flys = (FLYSArtifact)artifact; | |
58 | |
59 CalculationResult res = | |
60 (CalculationResult) flys.compute(context, | |
61 ComputeType.ADVANCE, | |
62 false); | |
63 | |
64 FixResult result = (FixResult) res.getData(); | |
65 double currentKm = getCurrentKm(context); | |
66 | |
67 logger.debug("current km in FRE: " + currentKm); | |
68 | |
69 KMIndex<QWD []> kmQWs = result.getReferenced(); | |
70 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); | |
71 QWD[] qwds = null; | |
72 if (kmQWsEntry != null) { | |
73 int ndx = index & 255; | |
74 qwds = kmQWsEntry.getValue(); | |
75 for (int i = 0; i < qwds.length; i++) { | |
76 if (qwds[i].getIndex() == ndx) { | |
77 return qwds[i]; | |
78 } | |
79 } | |
80 return null; | |
81 } | |
82 return null; | |
83 } | |
84 else { | |
85 logger.debug("Not an instance of FixationArtifact."); | |
86 return null; | |
87 } | |
88 } | |
89 | |
90 | |
91 /** | |
92 * Create a deep copy of this Facet. | |
93 * @return a deep copy. | |
94 */ | |
95 @Override | |
96 public FixReferenceEventsFacet deepCopy() { | |
97 FixReferenceEventsFacet copy = new FixReferenceEventsFacet(); | |
98 copy.set(this); | |
99 return copy; | |
100 } | |
101 } | |
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |