Mercurial > dive4elements > river
changeset 3777:048a02e29808
Added base class RiverAccess to dense code to access the river name.
flys-artifacts/trunk@5484 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 16 Sep 2012 18:42:20 +0000 (2012-09-16) |
parents | 1ddbf66a2b0a |
children | 35a6c9a49a76 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/ExtremeAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FlowVelocityAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RiverAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java |
diffstat | 8 files changed, 91 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Sep 16 18:42:20 2012 +0000 @@ -1,3 +1,39 @@ +2012-09-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java: + Please _DO NOT_ use FLYSUtils in new code based on Access*! + Now the river name is fetch via access.getRiver(). + + * src/main/java/de/intevation/flys/artifacts/access/RiverAccess.java: + New. Almost all calculations need accessing the river name. + + * src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java, + src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java, + src/main/java/de/intevation/flys/artifacts/access/FixAccess.java, + src/main/java/de/intevation/flys/artifacts/access/FlowVelocityAccess.java, + src/main/java/de/intevation/flys/artifacts/access/ExtremeAccess.java: + Now extend RiverAccess. + +2012-09-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/access/ExtremeAccess.java: + Implemented the access methods needed for + "Auslagerung extremer Wasserspiegellagen". + + * src/main/java/de/intevation/flys/artifacts/model/Segment.java: + Move segment parsing to DoubleUtil to be usable with more data types. + The wire protocol should be the same for: + - "WINFO: W fuer ungleichwertige Abfluesse", + - "WINFO: Auslagerung extremer Wasserspiegellagen" + - "Fixierungsanalyse: Auslagerung von Wasserspiegellagen" + + * src/main/java/de/intevation/flys/utils/DoubleUtil.java: + Now contains the the code to parse segments. Found segments + are propagated back with a callback. + + * src/main/java/de/intevation/flys/artifacts/model/RangeWithValues.java: + Added toString() method. + 2012-09-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -10,14 +10,13 @@ import de.intevation.flys.artifacts.model.DateRange; -public class BedQualityAccess extends Access { +public class BedQualityAccess extends RiverAccess { private static final Logger logger = Logger .getLogger(BedQualityAccess.class); private Double from; private Double to; - private String river; private List<String> bedDiameter; private List<String> bedloadDiameter; private List<DateRange> ranges; @@ -40,13 +39,6 @@ return to.doubleValue(); } - public String getRiver() { - if (river == null) { - river = getString("river"); - } - return river; - } - public List<DateRange> getDateRanges() { if (ranges == null) { ranges = extractRanges(getString("periods")); @@ -100,4 +92,4 @@ return result; } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/ExtremeAccess.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/ExtremeAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -12,12 +12,10 @@ import org.apache.log4j.Logger; public class ExtremeAccess -extends Access +extends RiverAccess { private static Logger log = Logger.getLogger(ExtremeAccess.class); - protected String river; - protected Double from; protected Double to; protected Double step; @@ -38,16 +36,6 @@ super(artifact); } - public String getRiver() { - if (river == null) { - river = getString("river"); - } - if (log.isDebugEnabled()) { - log.debug("river: '" + river + "'"); - } - return river; - } - public Double getFrom() { if (from == null) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAccess.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -7,12 +7,10 @@ import org.apache.log4j.Logger; public class FixAccess -extends Access +extends RiverAccess { private static Logger log = Logger.getLogger(FixAccess.class); - protected String river; - protected Double from; protected Double to; protected Double step; @@ -36,16 +34,6 @@ super(artifact); } - public String getRiver() { - if (river == null) { - river = getString("river"); - } - if (log.isDebugEnabled()) { - log.debug("river: '" + river + "'"); - } - return river; - } - public Double getFrom() { if (from == null) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FlowVelocityAccess.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FlowVelocityAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -3,7 +3,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; -public class FlowVelocityAccess extends Access { +public class FlowVelocityAccess extends RiverAccess { private int[] mainChannels; private int[] totalChannels;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/RiverAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -0,0 +1,31 @@ +package de.intevation.flys.artifacts.access; + +import de.intevation.flys.artifacts.FLYSArtifact; + +import org.apache.log4j.Logger; + +public class RiverAccess +extends Access +{ + private static Logger log = Logger.getLogger(RiverAccess.class); + + protected String river; + + public RiverAccess() { + } + + public RiverAccess(FLYSArtifact artifact) { + super(artifact); + } + + public String getRiver() { + if (river == null) { + river = getString("river"); + } + if (log.isDebugEnabled()) { + log.debug("river: '" + river + "'"); + } + return river; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java Sun Sep 16 18:42:20 2012 +0000 @@ -8,12 +8,10 @@ import de.intevation.flys.artifacts.model.DateRange; public class SQRelationAccess -extends Access +extends RiverAccess { private static Logger log = Logger.getLogger(SQRelationAccess.class); - protected String river; - protected Double location; protected DateRange period; @@ -27,16 +25,6 @@ super(artifact); } - public String getRiver() { - if (river == null) { - river = getString("river"); - } - if (log.isDebugEnabled()) { - log.debug("river: '" + river + "'"); - } - return river; - } - public Double getLocation() { if (location == null) { // XXX: The parameter name suggests plural!?
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java Sun Sep 16 17:55:10 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java Sun Sep 16 18:42:20 2012 +0000 @@ -1,18 +1,21 @@ package de.intevation.flys.artifacts.model; import java.util.ArrayList; +import java.util.Collections; import java.util.List; -import org.apache.log4j.Logger; +import de.intevation.artifacts.Artifact; -import de.intevation.artifacts.Artifact; +import de.intevation.flys.artifacts.access.FlowVelocityAccess; + +import de.intevation.flys.artifacts.model.RiverFactory; + import de.intevation.flys.model.DischargeZone; import de.intevation.flys.model.FlowVelocityModel; import de.intevation.flys.model.FlowVelocityModelValue; import de.intevation.flys.model.River; -import de.intevation.flys.artifacts.access.FlowVelocityAccess; -import de.intevation.flys.utils.FLYSUtils; +import org.apache.log4j.Logger; public class FlowVelocityCalculation extends Calculation { @@ -80,7 +83,17 @@ FlowVelocityAccess access, List<DischargeZone> zones ) { - River river = FLYSUtils.getRiver(access.getArtifact()); + String riverName = access.getRiver(); + if (riverName == null) { + logger.warn("No river name found"); + return Collections.<FlowVelocityModel>emptyList(); + } + + River river = RiverFactory.getRiver(riverName); + if (river == null) { + logger.warn("No such river: " + riverName); + return Collections.<FlowVelocityModel>emptyList(); + } List<FlowVelocityModel> models = new ArrayList<FlowVelocityModel>();