Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | d20215a0afd8 |
children |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
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.artifactdatabase.state.Facet; | |
9 | |
10 import de.intevation.flys.artifacts.FLYSArtifact; | |
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
12 | |
13 | |
14 /** | |
15 * Access Discharge Curve of a gauge. | |
16 */ | |
17 public class GaugeDischargeFacet extends DataFacet { | |
18 | |
19 /** Private logger. */ | |
20 private static final Logger logger = | |
21 Logger.getLogger(GaugeDischargeFacet.class); | |
22 | |
23 | |
24 public GaugeDischargeFacet() { | |
25 } | |
26 | |
27 | |
28 /** | |
29 * @param index Index translates to index of WQ-array. | |
30 * @param name Name of the facet. | |
31 * @param desc Description of the facet (visible in client). | |
32 */ | |
33 public GaugeDischargeFacet(int index, String name, String desc) { | |
34 super(index, name, desc, ComputeType.ADVANCE, null, | |
35 "state.gaugedischarge.init"); | |
36 } | |
37 | |
38 | |
39 public GaugeDischargeFacet( | |
40 int index, | |
41 String name, | |
42 String description, | |
43 ComputeType type, | |
44 String stateID, | |
45 String hash | |
46 | |
47 ) { | |
48 super(index, name, description, type, hash, stateID); | |
49 } | |
50 | |
51 | |
52 @Override | |
53 public Facet deepCopy() { | |
54 GaugeDischargeFacet copy = new GaugeDischargeFacet(); | |
55 copy.set(this); | |
56 copy.type = type; | |
57 copy.hash = hash; | |
58 copy.stateId = stateId; | |
59 return copy; | |
60 } | |
61 | |
62 | |
63 /** | |
64 * @return wqkms corresponding to gauge of artifact and index of facet. | |
65 */ | |
66 @Override | |
67 public Object getData(Artifact artifact, CallContext context) { | |
68 if (logger.isDebugEnabled()) { | |
69 logger.debug("Get data for discharge curves at index: " + | |
70 index + " / stateId: " + stateId); | |
71 } | |
72 | |
73 if (stateId == null) { | |
74 logger.error("GaugeDischargeFacet.getData: stateId is null."); | |
75 } | |
76 FLYSArtifact flys = (FLYSArtifact) artifact; | |
77 | |
78 CalculationResult res = (CalculationResult) | |
79 flys.compute(context, hash, stateId, type, true); | |
80 | |
81 WQKms[] discharge = (WQKms[]) res.getData(); | |
82 | |
83 return discharge[index]; | |
84 } | |
85 } | |
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |