[Dive4elements-commits] [PATCH] Removed river dependency from flow velocity model
Wald Commits
scm-commit at wald.intevation.org
Fri Mar 15 18:19:21 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1363367947 -3600
# Node ID c7ce7c9e405e154dda933e3583aafaef6ad28170
# Parent 81ad2c717b9c93ed17b2ca51059f74a8ddd1ae4d
Removed river dependency from flow velocity model.
diff -r 81ad2c717b9c -r c7ce7c9e405e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java
--- 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;
diff -r 81ad2c717b9c -r c7ce7c9e405e flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java
--- 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 {
diff -r 81ad2c717b9c -r c7ce7c9e405e flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java
--- 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();
More information about the Dive4elements-commits
mailing list