comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureFacet.java @ 9115:a165cd63099f

Added datacage select and chart display for river infrastructure heights loaded from database
author mschaefer
date Mon, 04 Jun 2018 11:55:08 +0200
parents
children a4121ec450d6
comparison
equal deleted inserted replaced
9114:31b3cae5de0d 9115:a165cd63099f
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.artifacts.sinfo.flood_duration;
12
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.List;
16
17 import org.dive4elements.artifacts.Artifact;
18 import org.dive4elements.artifacts.CallContext;
19 import org.dive4elements.river.artifacts.D4EArtifact;
20 import org.dive4elements.river.artifacts.common.GeneralResultType;
21 import org.dive4elements.river.artifacts.common.ResultRow;
22 import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
23 import org.dive4elements.river.artifacts.model.FacetTypes;
24 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
25 import org.dive4elements.river.model.sinfo.Infrastructure;
26 import org.dive4elements.river.model.sinfo.InfrastructureValue;
27
28 /**
29 * Facet for a infrastructure value series loaded from the database
30 *
31 * @author Matthias Schäfer
32 */
33 public class InfrastructureFacet extends BlackboardDataFacet implements FacetTypes {
34
35 private static final long serialVersionUID = 1;
36
37 public InfrastructureFacet(final String name, final String description, final String yAxisLabel) {
38 super(0, name, description);
39
40 this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
41 this.metaData.put("Y", yAxisLabel);
42 }
43
44 /**
45 * Returns the data this facet requires.
46 *
47 * @param artifact
48 * the owner artifact.
49 * @param context
50 * the CallContext (ignored).
51 *
52 * @return
53 * the data as InfrastructureQueryCalculationResult
54 */
55 @Override
56 public Object getData(final Artifact artifact, final CallContext context) {
57
58 final InfrastructureAccess access = new InfrastructureAccess((D4EArtifact) artifact);
59 final Infrastructure series = Infrastructure.getSeries(access.getId());
60 final List<InfrastructureValue> values = InfrastructureValue.getValues(series, access.getFrom(true), access.getTo(true));
61 final Collection<ResultRow> rows = new ArrayList<>();
62 for (final InfrastructureValue value : values) {
63 rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) //
64 .putValue(SInfoResultType.infrastructureHeight, value.getHeight()));
65 }
66 return new InfrastructureQueryCalculationResult(series.getFilename(), rows);
67 }
68
69 /**
70 * Create a deep copy of this Facet.
71 *
72 * @return a deep copy.
73 */
74 @Override
75 public InfrastructureFacet deepCopy() {
76 final InfrastructureFacet copy = new InfrastructureFacet(this.name, this.description, this.metaData.get("Y"));
77 copy.set(this);
78 return copy;
79 }
80 }

http://dive4elements.wald.intevation.org