diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java @ 2126:d626ae185305

Use the fast cross section lines from backend now. flys-artifacts/trunk@3697 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 17 Jan 2012 17:05:18 +0000
parents dc28ea60b53d
children
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java	Tue Jan 17 09:00:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FastCrossSectionLineFactory.java	Tue Jan 17 17:05:18 2012 +0000
@@ -3,16 +3,21 @@
 import de.intevation.flys.artifacts.cache.CacheFactory;
 
 import de.intevation.flys.model.CrossSection;
-import de.intevation.flys.model.CrossSectionLine;
+
+import de.intevation.flys.model.FastCrossSectionLine;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 
 public class FastCrossSectionLineFactory
 {
+    private static Logger log =
+        Logger.getLogger(FastCrossSectionLineFactory.class);
+
     public static final String CACHE_NAME = "fast-cross-section-lines";
 
     private FastCrossSectionLineFactory() {
@@ -24,11 +29,14 @@
     ) {
         Cache cache = CacheFactory.getCache(CACHE_NAME);
 
+        boolean debug = log.isDebugEnabled();
+
         if (cache == null) {
-            List<CrossSectionLine> lines = cs.getLines(km, km);
-            return lines.isEmpty()
-                ? null
-                : new FastCrossSectionLine(lines.get(0));
+            if (debug) {
+                log.debug("No cross section chunk cache configured.");
+            }
+            List<FastCrossSectionLine> lines = cs.getFastLines(km, km);
+            return lines.isEmpty() ? null : lines.get(0);
         }
 
         String cacheKey = FastCrossSectionChunk.createHashKey(cs, km);
@@ -38,9 +46,18 @@
         FastCrossSectionChunk fcsc;
 
         if (element != null) {
+            if (debug) {
+                log.debug("Found cross section chunk in cache id: " +
+                    cs.getId() + " km: " + km);
+            }
+
             fcsc = (FastCrossSectionChunk)element.getValue();
         }
         else {
+            if (debug) {
+                log.debug("Not found cross section chunk in cache id: " +
+                    cs.getId() + " km: " + km + " -> loading");
+            }
             fcsc = new FastCrossSectionChunk(cs, km);
             element = new Element(cacheKey, fcsc);
             cache.put(element);

http://dive4elements.wald.intevation.org