Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/common/ResultFacet.java @ 9347:08f46ccd37ba
salix.regional refactoring
author | gernotbelger |
---|---|
date | Tue, 31 Jul 2018 16:04:01 +0200 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultFacet.java@0fc9c82e744e |
children | f8308db94634 |
rev | line source |
---|---|
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 | |
9347 | 9 package org.dive4elements.river.artifacts.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; | |
16 import org.dive4elements.river.artifacts.model.CalculationResult; | |
17 import org.dive4elements.river.artifacts.model.DataFacet; | |
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
19 | |
20 /** | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9170
diff
changeset
|
21 * Facet of one of the S-Info curves. |
8854 | 22 */ |
9347 | 23 // TODO: rename: hat nichts mehr mit sinfo zu tun |
24 public class ResultFacet extends DataFacet { | |
8854 | 25 |
8884 | 26 private static final long serialVersionUID = 1L; |
8854 | 27 |
9347 | 28 private static Logger log = Logger.getLogger(ResultFacet.class); |
8884 | 29 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
30 private int resultIndex; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
31 |
9347 | 32 public ResultFacet() { |
8854 | 33 // required for clone operation deepCopy() |
34 } | |
35 | |
9347 | 36 public ResultFacet(final int resultIndex, final String name, final String description, final String yAxisLabelKey, final ComputeType type, |
9170 | 37 final String stateId, final String hash) { |
9215 | 38 this(resultIndex, resultIndex, name, description, yAxisLabelKey, type, stateId, hash); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
39 } |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
40 |
9347 | 41 public ResultFacet(final int facetIndex, final int resultIndex, final String name, final String description, final String yAxisLabelKey, |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
42 final ComputeType type, final String stateId, final String hash) { |
9215 | 43 // REMARK: in some cases, we have several data-lines for the same result (which normally determines the facet index) and |
44 // facet name. But index and name are used by the client side as unique keys for the chart themes... | |
45 // So we might have different facet index and result index. | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
46 super(facetIndex, name, description, type, hash, stateId); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
47 this.resultIndex = resultIndex; |
9215 | 48 |
8916 | 49 this.metaData.put("X", "sinfo.chart.km.xaxis.label"); |
8884 | 50 this.metaData.put("Y", yAxisLabelKey); |
8854 | 51 } |
52 | |
53 @Override | |
9215 | 54 public final Object getData(final Artifact artifact, final CallContext context) { |
55 log.debug("Get data for result at index: " + this.resultIndex); | |
8854 | 56 |
57 final D4EArtifact flys = (D4EArtifact) artifact; | |
58 | |
8884 | 59 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); |
8854 | 60 |
9170 | 61 final AbstractCalculationResults<AbstractCalculationResult> data = (AbstractCalculationResults<AbstractCalculationResult>) res.getData(); |
8884 | 62 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
63 return data.getResults().get(this.resultIndex); |
8854 | 64 } |
65 | |
66 /** Copy deeply. */ | |
67 @Override | |
68 public Facet deepCopy() { | |
8891 | 69 // FIXME: why not simply use the full constructor instead? |
9347 | 70 final ResultFacet copy = new ResultFacet(); |
8854 | 71 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! |
72 copy.set(this); | |
8884 | 73 copy.type = this.type; |
74 copy.hash = this.hash; | |
75 copy.stateId = this.stateId; | |
8854 | 76 return copy; |
77 } | |
9347 | 78 |
79 @Override | |
80 public void set(final Facet other) { | |
81 this.resultIndex = ((ResultFacet) other).resultIndex; | |
82 super.set(other); | |
83 } | |
8854 | 84 } |