# HG changeset patch # User Ingo Weinzierl # Date 1302874671 0 # Node ID 8f40a57229c3e0b203071dc511a37438deebbcca # Parent 4aa078e28cfdea49c4d3ceed64460e461ba4d4bf FLYSArtifact provides methods to retrieve the real River, Gauge objects. flys-artifacts/trunk@1704 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4aa078e28cfd -r 8f40a57229c3 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Apr 15 10:10:37 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Apr 15 13:37:51 2011 +0000 @@ -1,3 +1,9 @@ +2011-04-15 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Now + provides some methods that return some basic objects inserted while + parameterization: River, Gauge and so on. + 2011-04-15 Ingo Weinzierl * src/main/java/de/intevation/flys/artifacts/services/DistanceInfoService.java, diff -r 4aa078e28cfd -r 8f40a57229c3 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Apr 15 10:10:37 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Apr 15 13:37:51 2011 +0000 @@ -28,7 +28,11 @@ import de.intevation.artifactdatabase.state.StateEngine; import de.intevation.artifactdatabase.transition.TransitionEngine; +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.River; + import de.intevation.flys.artifacts.context.FLYSContext; +import de.intevation.flys.artifacts.model.RiverFactory; /** @@ -433,5 +437,60 @@ return false; } + + + /** + * Returns the selected River object based on the 'river' data that might + * have been inserted by the user. + * + * @return the selected River or null if no river has been chosen yet. + */ + public River getRiver() { + StateData dRiver = getData("river"); + + return dRiver != null + ? RiverFactory.getRiver((String) dRiver.getValue()) + : null; + } + + + /** + * Returns the selected distance of points. + * + * @return the selected distance or points. + */ + public double[] getDistance() { + StateData dFrom = getData("ld_from"); + StateData dTo = getData("ld_to"); + + double from = Double.parseDouble((String) dFrom.getValue()); + double to = Double.parseDouble((String) dTo.getValue()); + + // TODO take point selection into account + + return new double[] { from, to }; + } + + + /** + * Returns the gauge based on the current distance and river. + * + * @return the gauge. + */ + public Gauge getGauge() { + River river = getRiver(); + double[] dist = getDistance(); + + if (logger.isDebugEnabled()) { + logger.debug("Determine gauge for:"); + logger.debug("... river: " + river.getName()); + logger.debug("... distance: " + dist[0] + " - " + dist[1]); + } + + List gauges = river.getGauges(); + + // TODO Search the desired gauge! + return gauges.get(0); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :