# HG changeset patch # User Ingo Weinzierl # Date 1274200085 0 # Node ID 9981452c7e759a37dd722a4f54b18ecf1ec5a988 # Parent da4306683186ab614862d06390664701e4f0ca6a First step: Added a new state handling the selection between vector or scalar and a new transition in timeseries to provide vector values (issue27). gnv-artifacts/trunk@1110 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue May 18 16:28:05 2010 +0000 @@ -1,3 +1,28 @@ +2010-05-18 Ingo Weinzierl + + Issue27 - First step to provide vector values. + + * doc/conf/products/timeseries/conf_timeseriespoint.xml: Added a further + step to choose between vector or scalar values. + + TODO: Configure the parameterization path for working with vector values. + + * src/main/java/de/intevation/gnv/state/SwitchModeState.java: A new state + that allows users to choose between scalar or vector values. + + * src/main/java/de/intevation/gnv/state/StateBase.java, + src/main/java/de/intevation/gnv/state/MeasurementState.java, + src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java, + src/main/java/de/intevation/gnv/state/SingleInputState.java: Adjusted + method signature of getDescriptionForInputData(.) - added the CallContext + as further parameter that is necessary to retrieve the current locale. + + * src/main/resources/lang/artifactMessages.properties, + src/main/resources/lang/artifactMessages_de_DE.properties, + src/main/resources/lang/artifactMessages_en.properties, + src/main/resources/lang/artifactMessages_de.properties: Added labels for + the user interface. + 2010-05-18 Tim Englich * doc/conf/queries.properties: diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml --- a/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml Tue May 18 16:28:05 2010 +0000 @@ -144,7 +144,7 @@ - + @@ -158,12 +158,35 @@ - + - + + + vectorscalar + false + + + + + + + + + + + + + + + + + + + + timeseries_parameter parameterid diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java Tue May 18 16:28:05 2010 +0000 @@ -1,5 +1,7 @@ package de.intevation.gnv.state; +import de.intevation.artifacts.CallContext; + import de.intevation.gnv.geobackend.base.Result; import java.util.ArrayList; @@ -34,7 +36,8 @@ @Override - protected String[] getDescriptionForInputData(InputData data, String uuid) { + protected String[] getDescriptionForInputData( + InputData data, CallContext context, String uuid) { return new String[0]; } } diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java Tue May 18 16:28:05 2010 +0000 @@ -398,7 +398,8 @@ tupel[1]); if (name.equals(dataName)) { - String[] desc = getDescriptionForInputData(extended, uuid); + String[] desc = getDescriptionForInputData( + extended, context, uuid); extended.setDescription(desc); } diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java Tue May 18 16:28:05 2010 +0000 @@ -101,7 +101,7 @@ tmpItem.getValue(), inputValue.getType()); if (valid) { - String[] desc = getDescriptionForInputData(tmpItem, uuid); + String[] desc = getDescriptionForInputData(tmpItem, context, uuid); tmpItem.setDescription(desc); this.inputData.put(tmpItem.getName(), tmpItem); diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Tue May 18 16:28:05 2010 +0000 @@ -253,7 +253,8 @@ if (valid) { if (tmpItem.getName().equals(this.dataName)){ - String[] desc = getDescriptionForInputData(tmpItem, uuid); + String[] desc = getDescriptionForInputData( + tmpItem, context, uuid); tmpItem.setDescription(desc); } this.inputData.put(tmpItem.getName(), tmpItem); @@ -301,7 +302,9 @@ } - protected String[] getDescriptionForInputData(InputData data, String uuid) { + protected String[] getDescriptionForInputData( + InputData data, CallContext context, String uuid) + { // there is only one element in the list, so take the first Object obj = getDescibeData(uuid).get(0); List descs = new ArrayList(); diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/java/de/intevation/gnv/state/SwitchModeState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/SwitchModeState.java Tue May 18 16:28:05 2010 +0000 @@ -0,0 +1,128 @@ +package de.intevation.gnv.state; + +import de.intevation.artifactdatabase.XMLUtils; + +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.PreferredLocale; + +import de.intevation.gnv.artifacts.ressource.RessourceFactory; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + + +/** + * This task of this State implementation is to switch between + * working with vector or scalar data. + * + * @author Ingo Weinzierl + */ +public class SwitchModeState extends StateBase { + + public static final String VECTOR_VALUE = "vector"; + public static final String SCALAR_VALUE = "scalar"; + + public static final String RESSOURCE_VECTOR = "vectorvalues"; + public static final String RESSOURCE_SCALAR = "scalarvalues"; + + private static Logger logger = Logger.getLogger(SwitchModeState.class); + + public SwitchModeState() { + } + + + @Override + protected void describeDynamic( + XMLUtils.ElementCreator artCreator, + XMLUtils.ElementCreator creator, + Document document, + Node dynamic, + CallContext context, + String uuid) + { + RessourceFactory ressource = RessourceFactory.getInstance(); + CallMeta callMeta = context.getMeta(); + PreferredLocale[] locales = callMeta.getLanguages(); + + Element selectNode = creator.create("select1"); + creator.addAttr(selectNode, "ref", dataName); + + Element labelNode = creator.create("label"); + labelNode.setTextContent(ressource.getRessource( + locales, dataName, dataName)); + selectNode.appendChild(labelNode); + + selectNode.appendChild(createChoices(creator, context)); + dynamic.appendChild(selectNode); + logger.debug("creating dynamic ui elements finished"); + } + + + protected Node createChoices( + XMLUtils.ElementCreator creator, + CallContext context) + { + RessourceFactory ressource = RessourceFactory.getInstance(); + CallMeta callMeta = context.getMeta(); + PreferredLocale[] locales = callMeta.getLanguages(); + + Element choiceNodes = creator.create("choices"); + + // add choice for scalar values + logger.debug("create choice for scalar values"); + Element scalar = creator.create("item"); + Element label = creator.create("label"); + label.setTextContent(ressource.getRessource( + locales, RESSOURCE_SCALAR, RESSOURCE_SCALAR)); + scalar.appendChild(label); + + Element value = creator.create("value"); + value.setTextContent(SCALAR_VALUE); + scalar.appendChild(value); + + // add choice for vector values + logger.debug("create choice for vector values"); + Element vector = creator.create("item"); + label = creator.create("label"); + label.setTextContent(ressource.getRessource( + locales, RESSOURCE_VECTOR, RESSOURCE_VECTOR)); + vector.appendChild(label); + + value = creator.create("value"); + value.setTextContent(VECTOR_VALUE); + vector.appendChild(value); + + choiceNodes.appendChild(scalar); + choiceNodes.appendChild(vector); + + return choiceNodes; + } + + + @Override + protected String[] getDescriptionForInputData( + InputData data, CallContext context, String uuid) + { + RessourceFactory ressource = RessourceFactory.getInstance(); + CallMeta callMeta = context.getMeta(); + PreferredLocale[] locales = callMeta.getLanguages(); + + String value = data.getValue(); + + if (value != null && value.equals(SCALAR_VALUE)) { + return new String[] { ressource.getRessource( + locales, RESSOURCE_SCALAR, RESSOURCE_SCALAR) }; + } + else if (value != null && value.equals(VECTOR_VALUE)) { + return new String[] { ressource.getRessource( + locales, RESSOURCE_VECTOR, RESSOURCE_VECTOR) }; + } + + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/resources/lang/artifactMessages.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Tue May 18 16:28:05 2010 +0000 @@ -62,6 +62,9 @@ coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0E {3}'' coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}'' coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}'' +vectorscalar = Vector / Scalar values +vectorvalues = Vector values +scalarvalues = scalar values chart.timeseries.date.format=yyyy-MMM-dd chart.timeseries.title.xaxis=Time [UTC] diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Tue May 18 16:28:05 2010 +0000 @@ -62,6 +62,9 @@ coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0O {3}'' coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}'' coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}'' +vectorscalar = Vektorielle / Skalare Werte +vectorvalues = Vektorielle Werte +scalarvalues = Skalare Werte chart.timeseries.date.format=dd-MMM-yyyy chart.timeseries.title.xaxis=Zeit [UTC] diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Tue May 18 16:28:05 2010 +0000 @@ -62,6 +62,9 @@ coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0O {3}'' coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}'' coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}'' +vectorscalar = Vektorielle / Skalare Werte +vectorvalues = Vektorielle Werte +scalarvalues = Skalare Werte chart.timeseries.date.format=dd-MMM-yyyy chart.timeseries.title.xaxis=Zeit [UTC] diff -r da4306683186 -r 9981452c7e75 gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Tue May 18 14:27:46 2010 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Tue May 18 16:28:05 2010 +0000 @@ -62,6 +62,9 @@ coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0E {3}'' coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}'' coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}'' +vectorscalar = Vector / Scalar values +vectorvalues = Vector values +scalarvalues = scalar values chart.timeseries.date.format=yyyy-MMM-dd