Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java @ 9487:504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
author | mschaefer |
---|---|
date | Tue, 18 Sep 2018 12:21:17 +0200 |
parents | d194c5b24bf8 |
children |
comparison
equal
deleted
inserted
replaced
9486:ce13a2f07290 | 9487:504f63512379 |
---|---|
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.sinfo.collision; | 10 package org.dive4elements.river.artifacts.sinfo.collision; |
11 | 11 |
12 import java.util.ArrayList; | 12 import java.util.ArrayList; |
13 import java.util.Collection; | 13 import java.util.Collection; |
14 import java.util.List; | |
14 | 15 |
15 import org.apache.commons.collections.Predicate; | 16 import org.apache.commons.collections.Predicate; |
16 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | 17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
17 import org.dive4elements.river.artifacts.common.ExportContextCSV; | 18 import org.dive4elements.river.artifacts.common.ExportContextCSV; |
18 import org.dive4elements.river.artifacts.common.ExportContextPDF; | 19 import org.dive4elements.river.artifacts.common.ExportContextPDF; |
19 import org.dive4elements.river.artifacts.common.GeneralResultType; | 20 import org.dive4elements.river.artifacts.common.GeneralResultType; |
20 import org.dive4elements.river.artifacts.common.IResultType; | 21 import org.dive4elements.river.artifacts.common.IResultType; |
21 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | 22 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
22 import org.dive4elements.river.artifacts.common.ResultRow; | 23 import org.dive4elements.river.artifacts.common.ResultRow; |
24 import org.dive4elements.river.artifacts.model.DateRange; | |
23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | 25 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
24 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | 26 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
25 | 27 |
26 /** | 28 /** |
27 * Contains the results of a {@link CollisionCalculation}. | 29 * Contains the results of a {@link CollisionCalculation}. |
32 | 34 |
33 private static final long serialVersionUID = 1L; | 35 private static final long serialVersionUID = 1L; |
34 | 36 |
35 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; | 37 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; |
36 | 38 |
37 private final int[] singleYears; | 39 private final boolean isEpochs; |
38 | 40 |
39 public CollisionCalcOverviewResult(final String label, final int[] singleYears, final Collection<ResultRow> rows) { | 41 private final List<DateRange> years; |
42 | |
43 public CollisionCalcOverviewResult(final String label, final boolean isEpochs, final Collection<DateRange> years, final Collection<ResultRow> rows) { | |
40 super(label, rows); | 44 super(label, rows); |
41 this.singleYears = singleYears; | 45 this.isEpochs = isEpochs; |
46 this.years = new ArrayList<>(years); | |
42 } | 47 } |
43 | 48 |
44 public int[] getSingleYears() { | 49 public boolean getIsEpochs() { |
45 return this.singleYears; | 50 return this.isEpochs; |
46 } | 51 } |
47 | 52 |
48 public double[][] getStationPointsByYear(final IResultType type, final int year) { | 53 public List<DateRange> getYears() { |
54 return this.years; | |
55 } | |
56 | |
57 public double[][] getStationPointsByYear(final IResultType type, final String years) { | |
49 | 58 |
50 final Predicate filter = new Predicate() { | 59 final Predicate filter = new Predicate() { |
51 @Override | 60 @Override |
52 public boolean evaluate(final Object object) { | 61 public boolean evaluate(final Object object) { |
53 final ResultRow row = (ResultRow) object; | 62 final ResultRow row = (ResultRow) object; |
54 return getSingleYears() == null || Integer.valueOf(row.getValue(SInfoResultType.years).toString()) == year; | 63 return row.getValue(SInfoResultType.years).toString().equals(years); |
55 } | 64 } |
56 }; | 65 }; |
57 | 66 |
58 return getPoints(GeneralResultType.station, type, filter); | 67 return getPoints(GeneralResultType.station, type, filter); |
59 } | 68 } |