changeset 6505:128ab9169db1 double-precision

merged changes from default into double-precision branch
author Tom Gottfried <tom.gottfried@intevation.de>
date Fri, 28 Jun 2013 17:03:48 +0200
parents 9daf7c9cf663 (current diff) 7664ab97b4c7 (diff)
children f4fb7e38a288
files backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java
diffstat 3 files changed, 46 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java	Fri Jun 28 16:59:07 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java	Fri Jun 28 17:03:48 2013 +0200
@@ -33,6 +33,7 @@
     protected String    name;
     protected String    description;
     protected Integer   position;
+    protected String    source;
 
     protected ImportTimeInterval timeInterval;
 
@@ -50,7 +51,8 @@
         ImportWst wst,
         String    name,
         String    description,
-        Integer   position
+        Integer   position,
+        String    source
     ) {
         this();
         this.wst         = wst;
@@ -59,6 +61,15 @@
         this.position    = position;
     }
 
+    public ImportWstColumn(
+        ImportWst wst,
+        String    name,
+        String    description,
+        Integer   position
+    ) {
+        this(wst, name, description, position, null);
+    }
+
     public ImportWst getWst() {
         return wst;
     }
@@ -91,6 +102,14 @@
         this.position = position;
     }
 
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
     public void addColumnValue(BigDecimal position, BigDecimal w) {
         columnValues.add(
             new ImportWstColumnValue(this, position, w));
@@ -135,12 +154,14 @@
             Wst w = wst.getPeer(river);
             Session session = ImporterSession.getInstance().getDatabaseSession();
             Query query = session.createQuery(
-                "from WstColumn where " +
-                "wst=:wst and name=:name " +
+                "from WstColumn where" +
+                " wst=:wst and name=:name" +
+                " and source=:source" + 
                 " and position=:position");
-            query.setParameter("wst",         w);
-            query.setParameter("name",        name);
-            query.setParameter("position",    position);
+            query.setParameter("wst",      w);
+            query.setParameter("name",     name);
+            query.setParameter("position", position);
+            query.setParameter("source",   source);
 
             TimeInterval ti = timeInterval != null
                 ? timeInterval.getPeer()
@@ -148,7 +169,8 @@
 
             List<WstColumn> columns = query.list();
             if (columns.isEmpty()) {
-                peer = new WstColumn(w, name, description, position, ti);
+                peer = new WstColumn(
+                    w, name, description, source, position, ti);
                 session.save(peer);
             }
             else {
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java	Fri Jun 28 16:59:07 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java	Fri Jun 28 17:03:48 2013 +0200
@@ -116,7 +116,7 @@
             String [] lsBezeichner   = null;
             String [] langBezeichner = null;
             int    [] colNaWidths    = null;
-            // String [] quellen        = null;
+            String [] quellen        = null;
             String [] daten          = null;
 
             BigDecimal [] aktAbfluesse   = null;
@@ -220,7 +220,7 @@
                         if (spezial.length() == 0) {
                             continue;
                         }
-                        // quellen = StringUtil.splitQuoted(spezial, '"');
+                        quellen = StringUtil.splitQuoted(spezial, '"');
                     }
                     else if (spezial.startsWith(COLUMN_DATUM)) {
                         spezial = spezial.substring(COLUMN_DATUM.length()).trim();
@@ -283,6 +283,9 @@
                             }
                             ImportWstColumn iwc = wst.getColumn(i);
                             iwc.setName(candidate);
+                            if (quellen != null && i < quellen.length) {
+                                iwc.setSource(quellen[i]);
+                            }
                             String potentialDate = daten != null && i < daten.length
                                 ? daten[i]
                                 : candidate;
--- a/backend/src/main/java/org/dive4elements/river/model/WstColumn.java	Fri Jun 28 16:59:07 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/WstColumn.java	Fri Jun 28 17:03:48 2013 +0200
@@ -32,6 +32,7 @@
     private Wst                   wst;
     private String                name;
     private String                description;
+    private String                source;
     private Integer               position;
     private TimeInterval          timeInterval;
 
@@ -45,12 +46,14 @@
         Wst          wst,
         String       name,
         String       description,
+        String       source,
         Integer      position,
         TimeInterval timeInterval
     ) {
         this.wst          = wst;
         this.name         = name;
         this.description  = description;
+        this.source       = source;
         this.position     = position;
         this.timeInterval = timeInterval;
     }
@@ -91,6 +94,15 @@
         this.name = name;
     }
 
+    @Column(name = "source")
+    public String getSource() {
+        return description;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
     @Column(name = "description")
     public String getDescription() {
         return description;

http://dive4elements.wald.intevation.org