# HG changeset patch # User Sascha L. Teichmann # Date 1326987837 0 # Node ID e92bc9b0ca1db41149446ac2a57358bf49b2370c # Parent a4bdf7d8527efa3e1468320910c57ee0f68a29f1 DistanceInfoService now uses annotations from LocationProvider. flys-artifacts/trunk@3724 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r a4bdf7d8527e -r e92bc9b0ca1d flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jan 19 13:43:58 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Jan 19 15:43:57 2012 +0000 @@ -1,3 +1,11 @@ +2012-01-19 Sascha L. Teichmann + + * doc/conf/cache.xml: Removed cache "service-distanceinfo". + + * src/main/java/de/intevation/flys/artifacts/services/DistanceInfoService.java: + Now uses the annotations from the LocationProvider and the + XML documents are no longer cached. + 2012-01-19 Sascha L. Teichmann * doc/conf/cache.xml: Removed "annotations" cache. diff -r a4bdf7d8527e -r e92bc9b0ca1d flys-artifacts/doc/conf/cache.xml --- a/flys-artifacts/doc/conf/cache.xml Thu Jan 19 13:43:58 2012 +0000 +++ b/flys-artifacts/doc/conf/cache.xml Thu Jan 19 15:43:57 2012 +0000 @@ -28,18 +28,9 @@ memoryStoreEvictionPolicy="LRU" /> - - - - 0 - ? river + "_" + filtertype - : river; - } - - - protected Document getUncached(String river, String filtertype) { - + protected Document buildDocument( + Iterator iter + ) { Document result = XMLUtils.newDocument(); - Iterator iter = - AnnotationsFactory.getAnnotationsIterator(river); - Element all = result.createElement("distances"); - DistanceFilter filter = getDistanceFilter(filtertype); - while (iter.hasNext()) { - Annotation a = iter.next(); - Element distance = buildDistanceNode(result, a, filter); - - if (distance != null) { - all.appendChild(distance); - } + all.appendChild(buildNode(result, iter.next())); } result.appendChild(all); @@ -136,75 +84,53 @@ return result; } + protected static FastAnnotations.Filter selectFilter(String name) { - protected static DistanceFilter getDistanceFilter(String type) { - if (type.equals("locations")) { - logger.debug("Found 'location' filter."); - return DistanceFilter.LOCATIONS; - } - else if (type.equals("distances")) { - logger.debug("Found 'distances' filter."); - return DistanceFilter.DISTANCES; + if (name != null) { + if ("locations".equals(name)) return FastAnnotations.IS_POINT; + if ("distances".equals(name)) return FastAnnotations.IS_RANGE; } - logger.debug("Do not use any filter at all."); - - return DistanceFilter.NONE; + return FastAnnotations.ALL; } - /** * Builds an Element for a distance info. * - * @param anno The Annotation that provides information about the distance. + * @param an The Annotation that provides information about the distance. * * @return an Element that contains information about a distance. */ - protected static Element buildDistanceNode( - Document document, - Annotation anno, - DistanceFilter filter + protected static Element buildNode( + Document document, + FastAnnotations.Annotation an ) { - Position pos = anno.getPosition(); - Range range = anno.getRange(); - Attribute attr = anno.getAttribute(); - Edge edge = anno.getEdge(); - BigDecimal a = range.getA(); - BigDecimal b = range.getB(); - - if (b == null && filter == DistanceFilter.DISTANCES) { - return null; - } - - if (b != null && filter == DistanceFilter.LOCATIONS) { - return null; - } - Element distance = document.createElement("distance"); - distance.setAttribute("description", pos.getValue()); + distance.setAttribute("description", an.getPosition()); - String riverSide = attr.getValue(); + String riverSide = an.getAttribute(); if (riverSide != null && riverSide.length() > 0) { distance.setAttribute("riverside", riverSide); } - if (a != null) { - distance.setAttribute("from", a.toString()); - } - if (b != null) { - distance.setAttribute("to", b.toString()); + distance.setAttribute("from", String.valueOf(an.getA())); + + double b = an.getB(); + double bottom = an.getBottom(); + double top = an.getTop(); + + if (!Double.isNaN(b)) { + distance.setAttribute("to", String.valueOf(b)); } - if (edge != null) { - BigDecimal bottom = edge.getBottom(); - BigDecimal top = edge.getTop(); - if (bottom != null) { - distance.setAttribute("bottom", bottom.toString()); - } - if (top != null) { - distance.setAttribute("top", top.toString()); - } + + if (!Double.isNaN(bottom)) { + distance.setAttribute("bottom", String.valueOf(bottom)); + } + + if (!Double.isNaN(top)) { + distance.setAttribute("top", String.valueOf(top)); } return distance;