changeset 5439:7aeb2c101628

removed unit from model and importer for grain fractions (its always mm, otherwise a typo)
author Tom Gottfried <tom.gottfried@intevation.de>
date Tue, 26 Mar 2013 18:04:59 +0100
parents 91b14ade2149
children 765013c837b1
files flys-backend/src/main/java/de/intevation/flys/importer/ImportGrainFraction.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java flys-backend/src/main/java/de/intevation/flys/model/GrainFraction.java
diffstat 3 files changed, 8 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportGrainFraction.java	Tue Mar 26 17:35:39 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportGrainFraction.java	Tue Mar 26 18:04:59 2013 +0100
@@ -8,7 +8,6 @@
 import org.hibernate.Query;
 
 import de.intevation.flys.model.GrainFraction;
-import de.intevation.flys.model.Unit;
 
 
 public class ImportGrainFraction {
@@ -21,8 +20,6 @@
     private Double lower;
     private Double upper;
 
-    private ImportUnit unit;
-
     private GrainFraction peer;
 
 
@@ -34,13 +31,11 @@
     public ImportGrainFraction(
         String     name,
         Double     lower,
-        Double     upper,
-        ImportUnit unit
+        Double     upper
     ) {
         this.name  = name;
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
 
@@ -54,28 +49,24 @@
     public GrainFraction getPeer() {
         log.debug("get peer");
 
-        Unit u = unit != null ? unit.getPeer() : null;
-
         if (peer == null) {
             Session session = ImporterSession.getInstance().getDatabaseSession();
             Query query = session.createQuery(
                 "from GrainFraction where " +
                 "   name=:name and " +
                 "   lower=:lower and " +
-                "   upper=:upper and " +
-                "   unit=:unit"
+                "   upper=:upper"
             );
 
             query.setParameter("name", name);
             query.setParameter("lower", lower);
             query.setParameter("upper", upper);
-            query.setParameter("unit", u);
 
             List<GrainFraction> fractions = query.list();
             if (fractions.isEmpty()) {
                 log.info("create new GrainFraction");
 
-                peer = new GrainFraction(name, lower, upper, u);
+                peer = new GrainFraction(name, lower, upper);
                 session.save(peer);
             }
             else {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Tue Mar 26 17:35:39 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Tue Mar 26 18:04:59 2013 +0100
@@ -285,7 +285,6 @@
             String upperA = a.group(4);
             String upperB = a.group(5);
 
-            String unitStr = a.group(7);
             String lower = lowerA != null ? lowerA : lowerB;
             String upper = upperA != null ? upperA : upperB;
 
@@ -293,8 +292,7 @@
                 return new ImportGrainFraction(
                     getGrainFractionTypeName(this.description),
                     nf.parse(lower).doubleValue(),
-                    nf.parse(upper).doubleValue(),
-                    new ImportUnit(unitStr)
+                    nf.parse(upper).doubleValue()
                 );
             }
             catch (ParseException pe) {
@@ -308,7 +306,6 @@
             String lowerB  = b.group(5);
             String upperA  = b.group(6);
             String upperB  = b.group(7);
-            String unitStr = b.group(9);
 
             String lower = lowerA != null ? lowerA : lowerB;
             String upper = upperA != null ? upperA : upperB;
@@ -317,8 +314,7 @@
                 return new ImportGrainFraction(
                     getGrainFractionTypeName(this.description),
                     nf.parse(lower).doubleValue(),
-                    nf.parse(upper).doubleValue(),
-                    new ImportUnit(unitStr)
+                    nf.parse(upper).doubleValue()
                 );
             }
             catch (ParseException pe) {
@@ -330,7 +326,6 @@
         if (c.matches()) {
             String oper     = c.group(1);
             String valueStr = c.group(3);
-            String unitStr  = c.group(6);
 
             try {
                 Double value = nf.parse(valueStr).doubleValue();
@@ -339,16 +334,14 @@
                     return new ImportGrainFraction(
                         getGrainFractionTypeName(this.description),
                         value,
-                        null,
-                        new ImportUnit(unitStr)
+                        null
                     );
                 }
                 else {
                     return new ImportGrainFraction(
                         getGrainFractionTypeName(this.description),
                         null,
-                        value,
-                        new ImportUnit(unitStr)
+                        value
                     );
                 }
             }
--- a/flys-backend/src/main/java/de/intevation/flys/model/GrainFraction.java	Tue Mar 26 17:35:39 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/GrainFraction.java	Tue Mar 26 18:04:59 2013 +0100
@@ -38,17 +38,14 @@
     private Double lower;
     private Double upper;
 
-    private Unit unit;
-
 
     public GrainFraction() {
     }
 
-    public GrainFraction(String name, Double lower, Double upper, Unit unit) {
+    public GrainFraction(String name, Double lower, Double upper) {
         this.name  = name;
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
     @Id
@@ -95,14 +92,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 :

http://dive4elements.wald.intevation.org