Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java @ 5745:ed9d7e360658
Merged.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Apr 2013 15:00:38 +0200 |
parents | 23d8f2700b38 |
children |
rev | line source |
---|---|
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import javax.persistence.Column; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import javax.persistence.Entity; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import javax.persistence.Id; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import javax.persistence.JoinColumn; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import javax.persistence.OneToOne; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import javax.persistence.Table; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import org.hibernate.Query; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.hibernate.Session; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import org.hibernate.annotations.Type; |
5496
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
16 import org.hibernate.HibernateException; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
2361
e9b0fd1de89d
Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
18 import com.vividsolutions.jts.geom.Polygon; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.backend.SessionHolder; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 @Entity |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 @Table(name = "floodplain") |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 public class Floodplain |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 implements Serializable |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 { |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
28 private Integer id; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
30 private FloodplainKind kind; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
32 private River river; |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
33 |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
34 private Polygon geom; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
5496
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
36 private String name; |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
37 |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 public Floodplain() { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 @Id |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 @Column(name = "id") |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 public Integer getId() { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 return id; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 public void setId(Integer id) { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 this.id = id; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 @OneToOne |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 @JoinColumn(name = "river_id") |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 public River getRiver() { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 return river; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 public void setRiver(River river) { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 this.river = river; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
63 @OneToOne |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
64 @JoinColumn(name = "kind_id") |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
65 public FloodplainKind getKind() { |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
66 return kind; |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
67 } |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
68 |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
69 public void setKind(FloodplainKind kind) { |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
70 this.kind = kind; |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
71 } |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
72 |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 @Column(name = "geom") |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 @Type(type = "org.hibernatespatial.GeometryUserType") |
2361
e9b0fd1de89d
Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
75 public Polygon getGeom() { |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 return geom; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
2361
e9b0fd1de89d
Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
79 public void setGeom(Polygon geom) { |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 this.geom = geom; |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
5496
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
83 @Column(name = "name") |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
84 public String getName() { |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
85 return name; |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
86 } |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
87 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
88 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
89 public void setName(String name) { |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
90 this.name = name; |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
91 } |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
92 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
93 public static List<Floodplain> getFloodplains(String river, String name, int kind) |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
94 throws HibernateException { |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
95 Session session = SessionHolder.HOLDER.get(); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
96 Query query = session.createQuery( |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
97 "from Floodplain as fp where river.name =:river" + |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
98 " and kind.id =:kind" + |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
99 " and fp.name=:name"); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
100 query.setParameter("river", river); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
101 query.setParameter("kind", kind); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
102 query.setParameter("name", name); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
103 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
104 List<Floodplain> list = query.list(); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
105 return list.isEmpty() ? null : list; |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
106 } |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
107 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
108 public static List<Floodplain> getFloodplains(String river, int kind) |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
109 throws HibernateException { |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
110 Session session = SessionHolder.HOLDER.get(); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
111 Query query = session.createQuery( |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
112 "from Floodplain where river.name =:river AND kind.id =:kind"); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
113 query.setParameter("river", river); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
114 query.setParameter("kind", kind); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
115 |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
116 List<Floodplain> list = query.list(); |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
117 return list.isEmpty() ? null : list; |
23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
5242
diff
changeset
|
118 } |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 public static Floodplain getFloodplain(String river) { |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 Session session = SessionHolder.HOLDER.get(); |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
123 // kind_id 0 -> Offical |
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
124 // kind_id 1 -> Misc. |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 Query query = session.createQuery( |
5242
88e3473a3846
Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents:
2361
diff
changeset
|
126 "from Floodplain where river.name =:river and kind_id=1"); |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 query.setParameter("river", river); |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 List<Floodplain> result = query.list(); |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 return result.isEmpty() ? null : result.get(0); |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 } |
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |