comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffFacet.java @ 7985:10debf4b82be facet-metadata

Split bed differences facet into data specific facets.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 01 Jul 2014 15:09:56 +0200
parents
children 5acaf44062b5
comparison
equal deleted inserted replaced
7984:cf674b03901a 7985:10debf4b82be
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.model.minfo;
10
11 import org.apache.log4j.Logger;
12
13 import org.dive4elements.artifactdatabase.state.Facet;
14 import org.dive4elements.artifacts.Artifact;
15 import org.dive4elements.artifacts.CallContext;
16 import org.dive4elements.river.artifacts.D4EArtifact;
17 import org.dive4elements.river.artifacts.model.CalculationResult;
18 import org.dive4elements.river.artifacts.model.DataFacet;
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
20
21
22 public class BedDiffFacet
23 extends DataFacet
24 {
25 private static Logger logger = Logger.getLogger(BedDiffFacet.class);
26
27 public BedDiffFacet() {
28 }
29
30 public BedDiffFacet(int idx, String name, String description,
31 ComputeType type, String stateId, String hash) {
32 super(idx, name, description, type, hash, stateId);
33 this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
34 this.metaData.put("Y", "chart.beddifference.axis.label.y");
35 }
36
37 public Object getData(Artifact artifact, CallContext context) {
38 logger.debug("Get data for bed density at index: " + index);
39
40 D4EArtifact flys = (D4EArtifact) artifact;
41
42 CalculationResult res = (CalculationResult) flys.compute(context, hash,
43 stateId, type, false);
44
45 BedDiffYearResult[] resultData =
46 (BedDiffYearResult[]) res.getData(); // TODO CAST TO SPECIFIC CLASS
47
48 if (resultData != null && resultData.length > index) {
49 BedDiffYearResult data = resultData[index];
50 return data.getDifferencesData();
51 }
52 return null;
53 }
54
55 /** Copy deeply. */
56 @Override
57 public Facet deepCopy() {
58 BedDiffFacet copy = new BedDiffFacet();
59 copy.set(this);
60 copy.type = type;
61 copy.hash = hash;
62 copy.stateId = stateId;
63 return copy;
64 }
65 }
66 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org