changeset 1729:2e5ebdeb8af9

Give StaticWKmsArtifacts proper names, and pre-deselect them. flys-artifacts/trunk@3013 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 18 Oct 2011 15:00:43 +0000
parents 6068b6c90a19
children 4a245ad0ac17
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java
diffstat 3 files changed, 64 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 18 14:25:50 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Oct 18 15:00:43 2011 +0000
@@ -1,3 +1,15 @@
+2011-10-18  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Give StaticWKmsArtifacts proper names, and pre-deselect them.
+
+	* src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java:
+	  (getInitialFacetActivity): Overridden to let facets enter plot
+	  inactively.
+	  (setup): Give Facets the name of the Wst.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java:
+	  Refactored to expose getWKmsName separately.
+
 2011-10-18  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Adjusted Datacage-Configuration to fetch flood-protections when
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Oct 18 14:25:50 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Oct 18 15:00:43 2011 +0000
@@ -92,21 +92,28 @@
 
             if (parts.length >= 4) {
                 try {
-                    Integer.valueOf(parts[2]);
-                    Integer.valueOf(parts[3]);
+                    int col = Integer.valueOf(parts[2]);
+                    int wst = Integer.valueOf(parts[3]);
+
                     addStringData("col_pos", parts[2]);
                     addStringData("wst_id",  parts[3]);
+
+                    String wkmsName = WKmsFactory.getWKmsName(col, wst);
+
+                    Facet facet = new WKmsFacet(
+                        Resources.getMsg(
+                            callMeta,
+                            wkmsName,
+                            wkmsName));
+
+                    fs.add(facet);
+                    facets.put(state.getID(), fs);
+
                 }
                 catch (Exception e) {}
             }
         }
 
-        Facet facet = new WKmsFacet(Resources.getMsg(callMeta,
-                   "facet.discharge_curves.mainvalues.w",
-                   "facet.discharge_curves.mainvalues.w"));
-        fs.add(facet);
-        facets.put(state.getID(), fs);
-
         spawnState();
         super.setup(identifier, factory, context, callMeta, data);
     }
@@ -205,5 +212,21 @@
             Integer.valueOf(getDataAsString("col_pos")),
             Integer.valueOf(getDataAsString("wst_id")));
     }
+
+
+    /**
+     * Determines Facets initial disposition regarding activity (think of
+     * selection in Client ThemeList GUI). This will be checked one time
+     * when the facet enters a collections describe document.
+     *
+     * @param facetName name of the facet.
+     * @param index     index of the facet.
+     *
+     * @return Always 0. Static Data will enter plots inactive.
+     */
+    public int getInitialFacetActivity(String facetName, int index) {
+        return 0;
+    }
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java	Tue Oct 18 14:25:50 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java	Tue Oct 18 15:00:43 2011 +0000
@@ -32,6 +32,7 @@
         "SELECT km, w FROM wst_w_values " +
         "WHERE wst_id = :wst_id AND column_pos = :column_pos";
 
+    /** Query to get name for wst_id and column_pos. */
     public static final String SQL_SELECT_NAME =
         "SELECT name " +
         "FROM wst_columns "+
@@ -74,18 +75,13 @@
     }
 
 
-    /**
-     * Get WKms from db.
-     * @param column the position columns value
-     * @param wst_id database id of the wst
-     * @return according WKms.
-     */
-    public static WKms getWKmsUncached(int column, int wst_id) {
-        log.debug("WKmsFactory.getWKmsUncached c/" + column + ", wst_id/" + wst_id);
+    /** Get name for a WKms. */
+    public static String getWKmsName(int column, int wst_id) {
+        log.debug("WKmsFactory.getWKmsName c/" + column + ", wst_id/" + wst_id);
+
+        String name = null;
         Session session = SessionHolder.HOLDER.get();
 
-        String name = "todo";
-
         SQLQuery nameQuery = session.createSQLQuery(SQL_SELECT_NAME)
             .addScalar("name", StandardBasicTypes.STRING);
         nameQuery.setInteger("wst_id",     wst_id);
@@ -96,8 +92,22 @@
             name = names.get(0);
         }
 
-        WKmsImpl wkms = new WKmsImpl(name);
+        return name;
+    }
 
+
+    /**
+     * Get WKms from db.
+     * @param column the position columns value
+     * @param wst_id database id of the wst
+     * @return according WKms.
+     */
+    public static WKms getWKmsUncached(int column, int wst_id) {
+        log.debug("WKmsFactory.getWKmsUncached c/" + column + ", wst_id/" + wst_id);
+
+        WKmsImpl wkms = new WKmsImpl(getWKmsName(column, wst_id));
+
+        Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS)
             .addScalar("km", StandardBasicTypes.DOUBLE)
             .addScalar("w",  StandardBasicTypes.DOUBLE);

http://dive4elements.wald.intevation.org