# HG changeset patch # User Ingo Weinzierl # Date 1270113336 0 # Node ID a5526908f92f591436b3641d437621585fa02e09 # Parent cdade5005cba9052cc122a9cec572aa2ec09a835 Added javadoc in state package. gnv-artifacts/trunk@878 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/layer/LayerArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/layer/LayerArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/layer/LayerArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -34,9 +34,11 @@ /** - * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, - * de.intevation.artifacts.ArtifactFactory, java.lang.Object - * org.w3c.dom.Document) + * + * @param identifier + * @param factory + * @param context + * @param data */ @Override public void setup(String identifier, ArtifactFactory factory, diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontalcrosssection/HorizontalCrossSectionMeshArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontalcrosssection/HorizontalCrossSectionMeshArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontalcrosssection/HorizontalCrossSectionMeshArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -47,6 +47,12 @@ } + /** + * This method is called just before an artifact is exported. It removes all + * data which should not serialized into an export. + * + * @param context CallContext object. + */ @Override public void cleanup(Object context) { if (current != null) @@ -55,3 +61,4 @@ super.cleanup(context); } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -45,3 +45,4 @@ super.setup(identifier, factory, context, data); } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileInstantaneousPointArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileInstantaneousPointArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileInstantaneousPointArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -28,3 +28,4 @@ super.name = super.name + "InstantaneousPoint"; } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileMeshArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileMeshArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileMeshArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -27,3 +27,4 @@ super.name = super.name + "Mesh"; } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/profile/verticalcrosssection/VerticalCrossSectionMeshArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/verticalcrosssection/VerticalCrossSectionMeshArtifact.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/verticalcrosssection/VerticalCrossSectionMeshArtifact.java Thu Apr 01 09:15:36 2010 +0000 @@ -46,3 +46,4 @@ super.setup(identifier, factory, context, data); } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/AutoResumeState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/AutoResumeState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/AutoResumeState.java Thu Apr 01 09:15:36 2010 +0000 @@ -2,12 +2,13 @@ /** * - * Markerinterface for States which should be used for - * automatically Resume and jump to the next State using - * the Conditions of the Transitions which are linked to it. + * Markerinterface for states which should be used for + * automatically resume and jump to the next State using + * the conditions of the transitions which are linked to it. + * * @author Tim Englich - * */ public interface AutoResumeState extends State{ } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java Thu Apr 01 09:15:36 2010 +0000 @@ -30,6 +30,9 @@ import org.w3c.dom.NodeList; /** + * This state handles coordinate input by the user. It searches database results + * for coordinates and turns them into a human readable form. + * * @author Tim Englich * */ @@ -80,7 +83,8 @@ } /** - * @see de.intevation.gnv.state.StateBase#prepareInputData4RegionDBQuery(java.lang.String) + * @param value + * @return */ @Override protected String prepareInputData4RegionDBQuery(String value) { @@ -88,7 +92,8 @@ double distance=0.; String returnValue = null; try { - Point center = new InputValidator().getPointValue(value); + @SuppressWarnings("static-access") + Point center = InputValidator.getPointValue(value); String meshId = super.inputData.get("meshid").getValue(); int segments = 97; if (meshWidths != null){ @@ -113,7 +118,8 @@ } /** - * @see de.intevation.gnv.state.StateBase#extractKVP(java.util.Collection, java.lang.String, java.lang.String) + * @param valueid + * @param keyid */ @Override protected NamedCollection extractKVP( @@ -129,7 +135,8 @@ Result resultValue = rit.next(); String key = resultValue.getString(keyid); if(prevKey == null || !prevKey.equals(key)){ // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers - String geomString = this.convert2DisplayCoordinate(resultValue.getString(valueid)); + @SuppressWarnings("static-access") + String geomString = CoordinateSelectionState.convert2DisplayCoordinate(resultValue.getString(valueid)); String value = geomString; if (resultValue.getResultDescriptor().getColumnIndex("VALUE") > 0){ value = resultValue.getString("VALUE") + " - "+value; @@ -143,12 +150,18 @@ return keyValueDescibeData; } + /** + * Turn coordinate into a human readable format. + * + * @param wkt Coordinate as wkt string. + * @return formatted coordinate. + */ protected static String convert2DisplayCoordinate(String wkt){ return WKTUtils.toText(wkt); } /** - * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) + * @param configuration */ @Override public void setup(Node configuration) { @@ -174,3 +187,4 @@ } } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java Thu Apr 01 09:15:36 2010 +0000 @@ -8,13 +8,12 @@ /** + * Default implementation of AutoResumeState. + * * @author Tim Englich - * */ -public class DefaultAutoResumeState extends StateBase implements AutoResumeState { - - - +public class DefaultAutoResumeState extends StateBase implements AutoResumeState +{ /** * The UID of this Class. */ @@ -27,18 +26,28 @@ super(); } + /** - * @see de.intevation.gnv.state.StateBase#purifyResult(java.util.Collection, java.lang.String) + * + * @param result + * @param uuid + * @return */ @Override protected List purifyResult(Collection result, String uuid) { return new ArrayList(0); } + + /** + * + * @param data + * @param uuid + * @return + */ @Override protected String[] getDescriptionForInputData(InputData data, String uuid) { return new String[0]; } - - } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultExportMode.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultExportMode.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultExportMode.java Thu Apr 01 09:15:36 2010 +0000 @@ -1,31 +1,63 @@ package de.intevation.gnv.state; /** + * This is the default implementation of ExportMode. + * * @author Ingo Weinzierl */ public class DefaultExportMode implements ExportMode { + /** + * The name of the export (e.g. pdf, svg, image). + */ protected String name; + + /** + * A description for this export. + */ protected String description; + + /** + * The mimetype used to do execute this export. + */ protected String mimeType; + /** + * Constructor. + * + * @param name + * @param description + * @param mimeType + */ public DefaultExportMode(String name, String description, String mimeType){ this.name = name; this.description = description; this.mimeType = mimeType; } + /** + * + * @return + */ public String getName() { return name; } + /** + * + * @return + */ public String getDescription() { return description; } + /** + * + * @return + */ public String getMimeType() { return mimeType; } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java Thu Apr 01 09:15:36 2010 +0000 @@ -6,6 +6,9 @@ import org.apache.log4j.Logger; /** + * The default implementation of InputData. This object stores + * multiple values separated by {@link #VALUE_SEPARATOR} for a specific key. + * * @author Tim Englich * @author Ingo Weinzierl */ @@ -18,27 +21,59 @@ private static final Logger logger = Logger.getLogger(DefaultInputData.class); + /** + * The character used to separate the different values. + */ public final static String VALUE_SEPARATOR = " , "; + /** + * The key/name of this object. + */ protected String name; + + /** + * Values separated by {@link #VALUE_SEPARATOR}. + */ protected String value; + + /** + * Descriptions for values used for user interface creation. Each value + * should have an own description in this map. + */ protected Map description; + + /** + * An extra object. Might be everything. + */ protected Object object; /** * Constructor + * @param name + * @param value */ public DefaultInputData(String name, String value) { this.name = name; this.value = value; } + /** + * + * @param name + * @param object + */ public DefaultInputData(String name, Object object) { this.name = name; this.object = object; } + /** + * + * @param name + * @param value + * @param object + */ public DefaultInputData( String name, String value, @@ -50,27 +85,40 @@ } /** - * @see de.intevation.gnv.state.InputData#getName() + * @return */ public String getName() { return this.name; } /** - * @see de.intevation.gnv.state.InputData#getValue() + * @return */ public String getValue() { return this.value; } + /** + * + * @param object + */ public void setObject(Object object) { this.object = object; } + /** + * + * @return + */ public Object getObject() { return object; } + /** + * + * @param key Key needs to be a single value of {@link #value}. + * @return the description. + */ public String getDescription(String key) { if (description == null) return null; @@ -78,6 +126,11 @@ return (String) description.get(key); } + /** + * Return all descriptions as array. + * + * @return descriptions as array. + */ public String[] getDescription() { String[] values = splitValue(); int length = values.length; @@ -90,6 +143,10 @@ return description; } + /** + * + * @param description + */ public void setDescription(String[] description) { if (this.description == null) this.description = new HashMap(); @@ -110,7 +167,7 @@ } /** - * @see java.lang.Object#toString() + * @return */ @Override public String toString() { @@ -118,14 +175,14 @@ } /** - * @see de.intevation.gnv.state.InputData#concartValue(java.lang.String) + * @param value */ public void concartValue(String value) { this.value = this.value + VALUE_SEPARATOR + value; } /** - * @see de.intevation.gnv.state.InputData#splitValue() + * @return */ public String[] splitValue() { if (this.value != null){ @@ -135,3 +192,4 @@ } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputValue.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputValue.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputValue.java Thu Apr 01 09:15:36 2010 +0000 @@ -1,8 +1,10 @@ package de.intevation.gnv.state; /** + * The default implementation of InputValue. InputValue objects are + * used to store meta information about InputData objects. + * * @author Tim Englich - * */ public class DefaultInputValue implements InputValue { @@ -16,6 +18,13 @@ private int usedInQueries = 1; private String defaultValue = "N/N"; + /** + * + * @param name + * @param type + * @param defaultValue + * @param multiselect + */ public DefaultInputValue(String name, String type, String defaultValue, boolean multiselect) { this(name, type, multiselect, 1); @@ -25,6 +34,10 @@ /** * Constructor + * @param name + * @param type + * @param multiselect + * @param usedInQueries */ public DefaultInputValue(String name, String type, boolean multiselect, int usedInQueries) { @@ -35,21 +48,23 @@ } /** - * @see de.intevation.gnv.state.InputValue#getName() + * @return */ public String getName() { return this.name; } /** - * @see de.intevation.gnv.state.InputValue#getType() + * @return */ public String getType() { return this.type; } /** - * @see java.lang.Object#toString() + * Returns the information as string. + * + * @return information as string. */ @Override public String toString() { @@ -58,18 +73,27 @@ } /** - * @see de.intevation.gnv.state.InputValue#isMultiselect() + * @return */ public boolean isMultiselect() { return this.multiselect; } + /** + * + * @return + */ public int usedInQueries() { return this.usedInQueries; } + /** + * + * @return + */ public String getDefaultValue() { return this.defaultValue; } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java Thu Apr 01 09:15:36 2010 +0000 @@ -4,6 +4,8 @@ import java.util.List; /** + * The default implementation of OutputMode. + * * @author Tim Englich * @author Ingo Weinzierl */ @@ -22,9 +24,11 @@ /** * Constructor * - * @param name - * @param description - * @param mimeType + * @param name The name of the output mode. + * @param description The description of this output mode. + * @param mimeType The mime type used by this output mode. + * @param inputParameters The input parameters required by this output mode. + * @param exportModes The export modes for this output mode. */ public DefaultOutputMode( String name, @@ -42,28 +46,28 @@ } /** - * @see de.intevation.gnv.state.OutputMode#getDescription() + * @return the description. */ public String getDescription() { return this.description; } /** - * @see de.intevation.gnv.state.OutputMode#getMimeType() + * @return the mime type. */ public String getMimeType() { return this.mimeType; } /** - * @see de.intevation.gnv.state.OutputMode#getName() + * @return the name. */ public String getName() { return this.name; } /** - * @see java.lang.Object#toString() + * @return this output mode as string. */ @Override public String toString() { @@ -72,15 +76,19 @@ } /** - * @see de.intevation.gnv.state.OutputMode#getInputParameters() + * @return the input parameters. */ public Collection getInputParameters() { return this.inputParameters; } + /** + * + * @return the export modes. + */ public List getExportModes() { return exportModes; } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultState.java Thu Apr 01 09:15:36 2010 +0000 @@ -1,6 +1,8 @@ package de.intevation.gnv.state; /** + * This is the default implementation of StateBase. + * * @author Tim Englich * */ @@ -18,3 +20,4 @@ } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/ExportMode.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/ExportMode.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/ExportMode.java Thu Apr 01 09:15:36 2010 +0000 @@ -3,13 +3,32 @@ import java.io.Serializable; /** + * This interface defines basic methods which are necessary for exports. + * * @author Ingo Weinzierl */ public interface ExportMode extends Serializable { + /** + * Return the export name (e.g. pdf, svg, image). + * + * @return the export name. + */ public String getName(); + + /** + * Return the description for this export. + * + * @return the export description. + */ public String getDescription(); + + /** + * Returns the mime type used by this export. + * + * @return export's mimetype. + */ public String getMimeType(); } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/ExtendedInputData.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/ExtendedInputData.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/ExtendedInputData.java Thu Apr 01 09:15:36 2010 +0000 @@ -1,14 +1,32 @@ package de.intevation.gnv.state; /** + * This class is used to save the relation between two attributes. Mainly used + * to save the relation between a measurement and the parameter it belongs to. + * + * @see MeasurementState * @author Ingo Weinzierl */ public class ExtendedInputData extends DefaultInputData { + /** + * The separater used to separate measurement ids and parameter ids. + */ public static final String SEPARATOR = ";"; + /** + * The parameter this object belongs to. + */ protected String parameterid; + /** + * Constructcor. + * + * @param name + * @param value + * @param object + * @param parameterid + */ public ExtendedInputData( String name, String value, @@ -19,14 +37,29 @@ this.parameterid = parameterid; } + /** + * Return the parameter ids this object belongs to. + * + * @return the parameter id. + */ public String getParameterID() { return parameterid; } + /** + * Set the parameter ids. + * + * @param parameterid Parameter ids. + */ public void setParameter(String parameterid) { this.parameterid = parameterid; } + /** + * Return all parameter ids as array. + * + * @return Array of parameter ids. + */ public String[] splitParameter() { if (parameterid != null) return parameterid.split(SEPARATOR); diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java Thu Apr 01 09:15:36 2010 +0000 @@ -3,26 +3,78 @@ import java.io.Serializable; /** + * This interface defines the basic methods used to store multiple values with + * a specific key and name. + * * @author Tim Englich * */ public interface InputData extends Serializable { + /** + * Method to Retrieve the name of this input data item. + * + * @return the name + */ public String getName(); + /** + * Method to retrieve the value of this input data item. A value might be a + * list of values separated by a specific character. + * + * @return the value + */ public String getValue(); + /** + * Method to store a further object at this input data item. + * + * @param o A further object. + */ public void setObject(Object o); + /** + * Method to retrieve the extra object. + * + * @return the extra object. + */ public Object getObject(); + /** + * Method to store descriptions for this input data item. + * + * @param description Array of descriptions. + */ public void setDescription(String[] description); + /** + * Method to retrieve a description specified by a given key. + * + * @param key Key. + * @return the description for this key. + */ public String getDescription(String key); + /** + * Method to retrieve all descriptions of this input data item. + * + * @return descriptions. + */ public String[] getDescription(); + /** + * Append a further string value to the value field devided by a separater + * character. + * + * @param value Value to append. + */ public void concartValue(String value); + /** + * Method to retrieve the character separated values split into an array. + * + * @return + */ String[] splitValue(); } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/InputValue.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputValue.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputValue.java Thu Apr 01 09:15:36 2010 +0000 @@ -3,19 +3,48 @@ import java.io.Serializable; /** + * This interface defines some basic methods to retrieve information about the + * type of an user input. + * * @author Tim Englich * */ public interface InputValue extends Serializable { + /** + * Retrieve the name of the inserted data. + * + * @return the input data name. + */ public String getName(); + /** + * Retrieve the type of the input. + * + * @return the input data type. + */ public String getType(); + /** + * Retrieve the default value used when no input is done. + * + * @return the input data default value. + */ public String getDefaultValue(); + /** + * Retrieve information about mutliselect fields. + * + * @return true, if the input data is a multiselect, otherwise false. + */ public boolean isMultiselect(); + /** + * Retrieve information about the occurance of this input in an sql + * statement. + * + * @return the number of times, this data is used in a sql query. + */ public int usedInQueries(); - } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java Thu Apr 01 09:15:36 2010 +0000 @@ -34,6 +34,12 @@ import org.w3c.dom.Node; /** + * This state handles input of measurements relating to a parameter. The user + * interface description created by this class represents a matrix - each + * parameter in a single row, each measurement in a column. An invalid + * measurement column for a specific parameter is marked as disabled and should + * not be selected. + * * @author Ingo Weinzierl */ public class MeasurementState @@ -41,11 +47,24 @@ { private static Logger logger = Logger.getLogger(MeasurementState.class); + /** + * + */ public static final String SQL_KEY_PARAMETERID = "PARAMETERID"; + /** + * + */ public static final String SEPARATOR = ";"; + /** + * This class is used to generate the Matrix in MinMaxDateState. + * Parameter and Measurements are stored in separate lists and can be + * requested via different methods. + * + * @author Ingo Weinzierl + */ private class ParameterMatrix { private final Logger logger = Logger.getLogger(ParameterMatrix.class); @@ -55,6 +74,12 @@ private List parameters; private boolean[][] values; + /** + * Constructs a new matrix. + * + * @param data A collection containing the measurements. + * @param parameter An array of parameters. + */ public ParameterMatrix(Collection data, String[] parameter) { measurements = new ArrayList(data.size()); mDescriptions = new ArrayList(data.size()); @@ -69,6 +94,11 @@ initMeasurements(data); } + /** + * Initialize the measurements used in this matrix. + * + * @param data The measurements. + */ private void initMeasurements(Collection data) { Iterator iter = data.iterator(); while (iter.hasNext()) { @@ -103,12 +133,22 @@ } } + /** + * Initialize the parameters used in this matrix. + * + * @param parameter Parameters. + */ private void initParameters(String[] parameter) { for (String param: parameter) { parameters.add(param); } } + /** + * Returns the number of measurements. + * + * @return the number of measurements. + */ public int measurementSize() { if (measurements != null) return measurements.size(); @@ -116,6 +156,11 @@ return 0; } + /** + * Returns the number of parameters. + * + * @return number of parameters. + */ public int parameterSize() { if (parameters != null) return parameters.size(); @@ -123,6 +168,12 @@ return 0; } + /** + * Returns the measurement at idx. + * + * @param idx Index. + * @return the measurement. + */ public String getMeasurement(int idx) { if (idx >= 0 && idx < measurements.size()) return (String) measurements.get(idx); @@ -131,6 +182,12 @@ return ""; } + /** + * Returns the parameter at idx. + * + * @param idx Index + * @return the parameter. + */ public String getParameter(int idx) { if (idx >= 0 && idx < parameters.size()) { return (String) parameters.get(idx); @@ -140,6 +197,12 @@ return ""; } + /** + * Returns a description text for a specific measurement. + * + * @param idx Index of a measurement. + * @return measurement's description. + */ public String getMDescription(int idx) { if (mDescriptions != null) { return (String) mDescriptions.get(idx); @@ -148,6 +211,14 @@ return null; } + /** + * This method returns true, if a measurement is valid for a specific + * parameter - otherwise false. + * + * @param i Index of a measurement column. + * @param j Index of a parameter row. + * @return true, if valid, else false. + */ public boolean isValid(int i, int j) { if (i < 0 || i > measurements.size() || j < 0 || j > parameters.size()) @@ -161,6 +232,9 @@ } // End of ParameterMatrix + /** + * + */ public MeasurementState() { super(); } @@ -200,6 +274,18 @@ } + /** + * This method create the user interface description for measurement and + * parameters as matrix. A row for each parameter, a column for each + * measurement. + * + * @param artCreator + * @param creator + * @param document + * @param dynamicNode + * @param callMeta + * @param o + */ @Override protected void appendToDynamicNode( XMLUtils.ElementCreator artCreator, @@ -266,6 +352,17 @@ } + /** + * This feed takes some input data storing measurement ids and parameter ids + * and put them into ExtendedInputData objects to save the relation between + * a measurement and the parameter it belongs to. + * + * @param context + * @param input + * @param uuid + * @return + * @throws StateException + */ @Override public Document feed( CallContext context, @@ -334,6 +431,15 @@ } + /** + * Extract parameter ids and measurement ids from DefaultInputData objects + * and return an array. In the first position of this array, the measurement + * ids are placed, in the second position the parameter ids - all separated + * by a character. + * + * @param tmp String containing measurement ids and parameter ids. + * @return An array with separated measurements and parameters. + */ protected String[] extractValuesAndParams(String tmp) { String[] array = tmp.split(DefaultInputData.VALUE_SEPARATOR); @@ -363,4 +469,4 @@ return extracted; } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxDateState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxDateState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxDateState.java Thu Apr 01 09:15:36 2010 +0000 @@ -25,36 +25,58 @@ import org.w3c.dom.Document; /** + * This state handles date input. The resulting describe document of this state + * contains two fields in the user interface description to define a time range. + * * @author Ingo Weinzierl */ public class MinMaxDateState extends MinMaxState { + /** + * + */ public static final String EXCEPTION_DATE_REQUIRED = "input.is.not.valid.date.required"; + /** + * + */ public static final String EXCEPTION_START_AFTER_END = "start.date.after.end.date"; + /** + * + */ public static final String EXCEPTION_DATE_OUT_OF_RANGE = "date.out.of.range"; + /** + * + */ public static final String EXCEPTION_MISSING_DATE = "missing.data.field"; private static Logger logger = Logger.getLogger(MinMaxDateState.class); + /** + * + */ public MinMaxDateState() { super(); } /** - * @see de.intevation.gnv.state.StateBase#feed(java.util.Collection, - * java.lang.String) + * This feed method needs a collection of two InputData objects. These + * objects' values need to be a datetime string which is turned into a Date + * object. Afterwards, the given dates are validated. Min and max date need + * to be in range of the min and max date retrieved by + * {@link #getDescibeData(java.lang.String)}. */ @Override + @SuppressWarnings({"static-access", "static-access", "static-access"}) public Document feed( CallContext context, Collection inputData, @@ -71,7 +93,6 @@ return feedFailure(msg); } - InputValidator iv = new InputValidator(); Iterator iter = inputData.iterator(); MinMaxDescribeData data = @@ -95,7 +116,7 @@ return feedFailure(msg); } - if (!iv.isInputValid(value, type)) { + if (!InputValidator.isInputValid(value, type)) { String msg = resFactory.getRessource( locale, EXCEPTION_DATE_REQUIRED, EXCEPTION_DATE_REQUIRED); logger.error(msg); @@ -134,7 +155,7 @@ logger.debug("Upper date bound: " + upper.toString()); } - if (!iv.isDateValid(d, lower, upper)) { + if (!InputValidator.isDateValid(d, lower, upper)) { String msg = resFactory.getRessource( locale, EXCEPTION_DATE_OUT_OF_RANGE, @@ -153,7 +174,7 @@ } if (tmpMin != null && tmpMax != null) { - if (!iv.isInputValid((String) tmpMin, (String) tmpMax, type)) { + if (!InputValidator.isInputValid((String) tmpMin, (String) tmpMax, type)) { String msg = resFactory.getRessource( locale, EXCEPTION_START_AFTER_END, @@ -172,4 +193,4 @@ return feedSuccess(); } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxState.java Thu Apr 01 09:15:36 2010 +0000 @@ -33,6 +33,10 @@ import org.w3c.dom.Node; /** + * This state handles input of a min and max value and validates the user input. + * The min value needs to be equal or smaller than the max value, otherwise the + * input results in an error. + * * @author Tim Englich * @author Ingo Weinzierl */ @@ -51,8 +55,13 @@ } /** - * @see de.intevation.gnv.state.StateBase#purifyResult(java.util.Collection, - * java.lang.String) + * The objects returned by the database are searched for two fields with + * 'MIN' and 'MAX' as names. These objects are stored and used to be + * displayed in the gui to give the user an orientation of the range he is + * able to insert. + * + * @param uuid + * @return */ @Override protected List purifyResult( @@ -77,10 +86,14 @@ /** - * @see de.intevation.gnv.state.StateBase#feed(java.util.Collection, - * java.lang.String) + * @param context + * @param uuid + * @param inputData + * @return + * @throws StateException */ @Override + @SuppressWarnings("static-access") public Document feed( CallContext context, Collection inputData, @@ -113,7 +126,8 @@ return feedFailure(msg); } - boolean valid = iv.isInputValid(value, type); + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(value, type); if (!valid) { String msg = "Input is not valid for this state."; log.error(msg); @@ -129,7 +143,7 @@ } if (min != null && max != null) { - if (!iv.isInputValid((String) min, (String) max, type)) { + if (!InputValidator.isInputValid((String) min, (String) max, type)) { String msg = "Input is not valid for this state."; log.error(msg); return feedFailure(msg); @@ -148,6 +162,14 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param staticNode + * @param callMeta + */ @Override protected void appendToStaticNode( XMLUtils.ElementCreator artCreator, @@ -220,4 +242,4 @@ staticNode.appendChild(groupNode); } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java Thu Apr 01 09:15:36 2010 +0000 @@ -6,18 +6,49 @@ import java.util.List; /** + * This is the interface description of an OutputMode. The + * methods defined here retrieve some basic information for an output. An output + * can be chart, histogram, statistic, csv, odv and so on. + * * @author Tim Englich - * + * @author Ingo Weinzierl */ public interface OutputMode extends Serializable { + /** + * Retrieve the name of this output mode. + * + * @return the name of this output mode. + */ public String getName(); + /** + * Retrieve the description of an output. + * + * @return the description. + */ public String getDescription(); + /** + * Retrieve the mimetype used for the output. + * + * @return the mimetype. + */ public String getMimeType(); + /** + * Retrieve a list of optional InputValue objects the user is able to + * adjust. + * + * @return optional input parameters. + */ public Collection getInputParameters(); + /** + * Retrieve a list of export modes this output can be exported to. + * + * @return some export modes. + */ public List getExportModes(); } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputState.java Thu Apr 01 09:15:36 2010 +0000 @@ -11,8 +11,14 @@ import org.w3c.dom.Document; /** + * This is the interface description of an output state. Currently, there are + * two methods defined:
+ *
    + *
  1. out(): To start an output of the current state.
  2. + *
  3. getOutputModes(): To retrieve a list of possible output modes.
  4. + *
+ * * @author Tim Englich - * */ public interface OutputState extends State @@ -21,9 +27,11 @@ /** * Returns the Rendered Result of an State. * - * @param outputMode - * The Mode that should be produces (Chart, Map, ...) - * @return The Bytecode of the Result + * @param format + * @param inputData + * @param outputStream + * @param uuid + * @param callContext * @throws StateException */ public void out( @@ -41,3 +49,4 @@ */ public Collection getOutputModes(); } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java Thu Apr 01 09:15:36 2010 +0000 @@ -44,6 +44,10 @@ import org.w3c.dom.NodeList; /** + * This is the default implementation of OutputState. Artifacts + * having reached this state or a subclass of this state are able to produce + * some output (e.g. chart, histograms, statistic, etc). + * * @author Tim Englich * @author Ingo Weinzierl * @@ -52,15 +56,27 @@ extends StateBase implements OutputState { + /** + * + */ public static final String XPATH_OUTPUT_MODE = "/art:action/art:out/@name"; + /** + * + */ public static final String XPATH_EXPORT_MODE = "/art:action/art:out/art:export/@name"; + /** + * + */ public static final String XPATH_MIME_TYPE = "/art:action/art:out/art:mime-type/@value"; + /** + * + */ public static final String XPATH_EXPORTS = "exportModes/export"; @@ -79,6 +95,9 @@ */ protected Collection outputModes = null; + /** + * + */ protected String queryODVID = null; /** @@ -89,7 +108,8 @@ } /** - * @see de.intevation.gnv.state.OutputState#getOutputModes() + * + * @return */ public Collection getOutputModes() { log.debug("OutputStateBase.getOutputModes"); @@ -97,7 +117,7 @@ } /** - * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) + * @param configuration */ @Override public void setup(Node configuration) { @@ -166,7 +186,9 @@ } /** - * @see de.intevation.gnv.state.StateBase#advance() + * @param uuid + * @param context + * @throws StateException */ @Override public void advance(String uuid, CallContext context) @@ -174,12 +196,29 @@ { } + /** + * + * @param uuid + * @param context + * @throws StateException + */ @Override public void initialize(String uuid, CallContext context) throws StateException { } + /** + * This method needs to be defined by concrete subclasses. Nothing is done + * here. + * + * @param format + * @param inputData + * @param outputStream + * @param uuid + * @param callMeta + * @throws StateException + */ public void out( Document format, Collection inputData, @@ -192,6 +231,13 @@ } /** + * This method needs to be defined by concrete subclasses. Nothing is done + * here. + * + * @param outputMode + * @param inputData + * @param outputStream + * @throws StateException * @see de.intevation.gnv.state.OutputState#out(java.lang.String, * java.util.Collection, java.io.OutputStream) */ @@ -200,7 +246,15 @@ } /** - * @return + * Returns the data used to create charts. If a cache is configured, try to + * fetch the data from cache. The database is queried if the data is not in + * cache yet, or if no cache is configured. If the cache is configured, but + * the data is not in cache yet, put it into cache for a faster access + * in a later time. + * + * @param uuid The uuid of an artifact. + * @param callContext The CallContext. + * @return the chart data. */ protected Object getChartResult(String uuid, CallContext callContext) { log.debug("OutputStateBase.getChartResult"); @@ -233,6 +287,16 @@ } } + /** + * This method should no longer be used, because it is not good to put a + * chart into cache. Parameter changes done by the user wouldn't be detected + * proper. + * + * @param uuid + * @param callContext + * @return + * @deprecated + */ protected Object getChartFromCache(String uuid, CallContext callContext) { log.debug("Fetch chart [" + uuid + "] from cache"); CacheFactory cacheFactory = CacheFactory.getInstance(); @@ -247,6 +311,12 @@ return null; } + /** + * Retrieves the data used to create an ODV export. + * + * @param uuid + * @return odv data. + */ protected Collection getODVResult(String uuid) { log.debug("OutputStateBase.getODVResult"); // TODO add Caching? I think it's not nessessary @@ -260,8 +330,10 @@ } /** - * @param returnValue - * @return + * Retrieve data from database with help of queryID. + * + * @param queryID A query id defined in sql statements properties file. + * @return some data. */ protected Collection getData(String queryID) { log.debug("OutputStateBase.getData"); @@ -282,6 +354,11 @@ return returnValue; } + /** + * This method removes the data used for creating charts from cache. + * + * @param uuid + */ protected void removeChartResult(String uuid) { log.debug("OutputStateBase.getChartResult"); if (CacheFactory.getInstance().isInitialized()) { @@ -294,6 +371,12 @@ } } + /** + * This method should no longer be used. It removes a chart from cache. + * + * @param uuid + * @deprecated + */ protected void removeChart(String uuid) { log.debug("OutputStateBase.removeChart from cache"); @@ -306,6 +389,12 @@ } } + /** + * This is an internal method used while database query. + * + * @param chart + * @param uuid + */ protected void purifyChart(Object chart, String uuid) { log.debug("Prufify chart [" + uuid + "]"); CacheFactory cacheFactory = CacheFactory.getInstance(); @@ -316,6 +405,15 @@ } + /** + * Use this method to feed a state with new data. + * + * @param context + * @param inputData + * @param uuid + * @return + * @throws StateException + */ @Override public Document feed( CallContext context, @@ -329,9 +427,17 @@ } /** - * @see de.intevation.gnv.state.StateBase#putInputData(java.util.Collection, java.lang.String) + * This method is used to put new data into a next state. The difference + * between this method and feed is, that this method should be used to + * transfer some old input data required by this state. New data need to be + * inserted via feed! + * + * @param inputData + * @param uuid + * @throws StateException */ @Override + @SuppressWarnings({"static-access", "static-access", "static-access", "static-access"}) public void putInputData(Collection inputData, String uuid) throws StateException { @@ -352,13 +458,14 @@ inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { if (tmpItem.getName().equals(MINVALUEFIELDNAME)){ String minValue = tmpItem.getValue(); String maxValue = getInputValue4ID(inputData, MAXVALUEFIELDNAME); - valid = iv.isInputValid(maxValue,inputValue.getType()); + valid = InputValidator.isInputValid(maxValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -367,7 +474,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -378,7 +485,7 @@ }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){ String minValue = getInputValue4ID(inputData, MINVALUEFIELDNAME); String maxValue = tmpItem.getValue(); - valid = iv.isInputValid(minValue,inputValue.getType()); + valid = InputValidator.isInputValid(minValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -387,7 +494,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -428,12 +535,32 @@ } } - public void out(String outputMode, Collection inputData, - OutputStream outputStream, String uuid, CallMeta callMeta) - throws StateException { - } + /** + * + * @param outputMode + * @param inputData + * @param outputStream + * @param uuid + * @param callMeta + * @throws StateException + */ + public void out( + String outputMode, + Collection inputData, + OutputStream outputStream, + String uuid, + CallMeta callMeta) + throws StateException { } + /** + * Retrieves a message from resource bundle specified by locale. + * + * @param locale Locale to use. + * @param key The key of the message. + * @param value The default value. + * @return The value. + */ protected String getMessage(Locale locale, String key, String value) { return RessourceFactory.getInstance().getRessource( locale, @@ -442,4 +569,4 @@ ); } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferCoordinateSelectionState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferCoordinateSelectionState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferCoordinateSelectionState.java Thu Apr 01 09:15:36 2010 +0000 @@ -14,8 +14,9 @@ import org.w3c.dom.Node; /** + * This method looks for former inserted coordinates before initialization. + * * @author Tim Englich - * */ public class PreSettingsTransferCoordinateSelectionState extends CoordinateSelectionState { @@ -35,8 +36,13 @@ super(); } + /** - * @see de.intevation.gnv.state.StateBase#initialize(java.lang.String, de.intevation.artifacts.CallContext) + * Lookup mechanism for former inserted data before intialization begins. + * + * @param uuid + * @param context + * @throws StateException */ @Override public void initialize(String uuid, CallContext context) @@ -55,8 +61,10 @@ super.initialize(uuid, context); } + /** - * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) + * + * @param configuration */ @Override public void setup(Node configuration) { @@ -69,7 +77,5 @@ } super.setup(configuration); } - - - } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/PreSettingsTransferState.java Thu Apr 01 09:15:36 2010 +0000 @@ -14,8 +14,11 @@ import org.w3c.dom.Node; /** + * This special state does a lookup for already inserted data while + * initializing. If there are some data for this state, take them for further + * work. + * * @author Tim Englich - * */ public class PreSettingsTransferState extends DefaultState { @@ -34,8 +37,14 @@ super(); } + /** - * @see de.intevation.gnv.state.StateBase#initialize(java.lang.String, de.intevation.artifacts.CallContext) + * This method does a lookup for already inserted data before initializing + * it. + * + * @param uuid + * @param context + * @throws StateException */ @Override public void initialize(String uuid, CallContext context) @@ -54,8 +63,10 @@ super.initialize(uuid, context); } + /** - * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) + * + * @param configuration */ @Override public void setup(Node configuration) { @@ -68,7 +79,5 @@ } super.setup(configuration); } - - - } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java Thu Apr 01 09:15:36 2010 +0000 @@ -11,6 +11,9 @@ import org.apache.log4j.Logger; /** + * This state handles single user input. The user is allowed to select just one + * value. + * * @author Tim Englich * */ @@ -32,9 +35,11 @@ public SingleInputState() { } - /** - * @see de.intevation.gnv.state.StateBase#purifyResult(java.util.Collection, - * java.lang.String) + /**s + * + * @param result + * @param uuid + * @return */ @Override protected List purifyResult(Collection result, String uuid) { @@ -54,5 +59,5 @@ return describeData; } - } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/State.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/State.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/State.java Thu Apr 01 09:15:36 2010 +0000 @@ -13,18 +13,45 @@ import org.w3c.dom.Node; /** + * This interface describes the basic method a concrete state class needs to + * implement. + * * @author Tim Englich * @author Ingo Weinzierl * @author Sascha L. Teichmann */ public interface State extends Serializable { + /** + * Setup the state. + * + * @param configuration State configuration. + */ public void setup(Node configuration); + /** + * Return the id of the state. + * + * @return the id. + */ public String getID(); + /** + * Return the description of the state. + * + * @return the description of the state. + */ public String getDescription(); + /** + * This method is called when an artifacts retrieves a describe request. It + * creates the user interface description of the current state. + * + * @param document Describe doucment. + * @param rootNode Parent node for all new xml elements. + * @param context The CallContext. + * @param uuid The uuid of an artifact. + */ public void describe( Document document, Node rootNode, @@ -32,36 +59,124 @@ String uuid ); + /** + * This method is used to insert new data into this state. Concrete + * subclasses should valide the input before saving it. + * + * @param context The CallContext. + * @param inputData New InputData items. + * @param uuid The uuid of an artifact. + * @return a document with an error or sucess message. + * @throws StateException + */ public Document feed( CallContext context, Collection inputData, String uuid) throws StateException; + /** + * Set the previous state. + * + * @param state The previous state. + */ public void setParent(State state); + /** + * Returns the previous state. + * + * @return the previous state. + */ public State getParent(); + /** + * Retrieve a collection of required input values. + * + * @return required input values. + */ public Collection getRequiredInputValues(); + /** + * Retrieves a map with InputData items. + * + * @return a map with InputData items. + */ public Map inputData(); + /** + * Use this method to feed a state with some data. + * + * @param inputData InputData collection. + * @param uuid UUID of an artifact. + * @throws StateException + */ public void putInputData(Collection inputData, String uuid) throws StateException; + /** + * Retrieves a collection with the InputData stored in this state. + * + * @return An InputData collection. + * @throws StateException + */ public Collection getInputData() throws StateException; + /** + * This method is called to advance to a next or previous state. + * + * @param uuid The uuid of an artifact. + * @param context The CallContext object. + * @throws StateException + */ public void advance(String uuid, CallContext context) throws StateException; + /** + * This method is called when the state is created. + * + * @param uuid The uuid of an artifact. + * @param context The CallContext object. + * @throws StateException + */ public void initialize(String uuid, CallContext context) throws StateException; + /** + * This method can be used to reset the state. + * + * @param uuid The uuid of an artifact. + */ public void reset(String uuid); + /** + * This method is called when the lifetime of an artifact ends or if the + * user decides to step back to a previous state. + * + * @param globalContext The CallContext. + */ public void endOfLife(Object globalContext); + /** + * This method is used to put some InputData objects into an artifact before + * the parameterization begins. + * + * @param preSettings + */ public void setPreSettings(Map preSettings); + /** + * This method retrieves a map with InputData objects which have been + * inserted into this state before the parameterization has started. The key + * used to store the objects is the name of the state. + * + * @return map with InputData objects. + */ public Map getPreSettings(); + /** + * Method to remove the data stored at a state which should not be + * serialized while an artifact is exported. + * + * @param context The CallContext + */ public void cleanup(Object context); } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Thu Apr 01 09:15:36 2010 +0000 @@ -55,6 +55,9 @@ import org.w3c.dom.NodeList; /** + * This is the major implementation of State. Nearly every other + * state is derived by this class. + * * @author Tim Englich * @author Ingo Weinzierl * @author Sascha L. Teichmann @@ -71,17 +74,38 @@ */ private static Logger log = Logger.getLogger(StateBase.class); + /** + * + */ protected final static String MINVALUEFIELDNAME = "minvalue"; + /** + * + */ protected final static String MAXVALUEFIELDNAME = "maxvalue"; private final static String NODATASELECTIONKEY = "n/n"; + /** + * + */ public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; + /** + * + */ public final static String XPATH_STATIC_UI = "art:static"; + /** + * + */ public final static String XPATH_DYNAMIC_UI = "art:dynamic"; + /** + * + */ public static final String EXCEPTION_NO_INPUT = "no.input.data"; + /** + * + */ public static final String EXCEPTION_INVALID_INPUT = "input.is.not.valid"; @@ -90,28 +114,61 @@ private String id = null; + /** + * + */ protected String hash; private String description = null; + /** + * + */ protected String dataName = null; + /** + * + */ protected String preSettingsName = null; + /** + * + */ protected boolean dataMultiSelect = false; + /** + * + */ protected boolean dataNoSelect = false; + /** + * + */ protected String queryID = null; + /** + * + */ protected Collection inputValueNames = null; + /** + * + */ protected Map inputValues = null; + /** + * + */ protected State parent = null; + /** + * + */ protected Map inputData = null; + /** + * + */ protected Map preSettings = null; /** @@ -122,14 +179,14 @@ } /** - * @see de.intevation.gnv.state.State#getID() + * @return */ public String getID() { return this.id; } /** - * @see de.intevation.gnv.state.State#getDescription() + * @return */ public String getDescription() { return this.description; @@ -138,19 +195,24 @@ /** - * @see de.intevation.gnv.state.State#getRequiredInputValues() + * @return */ public Collection getRequiredInputValues() { return this.inputValues.values(); } + /** + * + * @param uuid + */ public void reset(String uuid) { inputData.remove(dataName); } /** + * @param configuration * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node) */ public void setup(Node configuration) { @@ -207,6 +269,7 @@ } /** + * @return * @see de.intevation.gnv.state.State#getParent() */ public State getParent() { @@ -214,6 +277,7 @@ } /** + * @param state * @see de.intevation.gnv.state.State#setParent(de.intevation.gnv.state.State) */ public void setParent(State state) { @@ -221,6 +285,14 @@ } + /** + * + * @param context + * @param inputData + * @param uuid + * @return + * @throws StateException + */ public Document feed( CallContext context, Collection inputData, @@ -244,7 +316,8 @@ inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { @@ -285,18 +358,33 @@ } + /** + * + * @return + */ protected Document feedSuccess() { return ArtifactXMLUtilities.createSuccessReport( "Initialize success", XMLUtils.newDocument()); } + /** + * + * @param msg + * @return + */ protected Document feedFailure(String msg) { return ArtifactXMLUtilities.createInputExceptionReport( msg, XMLUtils.newDocument()); } + /** + * + * @param data + * @param uuid + * @return + */ protected String[] getDescriptionForInputData(InputData data, String uuid) { // there is only one element in the list, so take the first Object obj = getDescibeData(uuid).get(0); @@ -336,8 +424,12 @@ /** + * @param inputData + * @param uuid + * @throws StateException * @see de.intevation.gnv.state.State#putInputData(java.util.Collection) */ + @SuppressWarnings({"static-access", "static-access", "static-access", "static-access"}) public void putInputData(Collection inputData, String uuid) throws StateException { if (inputData != null) { @@ -352,13 +444,14 @@ inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), + @SuppressWarnings("static-access") + boolean valid = InputValidator.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { if (tmpItem.getName().equals(MINVALUEFIELDNAME)){ String minValue = tmpItem.getValue(); String maxValue = this.getInputValue4ID(inputData, MAXVALUEFIELDNAME); - valid = iv.isInputValid(maxValue,inputValue.getType()); + valid = InputValidator.isInputValid(maxValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -367,7 +460,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -378,7 +471,7 @@ }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){ String minValue = this.getInputValue4ID(inputData, MINVALUEFIELDNAME); String maxValue = tmpItem.getValue(); - valid = iv.isInputValid(minValue,inputValue.getType()); + valid = InputValidator.isInputValid(minValue,inputValue.getType()); if (!valid){ String errMsg = "Wrong input for " + tmpItem.getValue() + " is not an " + inputValue.getType() @@ -387,7 +480,7 @@ throw new StateException(errMsg); } - valid = iv.isInputValid(minValue, + valid = InputValidator.isInputValid(minValue, maxValue, inputValue.getType()); if (!valid){ @@ -422,6 +515,7 @@ /** * + * @param preSettings * @see de.intevation.gnv.state.State#setPreSettings(java.util.Map) */ public void setPreSettings(Map preSettings) { @@ -430,10 +524,20 @@ + /** + * + * @return + */ public Map getPreSettings() { return this.preSettings; } + /** + * + * @param inputData + * @param inputName + * @return + */ protected String getInputValue4ID(Collection inputData, String inputName){ Iterator it = inputData.iterator(); while (it.hasNext()) { @@ -447,6 +551,9 @@ /** + * @param uuid + * @param context + * @throws StateException * @see de.intevation.gnv.state.State#advance(java.lang.String, * de.intevation.artifacts.CallMeta) */ @@ -455,6 +562,12 @@ { } + /** + * + * @param uuid + * @param context + * @throws StateException + */ public void initialize(String uuid, CallContext context) throws StateException { @@ -495,6 +608,11 @@ return filterValues; } + /** + * + * @param value + * @return + */ protected String prepareInputData4RegionDBQuery(String value){ return value; } @@ -536,6 +654,8 @@ /** * @param result + * @param uuid + * @return */ protected List purifyResult(Collection result, String uuid) { List describeData = new ArrayList(); @@ -550,6 +670,8 @@ /** * @param result + * @param keyid + * @param valueid * @return */ protected NamedCollection extractKVP(Collection result, @@ -614,6 +736,11 @@ } + /** + * + * @param key + * @return + */ public static boolean inBlackList(String key) { int length = BLACKLIST.length; for (int i = 0; i < length; i++) { @@ -626,6 +753,10 @@ } /** + * @param document + * @param rootNode + * @param context + * @param uuid * @see de.intevation.gnv.state.State#describe(org.w3c.dom.Document, * org.w3c.dom.Node, de.intevation.artifacts.CallMeta, * java.lang.String) @@ -675,6 +806,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param dynamic + * @param context + * @param uuid + */ protected void describeDynamic( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -703,6 +843,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param staticNode + * @param context + * @param uuid + */ protected void describeStatic( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -722,6 +871,14 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param staticNode + * @param callMeta + */ protected void appendToStaticNode( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -775,6 +932,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param dynamicNode + * @param callMeta + * @param o + */ protected void appendToDynamicNode( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -848,6 +1014,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param node + * @param callMeta + * @param o + */ protected void appendMinMaxDescribeData( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -914,6 +1089,15 @@ } + /** + * + * @param artCreator + * @param creator + * @param document + * @param node + * @param callMeta + * @param o + */ protected void appendSingleValueDescribeData( XMLUtils.ElementCreator artCreator, XMLUtils.ElementCreator creator, @@ -953,17 +1137,27 @@ } + /** + * + * @param uuid + */ protected void setHash(String uuid) { this.hash = uuid + id + inputData.hashCode(); } + /** + * + * @return + */ protected String getHash() { return this.hash; } /** + * @param uuid + * @return * @see de.intevation.gnv.state.State#getDescibeData() */ public List getDescibeData(String uuid) { @@ -1016,6 +1210,13 @@ return null; } + /** + * + * @param filterValues + * @param uuid + * @return + * @throws QueryException + */ protected List queryDatabase(String[] filterValues, String uuid) throws QueryException { Collection result = null; @@ -1030,17 +1231,28 @@ } + /** + * + * @return + */ public Map inputData() { return inputData; } /** + * @return + * @throws StateException * @see de.intevation.gnv.state.State#getInputData() */ public Collection getInputData() throws StateException { return this.inputData != null ? this.inputData.values() : null; } + /** + * + * @param name + * @return + */ public InputData getInputDataByName(String name) { State state = this; @@ -1056,11 +1268,19 @@ return null; } + /** + * + * @param globalContext + */ public void endOfLife(Object globalContext) { } + /** + * + * @param context + */ public void cleanup(Object context) { } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file diff -r cdade5005cba -r a5526908f92f gnv-artifacts/src/main/java/de/intevation/gnv/state/StateFactory.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateFactory.java Wed Mar 31 13:48:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateFactory.java Thu Apr 01 09:15:36 2010 +0000 @@ -7,6 +7,9 @@ import org.w3c.dom.Node; /** + * This factory should be used to create new state objects with help of a + * configuration segment. + * * @author Tim Englich * */ @@ -26,6 +29,11 @@ super(); } + /** + * Return the instance of this class. + * + * @return + */ public static StateFactory getInstance() { if (instance == null) { instance = new StateFactory(); @@ -33,6 +41,13 @@ return instance; } + /** + * This method creates a new state with help of the information in + * configuration and calls its setup method after creation. + * + * @param configuration + * @return the new state. + */ public State createState(Node configuration) { log.debug("StateFactory.createState"); State state = null; @@ -51,3 +66,4 @@ } } +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file