8854
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
6 * documentation coming with Dive4Elements River for details. |
|
7 */ |
|
8 |
8916
|
9 package org.dive4elements.river.artifacts.sinfo.common; |
8854
|
10 |
|
11 import org.apache.log4j.Logger; |
|
12 import org.dive4elements.artifactdatabase.state.Facet; |
|
13 import org.dive4elements.artifacts.Artifact; |
|
14 import org.dive4elements.artifacts.CallContext; |
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
9166
|
16 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; |
9170
|
17 import org.dive4elements.river.artifacts.common.AbstractCalculationResults; |
8854
|
18 import org.dive4elements.river.artifacts.model.CalculationResult; |
|
19 import org.dive4elements.river.artifacts.model.DataFacet; |
|
20 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
|
21 |
|
22 /** |
|
23 * Facet of a FlowDepth curve. |
|
24 */ |
8916
|
25 public final class SInfoResultFacet extends DataFacet { |
8854
|
26 |
8884
|
27 private static final long serialVersionUID = 1L; |
8854
|
28 |
8916
|
29 private static Logger log = Logger.getLogger(SInfoResultFacet.class); |
8884
|
30 |
8916
|
31 public SInfoResultFacet() { |
8854
|
32 // required for clone operation deepCopy() |
|
33 } |
|
34 |
9170
|
35 public SInfoResultFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, |
|
36 final String stateId, final String hash) { |
8854
|
37 super(idx, name, description, type, hash, stateId); |
8916
|
38 this.metaData.put("X", "sinfo.chart.km.xaxis.label"); |
8884
|
39 this.metaData.put("Y", yAxisLabelKey); |
8854
|
40 } |
|
41 |
|
42 @Override |
8884
|
43 public Object getData(final Artifact artifact, final CallContext context) { |
8916
|
44 log.debug("Get data for result at index: " + this.index); |
8854
|
45 |
|
46 final D4EArtifact flys = (D4EArtifact) artifact; |
|
47 |
8884
|
48 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); |
8854
|
49 |
9170
|
50 final AbstractCalculationResults<AbstractCalculationResult> data = (AbstractCalculationResults<AbstractCalculationResult>) res.getData(); |
8884
|
51 |
8891
|
52 return data.getResults().get(this.index); |
8854
|
53 } |
|
54 |
|
55 /** Copy deeply. */ |
|
56 @Override |
|
57 public Facet deepCopy() { |
8891
|
58 // FIXME: why not simply use the full constructor instead? |
8916
|
59 final SInfoResultFacet copy = new SInfoResultFacet(); |
8854
|
60 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! |
|
61 copy.set(this); |
8884
|
62 copy.type = this.type; |
|
63 copy.hash = this.hash; |
|
64 copy.stateId = this.stateId; |
8854
|
65 return copy; |
|
66 } |
|
67 } |