Mercurial > dive4elements > river
changeset 3727:b81f328da582
Removed code duplication.
flys-artifacts/trunk@5399 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 08 Sep 2012 12:58:58 +0000 |
parents | b679f6048acc |
children | d03e65378b9f |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java |
diffstat | 3 files changed, 14 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sat Sep 08 12:35:51 2012 +0000 +++ b/flys-artifacts/ChangeLog Sat Sep 08 12:58:58 2012 +0000 @@ -1,7 +1,13 @@ 2012-09-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> - * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: - Removed trailing whitespace. + * src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java, + src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java: + Removed code duplication. + +2012-09-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: + Removed trailing whitespace. 2012-09-08 Sascha L. Teichmann <sascha.teichmann@intevation.de>
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java Sat Sep 08 12:35:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java Sat Sep 08 12:58:58 2012 +0000 @@ -19,7 +19,7 @@ /** Private logger. */ private static Logger logger = Logger.getLogger(FixChartGenerator.class); - public static final double INVALID_KM = Double.valueOf(-1d); + public static final Double INVALID_KM = Double.valueOf(-1d); public static final String CURRENT_KM = "currentKm"; public static final String XPATH_CHART_CURRENTKM = "/art:action/art:attributes/art:currentKm/@art:km"; @@ -28,7 +28,7 @@ public void init(Document request, OutputStream out, CallContext context) { super.init(request, out, context); - double currentKm = getCurrentKmFromRequest(request); + Double currentKm = getCurrentKmFromRequest(request); if (logger.isDebugEnabled()) { logger.debug("currentKm = " + currentKm); @@ -37,7 +37,7 @@ context.putContextValue(CURRENT_KM, currentKm); } - public static double getCurrentKmFromRequest(Document request) { + public static final Double getCurrentKmFromRequest(Document request) { String km = XMLUtils.xpathString( request,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java Sat Sep 08 12:35:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java Sat Sep 08 12:58:58 2012 +0000 @@ -1,9 +1,7 @@ package de.intevation.flys.exports.fixings; import de.intevation.artifactdatabase.state.ArtifactAndFacet; -import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.CallContext; -import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.access.FixAnalysisAccess; import de.intevation.flys.artifacts.model.DateRange; @@ -26,8 +24,6 @@ import java.util.Map; import java.util.Set; -import javax.xml.xpath.XPathConstants; - import org.apache.log4j.Logger; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.data.time.Day; @@ -35,7 +31,6 @@ import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.w3c.dom.Document; -import org.w3c.dom.Element; /** @@ -50,9 +45,6 @@ private static Logger logger = Logger.getLogger(FixDeltaWtGenerator.class); - public static final String XPATH_CHART_CURRENTKM = - "/art:action/art:attributes/art:currentKm"; - public static final String I18N_CHART_TITLE = "chart.fix.deltawt.title"; @@ -110,7 +102,8 @@ context.getMeta(), I18N_CHART_TITLE, "", - getCurrentKmFromRequest().doubleValue()); + FixChartGenerator + .getCurrentKmFromRequest(request).doubleValue()); } @@ -403,7 +396,7 @@ public void init(Document request, OutputStream out, CallContext context) { super.init(request, out, context); - Double currentKm = getCurrentKmFromRequest(); + Double currentKm = FixChartGenerator.getCurrentKmFromRequest(request); if (logger.isDebugEnabled()) { logger.debug("currentKm = " + currentKm); @@ -414,28 +407,5 @@ StyledValueMarker marker = new StyledValueMarker(0, request); valueMarker.add(marker); } - - protected Double getCurrentKmFromRequest() { - Element km = (Element)XMLUtils.xpath( - request, - XPATH_CHART_CURRENTKM, - XPathConstants.NODE, - ArtifactNamespaceContext.INSTANCE); - - if (km == null) { - return Double.valueOf(-1d); - } - - String uri = ArtifactNamespaceContext.NAMESPACE_URI; - // XXX: When using XPath already why is the 'km' - // attribute not fetched directly? - String currentKm = km.getAttributeNS(uri, "km"); - try { - return Double.valueOf(currentKm); - } - catch (NumberFormatException nfe) { - return Double.valueOf(-1d); - } - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :