changeset 8615:054d1b57ae4a

(issue1755) Clarify how default mecahnism works and remove unused config value.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 25 Mar 2015 11:41:36 +0100
parents e7a2234e7c3f
children 594b0bbc7011
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java
diffstat 1 files changed, 12 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java	Wed Mar 25 11:25:28 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java	Wed Mar 25 11:41:36 2015 +0100
@@ -48,11 +48,6 @@
     private static Logger log = Logger.getLogger(DefaultState.class);
 
 
-    /** Determines, if the DESCRIBE document should contain default values or
-     * not. */
-    public static final boolean USE_DEFAULTS =
-        Boolean.getBoolean("flys.use.default.values");
-
     /** The three possible compute types. */
     public static enum ComputeType {
         FEED, ADVANCE, INIT
@@ -207,30 +202,23 @@
 
 
     /**
-     * This method returns the default value and description for <i>data</i>.
-     * Note, that this method returns the defaults only if <i>USE_DEFAULTS</i>
-     * is set; otherwise, null is returned.
+     * This method returns the default value and label for <i>data</i>.
+     *
+     * Override this method in a subclass to set an appropiate default
+     * value.
+     * The default label can be ignored by the client (e.g. the gwt-client).
+     * but shall not be null.
+     *
+     * Example implementation:
+     *  if (data != null && data.getName().equals("the_answer")) {
+     *       return new String[] {"42", "the_answer"};
+     *   }
+     *
      * @param context The CallContext used for i18n.
      * @param data The data objects that the defaults are for.
      * @return a String[] with [default value, default label].
      */
     protected String[] getDefaultsFor(CallContext context, StateData data) {
-        if (USE_DEFAULTS) {
-            String defValue = (String) data.getValue();
-            String defDesc  = null;
-
-            if (defValue != null && defValue.length() > 0) {
-                defDesc = Resources.getMsg(
-                    context.getMeta(),
-                    defValue,
-                    defValue);
-            }
-
-            if (defValue != null && defDesc != null) {
-                return new String[] { defValue, defDesc };
-            }
-        }
-
         return null;
     }
 

http://dive4elements.wald.intevation.org