Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Line.java @ 2365:60532f75396b
Adapted 'lines' relation and made lines queryable for a given river.
flys-backend/trunk@3219 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Nov 2011 13:35:31 +0000 |
parents | e2deda3b77a7 |
children | b6f94c5db89e |
comparison
equal
deleted
inserted
replaced
2364:efe19e669092 | 2365:60532f75396b |
---|---|
1 package de.intevation.flys.model; | 1 package de.intevation.flys.model; |
2 | 2 |
3 import java.io.Serializable; | 3 import java.io.Serializable; |
4 import java.math.BigDecimal; | 4 import java.math.BigDecimal; |
5 import java.util.List; | |
5 | 6 |
6 import javax.persistence.Column; | 7 import javax.persistence.Column; |
7 import javax.persistence.Entity; | 8 import javax.persistence.Entity; |
8 import javax.persistence.Id; | 9 import javax.persistence.Id; |
9 import javax.persistence.JoinColumn; | 10 import javax.persistence.JoinColumn; |
10 import javax.persistence.OneToOne; | 11 import javax.persistence.OneToOne; |
11 import javax.persistence.Table; | 12 import javax.persistence.Table; |
12 | 13 |
14 import org.hibernate.Session; | |
15 import org.hibernate.Query; | |
16 | |
13 import org.hibernate.annotations.Type; | 17 import org.hibernate.annotations.Type; |
14 | 18 |
15 import com.vividsolutions.jts.geom.LineString; | 19 import com.vividsolutions.jts.geom.LineString; |
20 | |
21 import de.intevation.flys.backend.SessionHolder; | |
16 | 22 |
17 | 23 |
18 @Entity | 24 @Entity |
19 @Table(name = "lines") | 25 @Table(name = "lines") |
20 public class Line | 26 public class Line |
21 implements Serializable | 27 implements Serializable |
22 { | 28 { |
23 private Integer id; | 29 private Integer id; |
24 private Integer kind; | 30 private String kind; |
25 private River river; | 31 private River river; |
26 private LineString geom; | 32 private LineString geom; |
27 private BigDecimal z; | 33 private BigDecimal z; |
28 | 34 |
29 public Line() { | 35 public Line() { |
53 this.river = river; | 59 this.river = river; |
54 } | 60 } |
55 | 61 |
56 | 62 |
57 @Column(name = "kind") | 63 @Column(name = "kind") |
58 public Integer getKind() { | 64 public String getKind() { |
59 return kind; | 65 return kind; |
60 } | 66 } |
61 | 67 |
62 | 68 |
63 public void setKind(Integer kind) { | 69 public void setKind(String kind) { |
64 this.kind = kind; | 70 this.kind = kind; |
65 } | 71 } |
66 | 72 |
67 | 73 |
68 @Column(name = "geom") | 74 @Column(name = "geom") |
84 | 90 |
85 | 91 |
86 public void setZ(BigDecimal z) { | 92 public void setZ(BigDecimal z) { |
87 this.z = z; | 93 this.z = z; |
88 } | 94 } |
95 | |
96 | |
97 public static List<Line> getLines(int riverId) { | |
98 Session session = SessionHolder.HOLDER.get(); | |
99 | |
100 Query query = session.createQuery( | |
101 "from Line where river.id =:river_id"); | |
102 query.setParameter("river_id", riverId); | |
103 | |
104 return query.list(); | |
105 } | |
89 } | 106 } |
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |