[PATCH] IDs can be assumed to be unique

Wald Commits scm-commit at wald.intevation.org
Thu Aug 28 18:42:24 CEST 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1409244140 -7200
# Node ID a709e6334c4a965aee9582097592206ec79e4efc
# Parent  fe67edde6189b6e68e4dbd2a5f8e296b71a2be2e
IDs can be assumed to be unique.

diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java	Thu Aug 28 15:34:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java	Thu Aug 28 18:42:20 2014 +0200
@@ -120,7 +120,6 @@
                     bedHName = Resources.getMsg(
                         callMeta,
                         "facet.bedheight.sounding_width",
-                        "facet.bedheight.sounding_widt",
                         new Object[] { bedHName });
                     facet = new BedHeightSoundingWidthFacet(facetType, bedHName);
                 }
diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticBedHeightCacheKey.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticBedHeightCacheKey.java	Thu Aug 28 15:34:57 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.artifacts.model;
-
-import java.io.Serializable;
-
-public class StaticBedHeightCacheKey implements Serializable {
-    public static final String CACHE_NAME = "bedheight-value-table-static";
-
-    private int time;
-    private int height_id;
-
-    public StaticBedHeightCacheKey(int column, int wst_id) {
-        this.height_id  = wst_id;
-        this.time  = column;
-    }
-
-    public int hashCode() {
-        return (height_id << 8) | time;
-    }
-
-    public boolean equals(Object other) {
-        if (!(other instanceof StaticBedHeightCacheKey)) {
-            return false;
-        }
-        StaticBedHeightCacheKey o = (StaticBedHeightCacheKey) other;
-        return this.height_id == o.height_id && this.time == o.time;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticSedimentLoadCacheKey.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticSedimentLoadCacheKey.java	Thu Aug 28 15:34:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticSedimentLoadCacheKey.java	Thu Aug 28 18:42:20 2014 +0200
@@ -48,7 +48,7 @@
 
     @Override
     public boolean equals(Object other) {
-        if (!(other instanceof StaticBedHeightCacheKey)) {
+        if (!(other instanceof StaticSedimentLoadCacheKey)) {
             return false;
         }
         StaticSedimentLoadCacheKey o = (StaticSedimentLoadCacheKey) other;
diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Thu Aug 28 15:34:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Thu Aug 28 18:42:20 2014 +0200
@@ -65,8 +65,8 @@
     /** Get two BedHeights from factory. */
     private static BedHeightData [] getHeightPair(int [] ids, String type) {
         return new BedHeightData [] {
-            BedHeightFactory.getHeight(type, ids[0], 0),
-            BedHeightFactory.getHeight(type, ids[1], 0)
+            BedHeightFactory.getHeight(type, ids[0]),
+            BedHeightFactory.getHeight(type, ids[1])
         };
     }
 
diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java	Thu Aug 28 15:34:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java	Thu Aug 28 18:42:20 2014 +0200
@@ -77,8 +77,7 @@
              * @return {@link BedHeight} */
             BedHeightData data = BedHeightFactory.getHeight(
                 access.getType(),
-                access.getHeightId(),
-                access.getTime());
+                access.getHeightId());
             //data.removeNaNs();
             TDoubleArrayList stations= data.getStations();
             double[][] values = new double[2][stations.size()];
diff -r fe67edde6189 -r a709e6334c4a artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java	Thu Aug 28 15:34:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java	Thu Aug 28 18:42:20 2014 +0200
@@ -51,14 +51,13 @@
     /**
      * Get BedHeightData for given type and height_id, caring about the cache.
      */
-    public static BedHeightData getHeight(String type, int height_id, int time) {
+    public static BedHeightData getHeight(String type, int height_id) {
         log.debug("BedHeightFactory.getHeight");
-        Cache cache = CacheFactory.getCache(StaticBedHeightCacheKey.CACHE_NAME);
+        Cache cache = CacheFactory.getCache("bedheight-value-table-static");
 
-        StaticBedHeightCacheKey cacheKey;
+        String cacheKey = Integer.toString(height_id);
 
         if (cache != null) {
-            cacheKey = new StaticBedHeightCacheKey(height_id, time);
             Element element = cache.get(cacheKey);
             if (element != null) {
                 log.debug("Got static bedheight values from cache");
@@ -69,7 +68,7 @@
             cacheKey = null;
         }
 
-        BedHeightData values = getBedHeightUncached(type, height_id, time);
+        BedHeightData values = getBedHeightUncached(type, height_id);
 
         if (values != null && cacheKey != null) {
             log.debug("Store static bed height values in cache.");
@@ -111,8 +110,7 @@
      */
     public static BedHeightData getBedHeightUncached(
         String type,
-        int height_id,
-        int time)
+        int height_id)
     {
         if (log.isDebugEnabled()) {
             log.debug("BedHeightFactory.getBedHeightUncached");


More information about the Dive4Elements-commits mailing list