changeset 499:cce054f27dac

Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default. flys-backend/trunk@1853 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 08 May 2011 21:34:43 +0000
parents 8ab04de0b879
children d50cd3a632e0
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTable.java flys-backend/src/main/java/de/intevation/flys/importer/ImportGauge.java flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java flys-backend/src/main/java/de/intevation/flys/importer/ImporterSession.java flys-backend/src/main/java/de/intevation/flys/importer/StaFileParser.java
diffstat 8 files changed, 48 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/ChangeLog	Sun May 08 21:34:43 2011 +0000
@@ -1,3 +1,22 @@
+2011-05-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/StaFileParser.java:
+	  Only accept main value types 'Q', 'W', 'D' and 'T' by default.
+	  '-' is not handled any more because it causes too much constraint
+	  problems. You can overwrite the imported type with the
+	  system property flys.backend.main.value.types" (default "QWTD")
+	  
+	* src/main/java/de/intevation/flys/importer/ImporterSession.java:
+	  Set session flush mode to manual. Hopefully this improves the
+	  performance a bit.
+
+	* src/main/java/de/intevation/flys/importer/ImportWst.java,
+	  src/main/java/de/intevation/flys/importer/ImportGauge.java,
+	  src/main/java/de/intevation/flys/importer/ImportWstColumn.java,
+	  src/main/java/de/intevation/flys/importer/ImportRange.java,
+	  src/main/java/de/intevation/flys/importer/ImportDischargeTable.java:
+	  Improved logging.
+
 2011-05-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/WstColumnValueKey.java: Deleted
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTable.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTable.java	Sun May 08 21:34:43 2011 +0000
@@ -10,8 +10,12 @@
 import de.intevation.flys.model.Gauge;
 import de.intevation.flys.model.TimeInterval;
 
+import org.apache.log4j.Logger;
+
 public class ImportDischargeTable
 {
+    private static Logger log = Logger.getLogger(ImportDischargeTable.class);
+
     protected DischargeTable peer;
 
     protected String         description;
@@ -96,6 +100,7 @@
 
 
     public void storeDependencies(Gauge gauge) {
+        log.info("store discharge table '" + description + "'");
         storeDischargeTableValues(gauge);
     }
 
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportGauge.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportGauge.java	Sun May 08 21:34:43 2011 +0000
@@ -197,14 +197,17 @@
 
         Gauge gauge = getPeer(river);
 
+        log.info("store main value types");
         for (ImportMainValueType mainValueType: mainValueTypes) {
             mainValueType.getPeer();
         }
 
+        log.info("store named main values");
         for (ImportNamedMainValue namedMainValue: namedMainValues) {
             namedMainValue.getPeer();
         }
 
+        log.info("store main values");
         for (ImportMainValue mainValue: mainValues) {
             mainValue.getPeer(river);
         }
@@ -214,11 +217,13 @@
     }
 
     public void storeDischargeTable(Gauge gauge) {
+        log.info("store discharge table");
         dischargeTable.getPeer(gauge);
         dischargeTable.storeDependencies(gauge);
     }
 
     public void storeHistoricalDischargeTable(Gauge gauge) {
+        log.info("store historical discharge tables");
         for (ImportDischargeTable hdt: historicalDischargeTables) {
             hdt.storeDependencies(gauge);
         }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java	Sun May 08 21:34:43 2011 +0000
@@ -73,7 +73,7 @@
             query.setParameter("a", a);
             query.setParameter("b", b);
             query.setParameter("river", river);
-            log.debug("a: " + a + " b: " + b + " river.id: " + river.getId());
+            //log.debug("a: " + a + " b: " + b + " river.id: " + river.getId());
             List<Range> ranges = query.list();
             if (ranges.isEmpty()) {
                 peer = new Range(a, b, river);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Sun May 08 21:34:43 2011 +0000
@@ -13,7 +13,7 @@
 
 public class ImportWst
 {
-    private static Logger logger = Logger.getLogger(ImportWst.class);
+    private static Logger log = Logger.getLogger(ImportWst.class);
 
     protected String description;
 
@@ -65,6 +65,8 @@
     }
 
     public void storeDependencies(River river) {
+
+        log.info("store '" + description + "'");
         Wst wst = getPeer(river);
 
         for (ImportWstColumn column: columns) {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java	Sun May 08 21:34:43 2011 +0000
@@ -12,8 +12,12 @@
 
 import java.math.BigDecimal;
 
+import org.apache.log4j.Logger;
+
 public class ImportWstColumn
 {
+    private static Logger log = Logger.getLogger(ImportWstColumn.class);
+
     protected ImportWst wst;
     protected String    name;
     protected String    description;
@@ -85,10 +89,14 @@
     }
 
     public void storeDependencies(River river) {
+        log.info("store column '" + description + "'");
         WstColumn column = getPeer(river);
+        log.info("store q ranges");
         for (ImportWstColumnQRange columnQRange: columnQRanges) {
             columnQRange.getPeer(river);
         }
+
+        log.info("store w values");
         for (ImportWstColumnValue columnValue: columnValues) {
             columnValue.getPeer(river);
         }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImporterSession.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImporterSession.java	Sun May 08 21:34:43 2011 +0000
@@ -9,6 +9,7 @@
 import org.hibernate.SessionFactory;
 import org.hibernate.Session;
 import org.hibernate.Query;
+import org.hibernate.FlushMode;
 
 import de.intevation.flys.backend.SessionFactoryProvider;
 
@@ -41,6 +42,7 @@
         SessionFactory sessionFactory =
             SessionFactoryProvider.createSessionFactory();
         databaseSession = sessionFactory.openSession();
+        databaseSession.setFlushMode(FlushMode.MANUAL);
     }
 
     public Session getDatabaseSession() {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/StaFileParser.java	Sun May 08 17:55:49 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/StaFileParser.java	Sun May 08 21:34:43 2011 +0000
@@ -22,8 +22,12 @@
 
     public static final String ENCODING = "ISO-8859-1";
 
+    public static final String TYPES =
+        System.getProperty("flys.backend.main.value.types", "QWTD");
+
     public static final Pattern QWTD_ =
-        Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([QWTD-]).*");
+        Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([" +
+            Pattern.quote(TYPES) + "]).*");
 
     public StaFileParser() {
     }

http://dive4elements.wald.intevation.org