[Dive4elements-commits] [PATCH] remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)

Wald Commits scm-commit at wald.intevation.org
Tue Mar 26 19:30:25 CET 2013


# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1364322579 -3600
# Node ID 7c1dd9c3f6bd132d963111fe9acea017de511b2e
# Parent  765013c837b1f92ad4ff2d72807bd25d374825ec
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)

diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/doc/schema/oracle-drop-minfo.sql
--- a/flys-backend/doc/schema/oracle-drop-minfo.sql	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/doc/schema/oracle-drop-minfo.sql	Tue Mar 26 19:29:39 2013 +0100
@@ -12,9 +12,7 @@
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_cur_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_old_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_range;
-ALTER TABLE depths DROP CONSTRAINT fk_depths_unit_id;
 ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_depth_id;
-ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_unit_id;
 ALTER TABLE sediment_density_values DROP CONSTRAINT fk_sdv_sediment_density_id;
 ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_river_id;
 ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_unit_id;
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/doc/schema/oracle-minfo.sql
--- a/flys-backend/doc/schema/oracle-minfo.sql	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Tue Mar 26 19:29:39 2013 +0100
@@ -114,9 +114,7 @@
     id      NUMBER(38,0) NOT NULL,
     lower   NUMBER(38,2) NOT NULL,
     upper   NUMBER(38,2) NOT NULL,
-    unit_id NUMBER(38,0) NOT NULL,
-    PRIMARY KEY(id),
-    CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    PRIMARY KEY(id)
 );
 
 
@@ -126,12 +124,10 @@
     id          NUMBER(38,0) NOT NULL,
     river_id    NUMBER(38,0) NOT NULL,
     depth_id    NUMBER(38,0) NOT NULL,
-    unit_id     NUMBER(38,0) NOT NULL,
     description VARCHAR(256),
     PRIMARY KEY(id),
     CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id),
-    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id),
-    CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id)
 );
 
 
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/doc/schema/postgresql-minfo.sql
--- a/flys-backend/doc/schema/postgresql-minfo.sql	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-minfo.sql	Tue Mar 26 19:29:39 2013 +0100
@@ -114,9 +114,7 @@
     id      int NOT NULL,
     lower   NUMERIC NOT NULL,
     upper   NUMERIC NOT NULL,
-    unit_id int NOT NULL,
-    PRIMARY KEY(id),
-    CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    PRIMARY KEY(id)
 );
 
 
@@ -126,12 +124,10 @@
     id          int NOT NULL,
     river_id    int NOT NULL,
     depth_id    int NOT NULL,
-    unit_id     int NOT NULL,
     description VARCHAR(256),
     PRIMARY KEY(id),
     CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
-    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id),
-    CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id)
 );
 
 
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java	Tue Mar 26 19:29:39 2013 +0100
@@ -22,13 +22,10 @@
     protected BigDecimal lower;
     protected BigDecimal upper;
 
-    protected ImportUnit unit;
 
-
-    public ImportDepth(BigDecimal lower, BigDecimal upper, ImportUnit unit) {
+    public ImportDepth(BigDecimal lower, BigDecimal upper) {
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
 
@@ -48,19 +45,17 @@
             Query query = session.createQuery(
                 "from Depth where " +
                 "   lower=:lower and " +
-                "   upper=:upper and " +
-                "   unit=:unit");
+                "   upper=:upper");
 
             query.setParameter("lower", lower);
             query.setParameter("upper", upper);
-            query.setParameter("unit", unit.getPeer());
 
             List<Depth> depths = query.list();
 
             if (depths.isEmpty()) {
                 log.debug("Create new Depth DB instance.");
 
-                peer = new Depth(lower, upper, unit.getPeer());
+                peer = new Depth(lower, upper);
 
                 session.save(peer);
             }
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java	Tue Mar 26 19:29:39 2013 +0100
@@ -21,8 +21,6 @@
 
     protected ImportDepth depth;
 
-    protected ImportUnit unit;
-
     protected String description;
 
     protected List<ImportSedimentDensityValue> values;
@@ -40,10 +38,6 @@
         this.depth = depth;
     }
 
-    public void setUnit(ImportUnit unit) {
-        this.unit = unit;
-    }
-
     public void addValue(ImportSedimentDensityValue value) {
         values.add(value);
     }
@@ -74,23 +68,15 @@
             return null;
         }
 
-        if (unit == null) {
-            log.warn("cannot store sediment density '" + description
-                + "': no unit");
-            return null;
-        }
-
         if (peer == null) {
             Session session = ImporterSession.getInstance()
                 .getDatabaseSession();
 
             Query query = session.createQuery("from SedimentDensity where "
-                + "   river=:river and " + "   depth=:depth and "
-                + "   unit=:unit");
+                + "   river=:river and " + "   depth=:depth");
 
             query.setParameter("river", river);
             query.setParameter("depth", depth.getPeer());
