[PATCH 5 of 8] New field wsts.sinfo_selection
Wald Commits
scm-commit at wald.intevation.org
Tue Apr 3 10:44:57 CEST 2018
# HG changeset patch
# User mschaefer
# Date 1522744197 -7200
# Node ID 35afa03497822f0eead506a70dcd5aa3c5ff3979
# Parent 26c4415a360a33438e3a420f1087f6e6046d0c3c
New field wsts.sinfo_selection
diff -r 26c4415a360a -r 35afa0349782 backend/src/main/java/org/dive4elements/river/model/Wst.java
--- a/backend/src/main/java/org/dive4elements/river/model/Wst.java Tue Apr 03 10:27:49 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/Wst.java Tue Apr 03 10:29:57 2018 +0200
@@ -12,26 +12,24 @@
import java.math.BigDecimal;
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.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.SequenceGenerator;
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 javax.persistence.OneToMany;
import org.apache.log4j.Logger;
-
+import org.dive4elements.river.backend.SessionHolder;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
import org.hibernate.Session;
-import org.hibernate.SQLQuery;
-import org.hibernate.Query;
import org.hibernate.type.StandardBasicTypes;
-import org.dive4elements.river.backend.SessionHolder;
-
/** DB-mapped WST. */
@Entity
@@ -45,22 +43,23 @@
private River river;
private String description;
private Integer kind;
+ private String sinfo_selection;
private List<WstColumn> columns;
public static final String SQL_SELECT_MINMAX =
- "select min(q) as minQ, max(q) as maxQ from wst_q_values " +
- "where wst_id = :wst and not (a > :km or b < :km)";
+ "select min(q) as minQ, max(q) as maxQ from wst_q_values " +
+ "where wst_id = :wst and not (a > :km or b < :km)";
public Wst() {
}
- public Wst(River river, String description) {
+ public Wst(final River river, final String description) {
this(river, description, 0);
}
- public Wst(River river, String description, Integer kind) {
+ public Wst(final River river, final String description, final Integer kind) {
this.river = river;
this.description = description;
this.kind = kind;
@@ -68,56 +67,65 @@
@Id
@SequenceGenerator(
- name = "SEQUENCE_WSTS_ID_SEQ",
- sequenceName = "WSTS_ID_SEQ",
- allocationSize = 1)
+ name = "SEQUENCE_WSTS_ID_SEQ",
+ sequenceName = "WSTS_ID_SEQ",
+ allocationSize = 1)
@GeneratedValue(
- strategy = GenerationType.SEQUENCE,
- generator = "SEQUENCE_WSTS_ID_SEQ")
+ strategy = GenerationType.SEQUENCE,
+ generator = "SEQUENCE_WSTS_ID_SEQ")
@Column(name = "id")
public Integer getId() {
- return id;
+ return this.id;
}
- public void setId(Integer id) {
+ public void setId(final Integer id) {
this.id = id;
}
@OneToOne
@JoinColumn(name = "river_id" )
public River getRiver() {
- return river;
+ return this.river;
}
- public void setRiver(River river) {
+ public void setRiver(final River river) {
this.river = river;
}
@Column(name = "description")
public String getDescription() {
- return description;
+ return this.description;
}
- public void setDescription(String description) {
+ public void setDescription(final String description) {
this.description = description;
}
@Column(name = "kind")
public Integer getKind() {
- return kind;
+ return this.kind;
}
- public void setKind(Integer kind) {
+ public void setKind(final Integer kind) {
this.kind = kind;
}
+ @Column(name = "sinfo_selection")
+ public String getSInfoSelection() {
+ return this.sinfo_selection;
+ }
+
+ public void setSInfoSelection(final String sinfoSelection) {
+ this.sinfo_selection = sinfoSelection;
+ }
+
@OneToMany
@JoinColumn(name="wst_id")
public List<WstColumn> getColumns() {
- return columns;
+ return this.columns;
}
- public void setColumns(List<WstColumn> columns) {
+ public void setColumns(final List<WstColumn> columns) {
this.columns = columns;
}
@@ -130,8 +138,8 @@
* @return the min and max Q values of this WST.
*/
public double[] determineMinMaxQ() {
- double[] ab = river.determineMinMaxDistance();
- return determineMinMaxQ(new Range(ab[0], ab[1], river));
+ final double[] ab = this.river.determineMinMaxDistance();
+ return determineMinMaxQ(new Range(ab[0], ab[1], this.river));
}
@@ -144,11 +152,11 @@
*
* @return the min and max Q values of this WST.
*/
- public double[] determineMinMaxQ(Range range) {
+ public double[] determineMinMaxQ(final Range range) {
if (range != null) {
return determineMinMaxQ(
- range.getA().doubleValue(),
- range.getB().doubleValue());
+ range.getA().doubleValue(),
+ range.getB().doubleValue());
}
return null;
@@ -165,22 +173,22 @@
*
* @return the min and max Q values of this WST.
*/
- public double[] determineMinMaxQ(double fromKm, double toKm) {
- Session session = SessionHolder.HOLDER.get();
+ public double[] determineMinMaxQ(final double fromKm, final double toKm) {
+ final Session session = SessionHolder.HOLDER.get();
- Query query = session.createQuery(
- "select min(q), max(q) from WstQRange where "
- + "id in "
- + " (select wstQRange.id from WstColumnQRange where "
- + " wstColumn.id in (select id from WstColumn where wst.id = :wst)) "
- + "and range.id in "
- + " (select id from Range where not (a > :end or b < :start))");
+ final Query query = session.createQuery(
+ "select min(q), max(q) from WstQRange where "
+ + "id in "
+ + " (select wstQRange.id from WstColumnQRange where "
+ + " wstColumn.id in (select id from WstColumn where wst.id = :wst)) "
+ + "and range.id in "
+ + " (select id from Range where not (a > :end or b < :start))");
query.setParameter("wst", getId());
query.setParameter("start", new BigDecimal(fromKm));
query.setParameter("end", new BigDecimal(toKm));
- List<Object []> results = query.list();
+ final List<Object []> results = query.list();
if (results.isEmpty()) {
return null;
@@ -191,32 +199,32 @@
return null;
}
- Object [] result = results.get(0);
+ final Object [] result = results.get(0);
return new double [] {
- ((BigDecimal)result[0]).doubleValue(),
- ((BigDecimal)result[1]).doubleValue() };
+ ((BigDecimal)result[0]).doubleValue(),
+ ((BigDecimal)result[1]).doubleValue() };
}
- public double[] determineMinMaxQFree(double km) {
- Session session = SessionHolder.HOLDER.get();
+ public double[] determineMinMaxQFree(final double km) {
+ final Session session = SessionHolder.HOLDER.get();
- SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_MINMAX)
- .addScalar("minQ", StandardBasicTypes.DOUBLE)
- .addScalar("maxQ", StandardBasicTypes.DOUBLE);
+ final SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_MINMAX)
+ .addScalar("minQ", StandardBasicTypes.DOUBLE)
+ .addScalar("maxQ", StandardBasicTypes.DOUBLE);
sqlQuery.setInteger("wst", getId());
sqlQuery.setDouble("km", km);
- List<Object[]> minmaxQ = sqlQuery.list();
+ final List<Object[]> minmaxQ = sqlQuery.list();
if (minmaxQ.isEmpty()) {
return null;
}
- Object[] mm = minmaxQ.get(0);
+ final Object[] mm = minmaxQ.get(0);
if (mm[0] == null || mm[1] == null) {
log.warn("No min/max Q for km " + km + " found.");
More information about the Dive4Elements-commits
mailing list