Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/model/BedHeight.java @ 8975:a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
author | mschaefer |
---|---|
date | Tue, 03 Apr 2018 10:40:57 +0200 |
parents | 11bf13cf0463 |
children | 4c5eeaff554c |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Tue Apr 03 10:37:30 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Tue Apr 03 10:40:57 2018 +0200 @@ -9,25 +9,23 @@ package org.dive4elements.river.model; import java.io.Serializable; - import java.util.ArrayList; 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.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; import javax.persistence.SequenceGenerator; -import javax.persistence.GenerationType; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.OneToMany; - -import org.hibernate.Session; -import org.hibernate.Query; +import javax.persistence.Table; import org.dive4elements.river.backend.SessionHolder; +import org.hibernate.Query; +import org.hibernate.Session; @Entity @@ -52,6 +50,9 @@ private Range range; + private String sounding_width_info; + private String comment; + private List<BedHeightValue> values; @@ -59,38 +60,17 @@ } - public BedHeight( - River river, - Integer year, - BedHeightType type, - LocationSystem locationSystem, - ElevationModel curElevationModel, - Range range - ) { - this( - river, - year, - type, - locationSystem, - curElevationModel, - null, - range, - null, - null); + public BedHeight(final River river, final Integer year, final BedHeightType type, final LocationSystem locationSystem, + final ElevationModel curElevationModel, + final Range range) { + this(river, year, type, locationSystem, curElevationModel, null, range, null, null, null, null); } - public BedHeight( - River river, - Integer year, - BedHeightType type, - LocationSystem locationSystem, - ElevationModel curElevationModel, - ElevationModel oldElevationModel, - Range range, - String evaluationBy, - String description - ) { + 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 comment) { this.river = river; this.year = year; this.type = type; @@ -100,144 +80,159 @@ this.range = range; this.evaluationBy = evaluationBy; this.description = description; + this.sounding_width_info = sounding_width_info; + this.comment = comment; } @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") + @SequenceGenerator(name = "SEQUENCE_BED_HEIGHT_ID_SEQ", sequenceName = "BED_HEIGHT_ID_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BED_HEIGHT_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 = "year") public Integer getYear() { - return year; + return this.year; } - public void setYear(Integer year) { + public void setYear(final Integer year) { this.year = year; } @OneToOne @JoinColumn(name = "type_id") public BedHeightType getType() { - return type; + return this.type; } - public void setType(BedHeightType type) { + public void setType(final BedHeightType type) { this.type = type; } @OneToOne @JoinColumn(name = "location_system_id") public LocationSystem getLocationSystem() { - return locationSystem; + return this.locationSystem; } - public void setLocationSystem(LocationSystem locationSystem) { + public void setLocationSystem(final LocationSystem locationSystem) { this.locationSystem = locationSystem; } @OneToOne @JoinColumn(name = "cur_elevation_model_id") public ElevationModel getCurElevationModel() { - return curElevationModel; + return this.curElevationModel; } - public void setCurElevationModel(ElevationModel curElevationModel) { + public void setCurElevationModel(final ElevationModel curElevationModel) { this.curElevationModel = curElevationModel; } @OneToOne @JoinColumn(name = "old_elevation_model_id") public ElevationModel getOldElevationModel() { - return oldElevationModel; + return this.oldElevationModel; } - public void setOldElevationModel(ElevationModel oldElevationModel) { + public void setOldElevationModel(final ElevationModel oldElevationModel) { this.oldElevationModel = oldElevationModel; } @OneToOne @JoinColumn(name = "range_id") public Range getRange() { - return range; + return this.range; } - public void setRange(Range range) { + public void setRange(final Range range) { this.range = range; } @Column(name = "evaluation_by") public String getEvaluationBy() { - return evaluationBy; + return this.evaluationBy; } - public void setEvaluationBy(String evaluationBy) { + public void setEvaluationBy(final String evaluationBy) { this.evaluationBy = evaluationBy; } @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 = "sounding_width_info") + public String getSoundingWidthInfo() { + return this.sounding_width_info; + } + + public void setSoundingWidthInfo(final String sounding_width_info) { + this.sounding_width_info = sounding_width_info; + } + + @Column(name = "comment") + public String getComment() { + return this.comment; + } + + public void setComment(final String comment) { + this.comment = comment; + } + @OneToMany @JoinColumn(name = "bed_height_id") public List<BedHeightValue> getValues() { - return values; + return this.values; } - public void setValues(List<BedHeightValue> values) { + public void setValues(final List<BedHeightValue> values) { this.values = values; } public static List<BedHeight> getBedHeights( - River river, - double kmLo, - double kmHi - ) { - Session session = SessionHolder.HOLDER.get(); + final River river, + final double kmLo, + final double kmHi + ) { + final Session session = SessionHolder.HOLDER.get(); - 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 - List<BedHeight> singles = query.list(); - List<BedHeight> good = new ArrayList<BedHeight>(); + final List<BedHeight> singles = query.list(); + final List<BedHeight> good = new ArrayList<>(); - for (BedHeight s: singles) { - for (BedHeightValue value: s.getValues()) { - double station = value.getStation().doubleValue(); + for (final BedHeight s: singles) { + for (final BedHeightValue value: s.getValues()) { + final double station = value.getStation().doubleValue(); if (station >= kmLo && station <= kmHi) { good.add(s); @@ -250,29 +245,29 @@ } - public static BedHeight getBedHeightById(int id) { - Session session = SessionHolder.HOLDER.get(); + public static BedHeight getBedHeightById(final int id) { + final Session session = SessionHolder.HOLDER.get(); - Query query = session.createQuery( - "from BedHeight where id=:id"); + final Query query = session.createQuery( + "from BedHeight where id=:id"); query.setParameter("id", id); - List<BedHeight> singles = query.list(); + final List<BedHeight> singles = query.list(); return singles != null ? singles.get(0) : null; } public static BedHeight getBedHeightByDescription(final String description) { - + final Session session = SessionHolder.HOLDER.get(); - - final Query query = session.createQuery("from BedHeight where description=:description"); + + final Query query = session.createQuery("FROM BedHeight WHERE (trim(description)=:description)"); query.setParameter("description", description); - + final List<BedHeight> singles = query.list(); - - return singles != null ? singles.get(0) : null; + + return singles != null ? singles.get(0) : null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file