Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenarioResultFacet.java @ 9316:72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
author | mschaefer |
---|---|
date | Thu, 26 Jul 2018 17:28:32 +0200 |
parents | |
children | 08f46ccd37ba |
comparison
equal
deleted
inserted
replaced
9315:2ff46d921917 | 9316:72b3270e1568 |
---|---|
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 | |
9 package org.dive4elements.river.artifacts.uinfo.salix; | |
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.common.AbstractCalculationResult; | |
17 import org.dive4elements.river.artifacts.common.AbstractCalculationResults; | |
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 the U-Info salix scenario curve. | |
24 */ | |
25 public class SalixScenarioResultFacet extends DataFacet { | |
26 | |
27 private static final long serialVersionUID = 1L; | |
28 | |
29 private static Logger log = Logger.getLogger(SalixScenarioResultFacet.class); | |
30 | |
31 private int resultIndex; | |
32 | |
33 public SalixScenarioResultFacet() { | |
34 // required for clone operation deepCopy() | |
35 } | |
36 | |
37 public SalixScenarioResultFacet(final String name, final String description, final int facetIndex, final String hash, final String id) { | |
38 super(facetIndex, name, description, ComputeType.ADVANCE, hash, id); | |
39 } | |
40 | |
41 @Override | |
42 public final Object getData(final Artifact artifact, final CallContext context) { | |
43 | |
44 log.debug("Get data for result at index: " + this.resultIndex); | |
45 | |
46 final D4EArtifact flys = (D4EArtifact) artifact; | |
47 | |
48 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); | |
49 | |
50 final AbstractCalculationResults<AbstractCalculationResult> data = (AbstractCalculationResults<AbstractCalculationResult>) res.getData(); | |
51 | |
52 return data.getResults().get(this.resultIndex); | |
53 } | |
54 | |
55 /** Copy deeply. */ | |
56 @Override | |
57 public Facet deepCopy() { | |
58 // FIXME: why not simply use the full constructor instead? | |
59 final SalixScenarioResultFacet copy = new SalixScenarioResultFacet(); | |
60 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! | |
61 copy.set(this); | |
62 copy.type = this.type; | |
63 copy.hash = this.hash; | |
64 copy.stateId = this.stateId; | |
65 return copy; | |
66 } | |
67 } |