-            query.setParameter("unit", unit.getPeer());
 
             List<SedimentDensity> density = query.list();
 
@@ -98,7 +84,7 @@
                 log.debug("Create new SedimentDensity DB instance.");
 
                 peer = new SedimentDensity(river, depth.getPeer(),
-                    unit.getPeer(), description);
+                    description);
 
                 session.save(peer);
             }
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Tue Mar 26 19:29:39 2013 +0100
@@ -20,7 +20,6 @@
 import de.intevation.flys.importer.ImportDepth;
 import de.intevation.flys.importer.ImportSedimentDensity;
 import de.intevation.flys.importer.ImportSedimentDensityValue;
-import de.intevation.flys.importer.ImportUnit;
 import de.intevation.flys.utils.DateGuesser;
 
 
@@ -34,9 +33,6 @@
     public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE);
 
 
-    public static final Pattern META_UNIT =
-        Pattern.compile("^Einheit: \\[(.*)\\].*");
-
     public static final Pattern META_DEPTH =
         Pattern.compile("^Tiefe: (\\w++)-(\\w++)( (\\w++))?.*");
 
@@ -86,10 +82,7 @@
 
 
     protected void handleMetaLine(String line) {
-        if (handleMetaUnit(line)) {
-            return;
-        }
-        else if (handleMetaDepth(line)) {
+        if (handleMetaDepth(line)) {
             return;
         }
         else if (handleMetaColumns(line)) {
@@ -113,36 +106,19 @@
     }
 
 
-    protected boolean handleMetaUnit(String line) {
-        Matcher m = META_UNIT.matcher(line);
-
-        if (m.matches()) {
-            String unit = m.group(1);
-
-            current.setUnit(new ImportUnit(unit));
-
-            return true;
-        }
-
-        return false;
-    }
-
-
     protected boolean handleMetaDepth(String line) {
         Matcher m = META_DEPTH.matcher(line);
 
         if (m.matches()) {
             String lo   = m.group(1);
             String up   = m.group(2);
-            String unit = m.group(4);
 
-            log.info("Found sediment density depth: " + lo + " - " + up + " " + unit);
+            log.info("Found sediment density depth: " + lo + " - " + up + " cm");
 
             try {
                 ImportDepth depth = new ImportDepth(
                     new BigDecimal(nf.parse(lo).doubleValue()),
-                    new BigDecimal(nf.parse(up).doubleValue()),
-                    new ImportUnit(unit)
+                    new BigDecimal(nf.parse(up).doubleValue())
                 );
 
                 current.setDepth(depth);
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/src/main/java/de/intevation/flys/model/Depth.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/Depth.java	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Depth.java	Tue Mar 26 19:29:39 2013 +0100
@@ -10,8 +10,6 @@
 import javax.persistence.Column;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.GenerationType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
 
 
 @Entity
@@ -23,17 +21,14 @@
     private BigDecimal lower;
     private BigDecimal upper;
 
-    private Unit unit;
-
 
     public Depth() {
     }
 
 
-    public Depth(BigDecimal lower, BigDecimal upper, Unit unit) {
+    public Depth(BigDecimal lower, BigDecimal upper) {
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
     @Id
@@ -71,14 +66,5 @@
         this.upper = upper;
     }
 
-    @OneToOne
-    @JoinColumn(name = "unit_id")
-    public Unit getUnit() {
-        return unit;
-    }
-
-    public void setUnit(Unit unit) {
-        this.unit = unit;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 765013c837b1 -r 7c1dd9c3f6bd flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java	Tue Mar 26 18:06:42 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java	Tue Mar 26 19:29:39 2013 +0100
@@ -25,8 +25,6 @@
 
     private Depth depth;
 
-    private Unit unit;
-
     private List<SedimentDensityValue> values;
 
     private String description;
@@ -36,10 +34,9 @@
     }
 
 
-    public SedimentDensity(River river, Depth depth, Unit unit, String desc) {
+    public SedimentDensity(River river, Depth depth, String desc) {
         this.river       = river;
         this.depth       = depth;
-        this.unit        = unit;
         this.description = desc;
     }
 
@@ -80,16 +77,6 @@
         this.depth = depth;
     }
 
-    @OneToOne
-    @JoinColumn(name = "unit_id")
-    public Unit getUnit() {
-        return unit;
-    }
-
-    public void setUnit(Unit unit) {
-        this.unit = unit;
-    }
-
     @Column(name = "description")
     public String getDescription() {
         return description;


More information about the Dive4elements-commits mailing list