# HG changeset patch # User Ingo Weinzierl # Date 1336647925 0 # Node ID b6f94c5db89e9dd0809dce37127df60a7b299996 # Parent 6442b30d80ecbc8bfb16c6da385867fcaee2ab55 Added HydrBoundary and HydrBoundaryPoly and adapted method signatures of Line and Building. flys-backend/trunk@4382 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/ChangeLog --- a/flys-backend/ChangeLog Thu May 10 06:01:17 2012 +0000 +++ b/flys-backend/ChangeLog Thu May 10 11:05:25 2012 +0000 @@ -1,3 +1,20 @@ +2012-05-10 Ingo Weinzierl + + * src/main/java/de/intevation/flys/model/HydrBoundary.java, + src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java: New. + Hydrological boundaries. + + * src/main/java/de/intevation/flys/model/Line.java: Modified signature of + Line.getLines(). It now also takes the name of a line to retrieve more + specific lines. + + * src/main/java/de/intevation/flys/model/Building.java: Modified signature + of Building.getBuildings(). It now also takes the name of a building to + retrieve more specific lines. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered HydrBoundary and HydrBoundaryPoly classes. + 2012-05-10 Ingo Weinzierl * contrib/shpimporter/crosssectiontracks.py: Search for 'STATION' field in diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java --- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Thu May 10 06:01:17 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Thu May 10 11:05:25 2012 +0000 @@ -52,6 +52,8 @@ import de.intevation.flys.model.Gauge; import de.intevation.flys.model.GrainFraction; import de.intevation.flys.model.Hws; +import de.intevation.flys.model.HydrBoundary; +import de.intevation.flys.model.HydrBoundaryPoly; import de.intevation.flys.model.HYK; import de.intevation.flys.model.HYKEntry; import de.intevation.flys.model.HYKFormation; @@ -267,6 +269,8 @@ cfg.addAnnotatedClass(Gauge.class); cfg.addAnnotatedClass(GrainFraction.class); cfg.addAnnotatedClass(Hws.class); + cfg.addAnnotatedClass(HydrBoundary.class); + cfg.addAnnotatedClass(HydrBoundaryPoly.class); cfg.addAnnotatedClass(HYK.class); cfg.addAnnotatedClass(HYKEntry.class); cfg.addAnnotatedClass(HYKFormation.class); diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/src/main/java/de/intevation/flys/model/Building.java --- a/flys-backend/src/main/java/de/intevation/flys/model/Building.java Thu May 10 06:01:17 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Building.java Thu May 10 11:05:25 2012 +0000 @@ -80,12 +80,13 @@ } - public static List getBuildings(int riverId) { + public static List getBuildings(int riverId, String name) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( - "from Building where river.id =:river_id"); + "from Building where river.id =:river_id and name=:name"); query.setParameter("river_id", riverId); + query.setParameter("name", name); return query.list(); } diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java Thu May 10 11:05:25 2012 +0000 @@ -0,0 +1,94 @@ +package de.intevation.flys.model; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.hibernate.Session; +import org.hibernate.Query; +import org.hibernate.annotations.Type; + +import com.vividsolutions.jts.geom.LineString; + +import de.intevation.flys.backend.SessionHolder; + + +@Entity +@Table(name = "hydr_boundaries") +public class HydrBoundary +implements Serializable +{ + private Integer id; + private String name; + private River river; + private LineString geom; + + public HydrBoundary() { + } + + + @Id + @Column(name = "id") + public Integer getId() { + return id; + } + + + public void setId(Integer id) { + this.id = id; + } + + + @OneToOne + @JoinColumn(name = "river_id") + public River getRiver() { + return river; + } + + + public void setRiver(River river) { + this.river = river; + } + + + @Column(name = "name") + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Column(name = "geom") + @Type(type = "org.hibernatespatial.GeometryUserType") + public LineString getGeom() { + return geom; + } + + + public void setGeom(LineString geom) { + this.geom = geom; + } + + + public static List getHydrBoundaries(int riverId, String name) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from HydrBoundary where river.id =:river_id and name=:name"); + query.setParameter("river_id", riverId); + query.setParameter("name", name); + + return query.list(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java Thu May 10 11:05:25 2012 +0000 @@ -0,0 +1,94 @@ +package de.intevation.flys.model; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.hibernate.Session; +import org.hibernate.Query; +import org.hibernate.annotations.Type; + +import com.vividsolutions.jts.geom.Geometry; + +import de.intevation.flys.backend.SessionHolder; + + +@Entity +@Table(name = "hydr_boundaries_poly") +public class HydrBoundaryPoly +implements Serializable +{ + private Integer id; + private String name; + private River river; + private Geometry geom; + + public HydrBoundaryPoly() { + } + + + @Id + @Column(name = "id") + public Integer getId() { + return id; + } + + + public void setId(Integer id) { + this.id = id; + } + + + @OneToOne + @JoinColumn(name = "river_id") + public River getRiver() { + return river; + } + + + public void setRiver(River river) { + this.river = river; + } + + + @Column(name = "name") + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Column(name = "geom") + @Type(type = "org.hibernatespatial.GeometryUserType") + public Geometry getGeom() { + return geom; + } + + + public void setGeom(Geometry geom) { + this.geom = geom; + } + + + public static List getHydrBoundaries(int riverId, String name) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from HydrBoundaryPoly where river.id =:river_id and name=:name"); + query.setParameter("river_id", riverId); + query.setParameter("name", name); + + return query.list(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 6442b30d80ec -r b6f94c5db89e flys-backend/src/main/java/de/intevation/flys/model/Line.java --- a/flys-backend/src/main/java/de/intevation/flys/model/Line.java Thu May 10 06:01:17 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Line.java Thu May 10 11:05:25 2012 +0000 @@ -94,12 +94,13 @@ } - public static List getLines(int riverId) { + public static List getLines(int riverId, String name) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( - "from Line where river.id =:river_id"); + "from Line where river.id =:river_id and name=:name"); query.setParameter("river_id", riverId); + query.setParameter("name", name); return query.list(); }