Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionFacet.java @ 9195:a4121ec450d6
'ca.'-issue
ExportContextCSV+PDF separated
uinfo.inundationduration url export
author | gernotbelger |
---|---|
date | Fri, 29 Jun 2018 14:52:54 +0200 |
parents | 820ae41c81b6 |
children | 6393e05a9610 |
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; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
20 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
|
21 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
|
22 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
|
23 import org.dive4elements.river.artifacts.model.FacetTypes; |
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 */ |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
33 public class CollisionFacet extends BlackboardDataFacet implements FacetTypes { |
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 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
37 public CollisionFacet(final String name, final String description, final String yAxisLabel) { |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
38 super(0, name, description); |
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) { |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
63 rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) // |
9195 | 64 .putValue(SInfoResultType.collisionCount, value.getCount()).putValue(SInfoResultType.collisionGaugeW, value.getGaugeW())); |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
65 } |
9195 | 66 return new CollisionCalcOverviewResult(series.getFilename(), rows); |
9125
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
67 } |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
68 |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
69 /** |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
70 * 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
|
71 * |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
72 * @return a deep copy. |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
73 */ |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
74 @Override |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
75 public CollisionFacet deepCopy() { |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
76 final CollisionFacet copy = new CollisionFacet(this.name, this.description, this.metaData.get("Y")); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
77 copy.set(this); |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
78 return copy; |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
79 } |
820ae41c81b6
Fixed adding missing files for the river bed collision counts selectable in the datacage
mschaefer
parents:
diff
changeset
|
80 } |