Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/WaterlevelSoundingYearFilter.java @ 9231:082e8e808902
Finetuning intelligent waterlevel-sounding select.
Soundings without year are never shown.
All involed datacage elements are assumed to have a 'year' attribute
author | gernotbelger |
---|---|
date | Fri, 06 Jul 2018 13:09:25 +0200 |
parents | 84397da33d17 |
children | 83ef08b5e1ac |
comparison
equal
deleted
inserted
replaced
9230:6a1580b38e7d | 9231:082e8e808902 |
---|---|
26 | 26 |
27 @Override | 27 @Override |
28 public boolean accept(final DataCageNode node) { | 28 public boolean accept(final DataCageNode node) { |
29 | 29 |
30 final AttrList attributes = node.getAttributes(); | 30 final AttrList attributes = node.getAttributes(); |
31 if (attributes == null) | 31 |
32 if (isFolder(attributes)) | |
32 return true; | 33 return true; |
33 | 34 |
34 if (!attributes.hasAttribute("factory")) | 35 final String year = attributes.getValue(WaterlevelSoundingSelectionController.ATTRIBUTE_YEAR); |
35 return true; | 36 final Integer waterlevelYear = parseYear(year); |
36 | |
37 final Integer waterlevelYear = getYear(attributes); | |
38 if (waterlevelYear == null) { | 37 if (waterlevelYear == null) { |
39 // should never happen, we should only show waterlevels that have a year | 38 // should never happen, we should only show waterlevels that have a year |
40 return false; | 39 return false; |
41 } | 40 } |
42 | 41 |
58 | 57 |
59 // > 1998 | 58 // > 1998 |
60 return 3; | 59 return 3; |
61 } | 60 } |
62 | 61 |
63 private static Integer getYear(final AttrList attributes) { | 62 static Integer parseYear(final String year) { |
64 | 63 |
65 final String year = attributes.getValue(WaterlevelSoundingSelectionController.ATTRIBUTE_YEAR); | |
66 if (year == null || year.trim().isEmpty()) | 64 if (year == null || year.trim().isEmpty()) |
67 return null; | 65 return null; |
68 | 66 |
69 try { | 67 try { |
70 return Integer.valueOf(year); | 68 return Integer.valueOf(year); |
72 catch (final NumberFormatException e) { | 70 catch (final NumberFormatException e) { |
73 e.printStackTrace(); | 71 e.printStackTrace(); |
74 return null; | 72 return null; |
75 } | 73 } |
76 } | 74 } |
75 | |
76 static boolean isFolder(final AttrList attributes) { | |
77 if (attributes == null) | |
78 return true; | |
79 | |
80 if (!attributes.hasAttribute("factory")) | |
81 return true; | |
82 | |
83 return false; | |
84 } | |
77 } | 85 } |