comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityDistanceSelect.java @ 8776:1116079e6624

Tidied.
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Dec 2015 19:35:11 +0100
parents 5102733c4567
children 6714e07e18c2
comparison
equal deleted inserted replaced
8775:76c84294c1d3 8776:1116079e6624
46 Artifact artifact, 46 Artifact artifact,
47 StateData data, 47 StateData data,
48 CallContext context) 48 CallContext context)
49 { 49 {
50 Element ele = super.createData(cr, artifact, data, context); 50 Element ele = super.createData(cr, artifact, data, context);
51 if (!data.getName().equals("ld_from") && !data.getName().equals("ld_to")) { 51 if (!data.getName().equals("ld_from")
52 && !data.getName().equals("ld_to")) {
52 return ele; 53 return ele;
53 } 54 }
54 55
55 D4EArtifact arti = (D4EArtifact) artifact; 56 D4EArtifact arti = (D4EArtifact) artifact;
56 RiverAccess access = new RiverAccess(arti); 57 RiverAccess access = new RiverAccess(arti);
57 58
58 /* Bit of an overkill here but it will be cached and accessed 59 /* Bit of an overkill here but it will be cached and accessed
59 * in the next state anyway. */ 60 * in the next state anyway. */
60 BedOverview overview = BedOverviewFactory.getOverview(access.getRiverName()); 61 BedOverview overview = BedOverviewFactory
62 .getOverview(access.getRiverName());
61 63
62 if (overview == null) { 64 if (overview == null) {
63 log.warn("No overview found for river '" + access.getRiverName() + "'"); 65 log.warn("No overview found for river '"
66 + access.getRiverName() + "'");
64 return ele; 67 return ele;
65 } 68 }
66 69
67 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT); 70 KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT);
68 if (entries.size() == 0) { 71 if (entries.size() == 0) {
69 log.warn("No data found for river '" + access.getRiverName() + "'"); 72 log.warn("No data found for river '"
73 + access.getRiverName() + "'");
70 return ele; 74 return ele;
71 } 75 }
72 entries.sort(); 76 entries.sort();
73 77
74 if (data.getName().equals("ld_from")) { 78 if (data.getName().equals("ld_from")) {
75 cr.addAttr(ele, "defaultLabel", data.getName(), true); 79 cr.addAttr(ele, "defaultLabel", data.getName(), true);
76 cr.addAttr(ele, "defaultValue", Double.toString(entries.get(0).getKm()), true); 80 cr.addAttr(ele, "defaultValue",
81 Double.toString(entries.get(0).getKm()), true);
77 } else if (data.getName().equals("ld_to")) { 82 } else if (data.getName().equals("ld_to")) {
78 cr.addAttr(ele, "defaultLabel", data.getName(), true); 83 cr.addAttr(ele, "defaultLabel", data.getName(), true);
79 cr.addAttr(ele, "defaultValue", Double.toString(entries.get(entries.size()-1).getKm()), true); 84 cr.addAttr(ele, "defaultValue",
85 Double.toString(entries.get(entries.size()-1).getKm()), true);
80 } 86 }
81 87
82 return ele; 88 return ele;
83 } 89 }
84 } 90 }

http://dive4elements.wald.intevation.org