comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityDistanceSelect.java @ 8682:5102733c4567

issue1755 Prevent out of bounds access when there is no data If there is no data it will default to the complete river. In the following overview you can then see that there is no data. Better then a "Error changing state".
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 13 Apr 2015 11:03:00 +0200
parents 39ce099a6551
children 1116079e6624
comparison
equal deleted inserted replaced
8681:1f878c82262f 8682:5102733c4567
63 log.warn("No overview found for river '" + access.getRiverName() + "'"); 63 log.warn("No overview found for river '" + access.getRiverName() + "'");
64 return ele; 64 return ele;
65 } 65 }
66 66
67 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT); 67 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT);
68 if (entries.size() == 0) {
69 log.warn("No data found for river '" + access.getRiverName() + "'");
70 return ele;
71 }
68 entries.sort(); 72 entries.sort();
69 73
70 if (data.getName().equals("ld_from")) { 74 if (data.getName().equals("ld_from")) {
71 cr.addAttr(ele, "defaultLabel", data.getName(), true); 75 cr.addAttr(ele, "defaultLabel", data.getName(), true);
72 cr.addAttr(ele, "defaultValue", Double.toString(entries.get(0).getKm()), true); 76 cr.addAttr(ele, "defaultValue", Double.toString(entries.get(0).getKm()), true);

http://dive4elements.wald.intevation.org