comparison flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java @ 5242:88e3473a3846 2.9.12

Add kind handling for floodplains and crossectiontracks getFloodplain / getCrossection now return only the "current" one 1 is current 0 is misc
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 12 Mar 2013 11:29:10 +0100
parents e9b0fd1de89d
children 23d8f2700b38
comparison
equal deleted inserted replaced
5241:31b464f17392 5242:88e3473a3846
22 @Entity 22 @Entity
23 @Table(name = "floodplain") 23 @Table(name = "floodplain")
24 public class Floodplain 24 public class Floodplain
25 implements Serializable 25 implements Serializable
26 { 26 {
27 private Integer id; 27 private Integer id;
28 28
29 private River river; 29 private FloodplainKind kind;
30 30
31 private Polygon geom; 31 private River river;
32
33 private Polygon geom;
32 34
33 35
34 public Floodplain() { 36 public Floodplain() {
35 } 37 }
36 38
53 55
54 public void setRiver(River river) { 56 public void setRiver(River river) {
55 this.river = river; 57 this.river = river;
56 } 58 }
57 59
60 @OneToOne
61 @JoinColumn(name = "kind_id")
62 public FloodplainKind getKind() {
63 return kind;
64 }
65
66 public void setKind(FloodplainKind kind) {
67 this.kind = kind;
68 }
69
58 @Column(name = "geom") 70 @Column(name = "geom")
59 @Type(type = "org.hibernatespatial.GeometryUserType") 71 @Type(type = "org.hibernatespatial.GeometryUserType")
60 public Polygon getGeom() { 72 public Polygon getGeom() {
61 return geom; 73 return geom;
62 } 74 }
67 79
68 80
69 public static Floodplain getFloodplain(String river) { 81 public static Floodplain getFloodplain(String river) {
70 Session session = SessionHolder.HOLDER.get(); 82 Session session = SessionHolder.HOLDER.get();
71 83
84 // kind_id 0 -> Offical
85 // kind_id 1 -> Misc.
72 Query query = session.createQuery( 86 Query query = session.createQuery(
73 "from Floodplain where river.name =:river"); 87 "from Floodplain where river.name =:river and kind_id=1");
74 query.setParameter("river", river); 88 query.setParameter("river", river);
75 89
76 List<Floodplain> result = query.list(); 90 List<Floodplain> result = query.list();
77 91
78 return result.isEmpty() ? null : result.get(0); 92 return result.isEmpty() ? null : result.get(0);

http://dive4elements.wald.intevation.org