Mercurial > dive4elements > river
changeset 313:89bd0417418f
The location/distance state now writes default values into DESCRIBE.
flys-artifacts/trunk@1697 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 14 Apr 2011 13:36:06 +0000 |
parents | 0c6328c227f1 |
children | aeeb9054b7cf |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java |
diffstat | 6 files changed, 67 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/ChangeLog Thu Apr 14 13:36:06 2011 +0000 @@ -1,3 +1,17 @@ +2011-04-14 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + Changed some method signatures - added a reference to the owner + Artifact. + + * src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java, + src/main/java/de/intevation/flys/artifacts/states/WQSelect.java, + src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java: + Modified method signatures based on the changes in DefaultState. + + * src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java: + Added default values to the dynamic part of DESCRIBE. + 2011-04-14 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java Thu Apr 14 13:36:06 2011 +0000 @@ -4,6 +4,7 @@ import org.w3c.dom.Element; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; @@ -53,6 +54,7 @@ protected Element[] createItems( XMLUtils.ElementCreator cr, + Artifact artifact, String name, CallContext context) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Thu Apr 14 13:36:06 2011 +0000 @@ -117,7 +117,7 @@ for (StateData data: dataItems) { String name = data.getName(); - Element select = createData(creator, data, context); + Element select = createData(creator, artifact, data, context); Element choices = ProtocolUtils.createArtNode( creator, "choices", null, null); @@ -125,7 +125,7 @@ select.appendChild(choices); ui.appendChild(select); - Element[] items = createItems(creator, name, context); + Element[] items = createItems(creator, artifact, name, context); for (Element item: items) { choices.appendChild(item); } @@ -146,6 +146,7 @@ */ protected Element createData( XMLUtils.ElementCreator cr, + Artifact artifact, StateData data, CallContext context) { @@ -178,6 +179,7 @@ */ protected abstract Element[] createItems( XMLUtils.ElementCreator cr, + Artifact artifact, String name, CallContext context);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Thu Apr 14 13:36:06 2011 +0000 @@ -4,6 +4,7 @@ import org.w3c.dom.Element; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils; @@ -11,6 +12,10 @@ import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.data.StateData; +import de.intevation.flys.model.River; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.resources.Resources; /** @@ -33,6 +38,7 @@ protected Element createData( XMLUtils.ElementCreator cr, + Artifact artifact, StateData data, CallContext context) { @@ -60,17 +66,35 @@ protected Element[] createItems( XMLUtils.ElementCreator cr, + Artifact artifact, String name, CallContext context) { - // TODO Insert correct min/max values! + double[] minmax = getMinMaxDistance(artifact); + + double minVal = Double.MIN_VALUE; + double maxVal = Double.MAX_VALUE; + + if (minmax != null) { + minVal = minmax[0]; + maxVal = minmax[1]; + } + else { + logger.warn("Could not read min/max distance values!"); + } if (name.equals("ld_from")) { - Element min = createItem(cr, new String[] {"min", "1"}); + Element min = createItem( + cr, + new String[] {"min", new Double(minVal).toString()}); + return new Element[] { min }; } else if (name.equals("ld_to")) { - Element max = createItem(cr, new String[] {"max", "10"}); + Element max = createItem( + cr, + new String[] {"max", new Double(maxVal).toString()}); + return new Element[] { max }; } else { @@ -101,5 +125,19 @@ protected String getUIProvider() { return "location_distance_panel"; } + + + protected double[] getMinMaxDistance(Artifact artifact) { + FLYSArtifact flysArtifact = (FLYSArtifact) artifact; + StateData data = flysArtifact.getData("river"); + + String name = (String) data.getValue(); + + logger.debug("Search for the min/max distances of '" + name + "'"); + + River river = RiverFactory.getRiver(name); + + return river != null ? river.determineMinMaxDistance() : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Thu Apr 14 13:36:06 2011 +0000 @@ -7,6 +7,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils; @@ -48,6 +49,7 @@ protected Element createData( XMLUtils.ElementCreator cr, + Artifact artifact, StateData data, CallContext context) { @@ -76,6 +78,7 @@ protected Element[] createItems( XMLUtils.ElementCreator cr, + Artifact artifact, String name, CallContext context) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Thu Apr 14 13:26:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Thu Apr 14 13:36:06 2011 +0000 @@ -4,6 +4,7 @@ import org.w3c.dom.Element; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils; @@ -36,6 +37,7 @@ protected Element createData( XMLUtils.ElementCreator cr, + Artifact artifact, StateData data, CallContext context) { @@ -63,6 +65,7 @@ protected Element[] createItems( XMLUtils.ElementCreator cr, + Artifact artifact, String name, CallContext context) {