Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculationExtended.java @ 8957:7565d7dce850
Implemented calculation of 'year' for fixations
author | gernotbelger |
---|---|
date | Fri, 23 Mar 2018 17:52:59 +0100 |
parents | bd3095b3f028 |
children | 9744ce3c3853 |
comparison
equal
deleted
inserted
replaced
8956:ee5ce13016ed | 8957:7565d7dce850 |
---|---|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.model.fixings; | 10 package org.dive4elements.river.artifacts.model.fixings; |
11 | 11 |
12 import java.util.Calendar; | |
12 import java.util.Date; | 13 import java.util.Date; |
13 import java.util.List; | 14 import java.util.List; |
15 import java.util.SortedSet; | |
16 import java.util.TreeSet; | |
14 | 17 |
15 import org.dive4elements.river.artifacts.access.FixRealizingAccess; | 18 import org.dive4elements.river.artifacts.access.FixRealizingAccess; |
16 import org.dive4elements.river.artifacts.model.FixingsOverview; | 19 import org.dive4elements.river.artifacts.model.FixingsOverview; |
17 import org.dive4elements.river.artifacts.model.FixingsOverviewFactory; | 20 import org.dive4elements.river.artifacts.model.FixingsOverviewFactory; |
18 | 21 |
27 | 30 |
28 public FixRealizingCalculationExtended(final FixRealizingAccess fixAccess) { | 31 public FixRealizingCalculationExtended(final FixRealizingAccess fixAccess) { |
29 super(fixAccess); | 32 super(fixAccess); |
30 } | 33 } |
31 | 34 |
32 // FIXME: implement | |
33 // FIXME: check if this breaks serialization | |
34 public int determineMeanYear() { | 35 public int determineMeanYear() { |
35 final FixingsOverview overview = FixingsOverviewFactory.getOverview(this.river); | 36 final FixingsOverview overview = FixingsOverviewFactory.getOverview(this.river); |
36 final ColumnCache cc = new ColumnCache(); | 37 final ColumnCache cc = new ColumnCache(); |
37 | 38 |
38 // FIXME: die Hälfte der zeitlichen Differenz zwischen der ältesten und neusten WSPL | 39 final SortedSet<Integer> years = new TreeSet<>(); |
40 | |
41 final Calendar cal = Calendar.getInstance(); | |
39 | 42 |
40 final List<Column> columns = getEventColumns(overview, cc); | 43 final List<Column> columns = getEventColumns(overview, cc); |
41 for (final Column column : columns) { | 44 for (final Column column : columns) { |
42 final Date date = column.getDate(); | 45 final Date date = column.getDate(); |
46 cal.setTime(date); | |
47 | |
48 final int year = cal.get(Calendar.YEAR); | |
49 years.add(year); | |
43 } | 50 } |
44 | 51 |
45 return 1999; | 52 final Integer first = years.first(); |
53 final Integer last = years.last(); | |
54 if (first == null || last == null) | |
55 return -1; | |
56 | |
57 return (first + last) / 2; | |
46 } | 58 } |
47 } | 59 } |