Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedcollision/PredefinedCollisionFacet.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/collision/CollisionFacet.java@0fc9c82e744e |
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.predefinedcollision; | |
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.sinfo.common.SInfoResultType; | |
25 import org.dive4elements.river.model.sinfo.Collision; | |
26 import org.dive4elements.river.model.sinfo.CollisionAggregateValue; | |
27 | |
28 /** | |
29 * Facet for a river bed collision value series loaded from the database | |
30 * | |
31 * @author Matthias Schäfer | |
32 */ | |
33 public class PredefinedCollisionFacet extends BlackboardDataFacet { | |
34 | |
35 private static final long serialVersionUID = 1; | |
36 | |
37 public PredefinedCollisionFacet(final int facetIndex, final String name, final String description, final String yAxisLabel) { | |
38 super(facetIndex, 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 CollisionQueryCalculationResult | |
54 */ | |
55 @Override | |
56 public Object getData(final Artifact artifact, final CallContext context) { | |
57 | |
58 final PredefinedCollisionAccess access = new PredefinedCollisionAccess((D4EArtifact) artifact); | |
59 final Collision series = Collision.getSeries(access.getId()); | |
60 final List<CollisionAggregateValue> values = CollisionAggregateValue.getValuesByKm(series, access.getFrom(true), access.getTo(true)); | |
61 final Collection<ResultRow> rows = new ArrayList<>(); | |
62 for (final CollisionAggregateValue value : values) { | |
63 | |
64 final ResultRow row = ResultRow.create(); | |
65 | |
66 row.putValue(GeneralResultType.station, value.getStation()); | |
67 // Not needed: row.putValue(SInfoResultType.years, series.getYear()); | |
68 row.putValue(SInfoResultType.collisionCount, value.getCount()); | |
69 row.putValue(SInfoResultType.collisionGaugeW, value.getGaugeW()); | |
70 | |
71 rows.add(row); | |
72 } | |
73 return new DefaultCalculationResult(series.getFilename(), rows); | |
74 } | |
75 | |
76 /** | |
77 * Create a deep copy of this Facet. | |
78 * | |
79 * @return a deep copy. | |
80 */ | |
81 @Override | |
82 public PredefinedCollisionFacet deepCopy() { | |
83 final PredefinedCollisionFacet copy = new PredefinedCollisionFacet(this.index, this.name, this.description, this.metaData.get("Y")); | |
84 copy.set(this); | |
85 return copy; | |
86 } | |
87 } |