Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultFacet.java @ 9202:b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
author | mschaefer |
---|---|
date | Mon, 02 Jul 2018 07:33:53 +0200 |
parents | 9b2e46090099 |
children | 3dae6b78e1da |
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 | |
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 /** | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9170
diff
changeset
|
23 * Facet of one of the S-Info curves. |
8854 | 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 } |