comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedinfrastructure/PredefinedInfrastructureFacet.java @ 9377:e8d65cecc950

Renaming (predefined...) and own package for database loaded S-Info series of collisions and infrastructure height
author mschaefer
date Mon, 06 Aug 2018 11:48:49 +0200
parents artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureFacet.java@a4121ec450d6
children
comparison
equal deleted inserted replaced
9376:f318359b81a2 9377:e8d65cecc950
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.predefinedinfrastructure;
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.DefaultCalculationResult;
21 import org.dive4elements.river.artifacts.common.GeneralResultType;
22 import org.dive4elements.river.artifacts.common.ResultRow;
23 import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
24 import org.dive4elements.river.artifacts.model.FacetTypes;
25 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
26 import org.dive4elements.river.model.sinfo.Infrastructure;
27 import org.dive4elements.river.model.sinfo.InfrastructureValue;
28
29 /**
30 * Facet for a infrastructure value series loaded from the database
31 *
32 * @author Matthias Schäfer
33 */
34 public class PredefinedInfrastructureFacet extends BlackboardDataFacet implements FacetTypes {
35
36 private static final long serialVersionUID = 1;
37
38 public PredefinedInfrastructureFacet(final String name, final String description, final String yAxisLabel) {
39 super(0, name, description);
40
41 this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
42 this.metaData.put("Y", yAxisLabel);
43 }
44
45 /**
46 * Returns the data this facet requires.
47 *
48 * @param artifact
49 * the owner artifact.
50 * @param context
51 * the CallContext (ignored).
52 *
53 * @return
54 * the data as InfrastructureQueryCalculationResult
55 */
56 @Override
57 public Object getData(final Artifact artifact, final CallContext context) {
58
59 final PredefinedInfrastructureAccess access = new PredefinedInfrastructureAccess((D4EArtifact) artifact);
60 final Infrastructure series = Infrastructure.getSeries(access.getId());
61 final List<InfrastructureValue> values = InfrastructureValue.getValues(series, access.getFrom(true), access.getTo(true));
62 final Collection<ResultRow> rows = new ArrayList<>();
63 for (final InfrastructureValue value : values) {
64 rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) //
65 .putValue(SInfoResultType.infrastructureHeight, value.getHeight()));
66 }
67 return new DefaultCalculationResult(series.getFilename(), rows);
68 }
69
70 /**
71 * Create a deep copy of this Facet.
72 *
73 * @return a deep copy.
74 */
75 @Override
76 public PredefinedInfrastructureFacet deepCopy() {
77 final PredefinedInfrastructureFacet copy = new PredefinedInfrastructureFacet(this.name, this.description, this.metaData.get("Y"));
78 copy.set(this);
79 return copy;
80 }
81 }

http://dive4elements.wald.intevation.org