comparison flys-backend/src/main/java/de/intevation/flys/model/GaugeLocation.java @ 2877:f0a67bc0e777 2.7

merged flys-backend/2.7
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:31 +0200
parents e29781310140
children 8f905390c10d
comparison
equal deleted inserted replaced
2793:6310b1582f2d 2877:f0a67bc0e777
1 package de.intevation.flys.model;
2
3 import java.io.Serializable;
4 import java.math.BigDecimal;
5 import java.util.List;
6
7 import javax.persistence.Column;
8 import javax.persistence.Entity;
9 import javax.persistence.Id;
10 import javax.persistence.JoinColumn;
11 import javax.persistence.OneToOne;
12 import javax.persistence.Table;
13
14 import org.hibernate.Session;
15 import org.hibernate.Query;
16 import org.hibernate.annotations.Type;
17
18 import com.vividsolutions.jts.geom.Point;
19
20 import de.intevation.flys.backend.SessionHolder;
21
22
23 @Entity
24 @Table(name = "gauge_location")
25 public class GaugeLocation
26 implements Serializable
27 {
28 private Integer id;
29 private River river;
30 private String name;
31 private Point geom;
32
33
34 public GaugeLocation() {
35 }
36
37
38 @Id
39 @Column(name = "id")
40 public Integer getId() {
41 return id;
42 }
43
44
45 public void setId(Integer id) {
46 this.id = id;
47 }
48
49
50 @OneToOne
51 @JoinColumn(name = "river_id")
52 public River getRiver() {
53 return river;
54 }
55
56
57 public void setRiver(River river) {
58 this.river = river;
59 }
60
61
62 @Column(name = "name")
63 public String getName() {
64 return name;
65 }
66
67
68 public void setName(String name) {
69 this.name = name;
70 }
71
72
73 @Column(name = "geom")
74 @Type(type = "org.hibernatespatial.GeometryUserType")
75 public Point getGeom() {
76 return geom;
77 }
78
79
80 public void setGeom(Point geom) {
81 this.geom = geom;
82 }
83
84
85 /**
86 * Returns a list of RiverAxisKm objects for a given river.
87 *
88 * @param riverid The ID of a river in the database.
89 *
90 * @return a list of RiverAxisKm objects.
91 */
92 public static List<GaugeLocation> getGaugeLocations(int riverid, String name) {
93 Session session = SessionHolder.HOLDER.get();
94
95 Query query = session.createQuery(
96 "from GaugeLocation where river.id =:riverid and name=:name");
97 query.setParameter("riverid", riverid);
98 query.setParameter("name", name);
99
100 List<GaugeLocation> list = query.list();
101
102 return list;
103 }
104 }
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org