changeset 5323:c7ce7c9e405e

Removed river dependency from flow velocity model.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 15 Mar 2013 18:19:07 +0100
parents 81ad2c717b9c
children 807fa01b498b
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java
diffstat 3 files changed, 25 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java	Fri Mar 15 17:19:16 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java	Fri Mar 15 18:19:07 2013 +0100
@@ -1,9 +1,5 @@
 package de.intevation.flys.artifacts.model;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import de.intevation.artifacts.Artifact;
 
 import de.intevation.flys.artifacts.access.FlowVelocityAccess;
@@ -11,7 +7,10 @@
 import de.intevation.flys.model.DischargeZone;
 import de.intevation.flys.model.FlowVelocityModel;
 import de.intevation.flys.model.FlowVelocityModelValue;
-import de.intevation.flys.model.River;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.log4j.Logger;
 
@@ -97,21 +96,11 @@
             return Collections.<FlowVelocityModel>emptyList();
         }
 
-        River river = RiverFactory.getRiver(riverName);
-        if (river == null) {
-            logger.warn("No such river: " + riverName);
-            return Collections.<FlowVelocityModel>emptyList();
-        }
-
         List<FlowVelocityModel> models = new ArrayList<FlowVelocityModel>();
 
         for (DischargeZone zone: zones) {
-            List<FlowVelocityModel> model =
-                FlowVelocityModel.getModels(river, zone);
-
-            if (model != null) {
-                models.addAll(model);
-            }
+            List<FlowVelocityModel> model = FlowVelocityModel.getModels(zone);
+            models.addAll(model);
         }
 
         return models;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Fri Mar 15 17:19:16 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Fri Mar 15 18:19:07 2013 +0100
@@ -85,15 +85,16 @@
             DischargeZone zone = dischargeZone.getPeer(river);
 
             Query query = session.createQuery("from FlowVelocityModel where "
-                + "   river=:river and " + "   dischargeZone=:dischargeZone");
+                + "   dischargeZone=:dischargeZone");
 
-            query.setParameter("river", river);
+            //query.setParameter("river", river);
             query.setParameter("dischargeZone", zone);
 
             List<FlowVelocityModel> model = query.list();
 
             if (model.isEmpty()) {
-                peer = new FlowVelocityModel(river, zone);
+                //peer = new FlowVelocityModel(river, zone);
+                peer = new FlowVelocityModel(zone);
                 session.save(peer);
             }
             else {
--- a/flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java	Fri Mar 15 17:19:16 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java	Fri Mar 15 18:19:07 2013 +0100
@@ -1,24 +1,25 @@
 package de.intevation.flys.model;
 
+import de.intevation.flys.backend.SessionHolder;
+
 import java.io.Serializable;
+
 import java.util.List;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
 import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Column;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.GenerationType;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
-
-import org.hibernate.Session;
-import org.hibernate.Query;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
 
 import org.apache.log4j.Logger;
 
-import de.intevation.flys.backend.SessionHolder;
+import org.hibernate.Query;
+import org.hibernate.Session;
 
 
 @Entity
@@ -31,12 +32,8 @@
 
     private Integer id;
 
-    private River river;
-
     private DischargeZone dischargeZone;
 
-    private List<FlowVelocityModelValue> values;
-
     private String description;
 
 
@@ -44,17 +41,15 @@
     }
 
 
-    public FlowVelocityModel(River river, DischargeZone dischargeZone) {
-        this(river, dischargeZone, null);
+    public FlowVelocityModel(DischargeZone dischargeZone) {
+        this(dischargeZone, null);
     }
 
 
     public FlowVelocityModel(
-        River         river,
         DischargeZone dischargeZone,
         String        description
     ) {
-        this.river         = river;
         this.dischargeZone = dischargeZone;
         this.description   = description;
     }
@@ -77,16 +72,6 @@
     }
 
     @OneToOne
-    @JoinColumn(name = "river_id")
-    public River getRiver() {
-        return river;
-    }
-
-    public void setRiver(River river) {
-        this.river = river;
-    }
-
-    @OneToOne
     @JoinColumn(name = "discharge_zone_id")
     public DischargeZone getDischargeZone() {
         return dischargeZone;
@@ -106,16 +91,13 @@
     }
 
 
-    public static List<FlowVelocityModel> getModels(
-        River         river,
-        DischargeZone zone
-    ) {
+    public static List<FlowVelocityModel> getModels(DischargeZone zone) {
+
         Session session = SessionHolder.HOLDER.get();
 
         Query query = session.createQuery(
-            "from FlowVelocityModel where river=:river and dischargeZone=:zone");
+            "from FlowVelocityModel where dischargeZone=:zone");
 
-        query.setParameter("river", river);
         query.setParameter("zone", zone);
 
         return query.list();

http://dive4elements.wald.intevation.org