[Dive4elements-commits] [PATCH 1 of 2] Set description when importing flow velocity models

Wald Commits scm-commit at wald.intevation.org
Fri Apr 12 19:52:25 CEST 2013


# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1365789104 -7200
# Node ID a3f7da9bf0d1febccb4431c299c5b54f28ca464a
# Parent  545a6ace9a19b243b7560d6922153b6b089f1851
Set description when importing flow velocity models

diff -r 545a6ace9a19 -r a3f7da9bf0d1 flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Fri Apr 12 15:08:14 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Fri Apr 12 19:51:44 2013 +0200
@@ -30,6 +30,12 @@
         values = new ArrayList<ImportFlowVelocityModelValue>();
     }
 
+    public ImportFlowVelocityModel(String description) {
+        this();
+
+        this.description = description;
+    }
+
     public ImportFlowVelocityModel(ImportDischargeZone dischargeZone,
         String description) {
         this();
@@ -84,14 +90,12 @@
             Query query = session.createQuery("from FlowVelocityModel where "
                 + "   dischargeZone=:dischargeZone");
 
-            //query.setParameter("river", river);
             query.setParameter("dischargeZone", zone);
 
             List<FlowVelocityModel> model = query.list();
 
             if (model.isEmpty()) {
-                //peer = new FlowVelocityModel(river, zone);
-                peer = new FlowVelocityModel(zone);
+                peer = new FlowVelocityModel(zone, description);
                 session.save(peer);
             }
             else {
diff -r 545a6ace9a19 -r a3f7da9bf0d1 flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java	Fri Apr 12 15:08:14 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java	Fri Apr 12 19:51:44 2013 +0200
@@ -1,5 +1,8 @@
 package de.intevation.flys.importer.parsers;
 
+import java.io.File;
+import java.io.IOException;
+
 import java.math.BigDecimal;
 import java.text.NumberFormat;
 import java.text.ParseException;
@@ -49,6 +52,8 @@
 
     private ImportFlowVelocityModel current;
 
+    protected String description;
+
 
     public FlowVelocityModelParser() {
         models = new ArrayList<ImportFlowVelocityModel>();
@@ -60,14 +65,23 @@
     }
 
     @Override
+    public void parse(File file) throws IOException {
+        description = file.getName();
+
+        super.parse(file);
+    }
+
+    @Override
     protected void reset() {
-        current = new ImportFlowVelocityModel();
+        current = new ImportFlowVelocityModel(description);
     }
 
 
     @Override
     protected void finish() {
         models.add(current);
+
+	//	description = null;
     }
 
 


More information about the Dive4elements-commits mailing list