Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/model/BedHeight.java @ 9074:766890addcb2
state To client communication;
author | gernotbelger |
---|---|
date | Fri, 18 May 2018 17:26:26 +0200 |
parents | 4c5eeaff554c |
children | 02e4a0d983c0 |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Thu May 17 13:06:12 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Fri May 18 17:26:26 2018 +0200 @@ -27,7 +27,6 @@ import org.hibernate.Query; import org.hibernate.Session; - @Entity @Table(name = "bed_height") public class BedHeight implements Serializable { @@ -40,7 +39,7 @@ private River river; - private BedHeightType type; + private BedHeightType type; private LocationSystem locationSystem; @@ -55,35 +54,30 @@ private List<BedHeightValue> values; - public BedHeight() { } - public BedHeight(final River river, final Integer year, final BedHeightType type, final LocationSystem locationSystem, - final ElevationModel curElevationModel, - final Range range) { + final ElevationModel curElevationModel, final Range range) { this(river, year, type, locationSystem, curElevationModel, null, range, null, null, null, null); } - public BedHeight(final River river, final Integer year, final BedHeightType type, final LocationSystem locationSystem, final ElevationModel curElevationModel, final ElevationModel oldElevationModel, final Range range, final String evaluationBy, final String description, final String sounding_width_info, final String notes) { - this.river = river; - this.year = year; - this.type = type; - this.locationSystem = locationSystem; + this.river = river; + this.year = year; + this.type = type; + this.locationSystem = locationSystem; this.curElevationModel = curElevationModel; this.oldElevationModel = oldElevationModel; - this.range = range; - this.evaluationBy = evaluationBy; - this.description = description; + this.range = range; + this.evaluationBy = evaluationBy; + this.description = description; this.sounding_width_info = sounding_width_info; this.notes = notes; } - @Id @SequenceGenerator(name = "SEQUENCE_BED_HEIGHT_ID_SEQ", sequenceName = "BED_HEIGHT_ID_SEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BED_HEIGHT_ID_SEQ") @@ -211,26 +205,20 @@ this.values = values; } - - public static List<BedHeight> getBedHeights( - final River river, - final double kmLo, - final double kmHi - ) { + public static List<BedHeight> getBedHeights(final River river, final double kmLo, final double kmHi) { final Session session = SessionHolder.HOLDER.get(); - final Query query = session.createQuery( - "from BedHeight where river=:river"); + final Query query = session.createQuery("from BedHeight where river=:river"); query.setParameter("river", river); // TODO Do km range filtering in SQL statement final List<BedHeight> singles = query.list(); - final List<BedHeight> good = new ArrayList<>(); + final List<BedHeight> good = new ArrayList<>(); - for (final BedHeight s: singles) { - for (final BedHeightValue value: s.getValues()) { + for (final BedHeight s : singles) { + for (final BedHeightValue value : s.getValues()) { final double station = value.getStation().doubleValue(); if (station >= kmLo && station <= kmHi) { @@ -243,12 +231,10 @@ return good; } - public static BedHeight getBedHeightById(final int id) { final Session session = SessionHolder.HOLDER.get(); - final Query query = session.createQuery( - "from BedHeight where id=:id"); + final Query query = session.createQuery("from BedHeight where id=:id"); query.setParameter("id", id);