changeset 9763:ce7c67445cbb 3.2.x

No more hacks for getting description in case of official lines In case the name contained one and only one number, that number had been returned as description because in that case, the name matched WQ.NUMBERS_PATTERN.
author Tom Gottfried <tom@intevation.de>
date Fri, 11 Nov 2022 18:12:26 +0100
parents d5d250ad3c78
children b5d4cb088737
files artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
diffstat 1 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Fri Nov 11 17:22:55 2022 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Fri Nov 11 18:12:26 2022 +0100
@@ -338,7 +338,7 @@
 
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
-                wQKms2CSV(writer, wqkms, atGauge, isQ);
+                wQKms2CSV(writer, wqkms, atGauge, isQ, false);
                 double[] firstLast = wqkms.getFirstLastKM();
                 if (first.isNaN()) {
                     /* Initialize */
@@ -361,7 +361,8 @@
         }
         /* Append the official fixing at the bottom */
         for (WQKms wqkms: officalFixings) {
-            wQKms2CSV(writer, filterWQKms(wqkms, first, last), atGauge, isQ);
+            wQKms2CSV(
+                writer, filterWQKms(wqkms, first, last), atGauge, isQ, true);
         }
     }
 
@@ -617,8 +618,11 @@
         });
     }
 
-    private String getDesc(WQKms wqkms, boolean isQ)
-    {
+    private String getDesc(WQKms wqkms, boolean isQ, boolean isOfficial) {
+        if (isOfficial) {
+            return wqkms.getName();
+        }
+
         D4EArtifact flys = (D4EArtifact) master;
         String colDesc = "";
 
@@ -642,11 +646,6 @@
                 }
             }
         }
-        if (colDesc != null) {
-            /* Quick hack. Can be removed when database strings are
-             * adapted or left in here as it should never be harmful. */
-            colDesc = colDesc.replace("Amtl.Festlegung_", "Amtl. ");
-        }
 
         return colDesc == null ? "" : colDesc;
     }
@@ -658,7 +657,8 @@
         CSVWriter writer,
         WQKms     wqkms,
         boolean   atGauge,
-        boolean   isQ
+        boolean   isQ,
+        boolean   isOfficial
     ) {
         log.debug("WaterlevelExporter.wQKms2CSV");
 
@@ -694,7 +694,7 @@
         double b = gauge.getRange().getB().doubleValue();
         long startTime = System.currentTimeMillis();
 
-        desc = getDesc(wqkms, isQ);
+        desc = getDesc(wqkms, isQ, isOfficial);
 
         if (flys instanceof FixationArtifact) {
             // Get W/Q input per gauge for this case.
@@ -821,7 +821,7 @@
         // for details.
         for (WQKms wqkms: officalFixings) {
             // To add some spaces here or to add them in the writer,..
-            writer.addColumn(getDesc(wqkms, true));
+            writer.addColumn(getDesc(wqkms, true, true));
 
             // Get all lines from the calculation
             Map <Double, WstLine> calcLines = writer.getLines();
@@ -904,7 +904,7 @@
         addMetaData(source);
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
-                addWKmsData(wqkms, atGauge, isQ, source);
+                addWKmsData(source, wqkms, atGauge, isQ, false);
                 double[] firstLast = wqkms.getFirstLastKM();
                 if (first.isNaN()) {
                     /* Initialize */
@@ -928,7 +928,8 @@
 
         /* Append the official fixing at the bottom */
         for (WQKms wqkms: officalFixings) {
-            addWKmsData(filterWQKms(wqkms, first, last), atGauge, isQ, source);
+            addWKmsData(
+                source, filterWQKms(wqkms, first, last), atGauge, isQ, true);
         }
         return source;
     }
@@ -960,11 +961,12 @@
     }
 
     protected void addWKmsData(
+        WKmsJRDataSource source,
         WQKms wqkms,
         boolean atGauge,
         boolean isQ,
-        WKmsJRDataSource source)
-    {
+        boolean isOfficial
+    ) {
         log.debug("WaterlevelExporter.addWKmsData");
 
         // Skip constant data.
@@ -994,7 +996,7 @@
         double a = gauge.getRange().getA().doubleValue();
         double b = gauge.getRange().getB().doubleValue();
 
-        desc = getDesc(wqkms, isQ);
+        desc = getDesc(wqkms, isQ, isOfficial);
         long startTime = System.currentTimeMillis();
 
         for (int i = 0; i < size; i ++) {

http://dive4elements.wald.intevation.org