changeset 3602:e1fd2dfdcb80

Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed flys-artifacts/trunk@5228 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Wed, 22 Aug 2012 10:18:00 +0000 (2012-08-22)
parents 6c94153cc4a4
children d2ae58f6730d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties
diffstat 5 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Aug 20 08:34:05 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 22 10:18:00 2012 +0000
@@ -1,3 +1,14 @@
+2012-08-22	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java,
+	  src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  Fix NullPointerExceptions in cross section diagrams that occurred when
+	  no HYKs are available for the selected kms.
+
+	* src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_de.properties:
+	  Typo, see issue #806
+
 2012-08-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/fixings/FixATExport.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java	Mon Aug 20 08:34:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java	Wed Aug 22 10:18:00 2012 +0000
@@ -1,20 +1,17 @@
 package de.intevation.flys.artifacts.model;
 
+import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.DataProvider;
+import de.intevation.flys.artifacts.HYKArtifact;
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import de.intevation.flys.model.FastCrossSectionLine;
+
 import java.util.List;
 
 import org.apache.log4j.Logger;
 
-import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.CallContext;
-import de.intevation.artifacts.DataProvider;
-
-import de.intevation.artifactdatabase.state.Facet;
-
-import de.intevation.flys.artifacts.HYKArtifact;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-import de.intevation.flys.model.FastCrossSectionLine;
-
 
 /**
  * Trival Facet for HYKs
@@ -39,7 +36,8 @@
      * @param art artifact to get data from.
      * @param context ignored
      */
-     public Object getData(Artifact art, CallContext context) {
+     @Override
+    public Object getData(Artifact art, CallContext context) {
         logger.debug("HYKFacet.getData");
 
         String dataKey = CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA;
@@ -53,6 +51,11 @@
         FastCrossSectionLine crossSection = (FastCrossSectionLine) providers.get(0)
             .provideData(dataKey, null, context);
 
+        if(crossSection == null) {
+            logger.debug("getData: crossSection is null");
+            return null;
+        }
+
         double km = crossSection.getKm();
         logger.debug("HYKFacet.getData: Master Cross Section is at km: " + km);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Mon Aug 20 08:34:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed Aug 22 10:18:00 2012 +0000
@@ -116,7 +116,7 @@
             FastCrossSectionLine csl = (FastCrossSectionLine) providers.get(0).
                 provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA,
                     null, context);
-            km = csl.getKm();
+            km = csl == null ? -1 : csl.getKm();
         }
 
         Object[] args = new Object[] {
--- a/flys-artifacts/src/main/resources/messages_de.properties	Mon Aug 20 08:34:05 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Wed Aug 22 10:18:00 2012 +0000
@@ -95,7 +95,7 @@
 main.channel = Hauptgerinne
 total.channel = Gesamtgerinne
 
-chart.cross_section.title = Querprofildiagram f\u00fcr Gew\u00e4sser {0}
+chart.cross_section.title = Querprofildiagramm f\u00fcr Gew\u00e4sser {0}
 chart.cross_section.subtitle = {0}-km: {1,number,#.###}
 chart.cross_section.xaxis.label = Abstand [m]
 chart.cross_section.yaxis.label = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Mon Aug 20 08:34:05 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Aug 22 10:18:00 2012 +0000
@@ -95,7 +95,7 @@
 main.channel = Hauptgerinne
 total.channel = Gesamtgerinne
 
-chart.cross_section.title = Querprofildiagram f\u00fcr Gew\u00e4sser {0}
+chart.cross_section.title = Querprofildiagramm f\u00fcr Gew\u00e4sser {0}
 chart.cross_section.subtitle = {0}-km: {1,number,#.###}
 chart.cross_section.xaxis.label = Abstand [m]
 chart.cross_section.yaxis.label = W [NN + m]

http://dive4elements.wald.intevation.org