Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionFacet.java @ 9215:0fc9c82e744e
work on collison, flood_duration
author | gernotbelger |
---|---|
date | Tue, 03 Jul 2018 17:00:48 +0200 |
parents | 6393e05a9610 |
children |
rev | line source |
---|---|
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
2 * Software engineering by |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
5 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
9 */ |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
10 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
11 package org.dive4elements.river.artifacts.sinfo.collision; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
12 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
13 import java.util.ArrayList; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
14 import java.util.Collection; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
15 import java.util.List; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
16 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
17 import org.dive4elements.artifacts.Artifact; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
18 import org.dive4elements.artifacts.CallContext; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
19 import org.dive4elements.river.artifacts.D4EArtifact; |
9200 | 20 import org.dive4elements.river.artifacts.common.DefaultCalculationResult; |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.GeneralResultType; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
22 import org.dive4elements.river.artifacts.common.ResultRow; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
24 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
25 import org.dive4elements.river.model.sinfo.Collision; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
26 import org.dive4elements.river.model.sinfo.CollisionAggregateValue; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
27 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
28 /** |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
29 * Facet for a river bed collision value series loaded from the database |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
30 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
31 * @author Matthias Schäfer |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
32 */ |
9215 | 33 public class CollisionFacet extends BlackboardDataFacet { |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
34 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
35 private static final long serialVersionUID = 1; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
36 |
9215 | 37 public CollisionFacet(final int facetIndex, final String name, final String description, final String yAxisLabel) { |
38 super(facetIndex, name, description); | |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
39 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
40 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
41 this.metaData.put("Y", yAxisLabel); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
42 } |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
43 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
44 /** |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
45 * Returns the data this facet requires. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
46 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
47 * @param artifact |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
48 * the owner artifact. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
49 * @param context |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
50 * the CallContext (ignored). |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
51 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
52 * @return |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
53 * the data as CollisionQueryCalculationResult |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
54 */ |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
55 @Override |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
56 public Object getData(final Artifact artifact, final CallContext context) { |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
57 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
58 final CollisionDbAccess access = new CollisionDbAccess((D4EArtifact) artifact); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
59 final Collision series = Collision.getSeries(access.getId()); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
60 final List<CollisionAggregateValue> values = CollisionAggregateValue.getValuesByKm(series, access.getFrom(true), access.getTo(true)); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
61 final Collection<ResultRow> rows = new ArrayList<>(); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
62 for (final CollisionAggregateValue value : values) { |
9215 | 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); | |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
72 } |
9200 | 73 return new DefaultCalculationResult(series.getFilename(), rows); |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
74 } |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
75 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
76 /** |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
77 * Create a deep copy of this Facet. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
78 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
79 * @return a deep copy. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
80 */ |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
81 @Override |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
82 public CollisionFacet deepCopy() { |
9215 | 83 final CollisionFacet copy = new CollisionFacet(this.index, this.name, this.description, this.metaData.get("Y")); |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
84 copy.set(this); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
85 return copy; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
86 } |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
87 } |