comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java @ 3035:b388d888330d

Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet. flys-artifacts/trunk@4604 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 06 Jun 2012 11:35:32 +0000
parents
children 7db919b1bc1e
comparison
equal deleted inserted replaced
3034:842502b3913a 3035:b388d888330d
1 package de.intevation.flys.artifacts.model.fixings;
2
3 import org.apache.log4j.Logger;
4
5 import de.intevation.artifacts.Artifact;
6 import de.intevation.artifacts.CallContext;
7
8 import de.intevation.flys.utils.KMIndex;
9
10 import de.intevation.flys.artifacts.FLYSArtifact;
11 import de.intevation.flys.artifacts.FixationArtifactAccess;
12
13 import de.intevation.flys.artifacts.model.FacetTypes;
14 import de.intevation.flys.artifacts.model.DataFacet;
15 import de.intevation.flys.artifacts.model.CalculationResult;
16
17 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
18
19
20 /**
21 * Facet to show W values for Q values at km for a date.
22 *
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
24 */
25 public class FixReferenceEventsFacet
26 extends DataFacet
27 implements FacetTypes {
28
29 /** House logger. */
30 private static Logger logger = Logger.getLogger(FixReferenceEventsFacet.class);
31
32 /** Trivial Constructor. */
33 public FixReferenceEventsFacet() {
34 }
35
36
37 /**
38 * @param name
39 */
40 public FixReferenceEventsFacet(int index, String description) {
41 super(index, FIX_EVENTS, description, ComputeType.ADVANCE, null, null);
42 }
43
44
45 /**
46 * Returns the data this facet requires.
47 *
48 * @param artifact the owner artifact.
49 * @param context the CallContext (ignored).
50 *
51 * @return the data.
52 */
53 @Override
54 public Object getData(Artifact artifact, CallContext context) {
55 logger.debug("FixReferenceEventsFacet.getData");
56
57 if (artifact instanceof FLYSArtifact) {
58 FLYSArtifact flys = (FLYSArtifact)artifact;
59 FixationArtifactAccess access = new FixationArtifactAccess(flys);
60
61 CalculationResult res =
62 (CalculationResult) flys.compute(context,
63 ComputeType.ADVANCE,
64 false);
65
66 FixResult result = (FixResult) res.getData();
67
68 double km = access.getCurrentKm();
69 KMIndex<QW []> kmQWs = result.getReferenced();
70
71 QW[] qws = kmQWs.binarySearch(km).getValue();
72 if (qws == null) {
73 return null;
74 }
75 return qws;
76 }
77 else {
78 logger.debug("Not an instance of FixationArtifact.");
79 return null;
80 }
81 }
82
83
84 /**
85 * Create a deep copy of this Facet.
86 * @return a deep copy.
87 */
88 @Override
89 public FixReferenceEventsFacet deepCopy() {
90 FixReferenceEventsFacet copy = new FixReferenceEventsFacet();
91 copy.set(this);
92 return copy;
93 }
94 }
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org