annotate flys-backend/src/main/java/de/intevation/flys/model/GaugeLocation.java @ 5590:b75005269a6c

Datacage: Fix potential connection leak to SedDB.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 08 Apr 2013 12:07:43 +0200
parents 8f905390c10d
children
rev   line source
2869
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
3320
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
3 import com.vividsolutions.jts.geom.Point;
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
4
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
5 import de.intevation.flys.backend.SessionHolder;
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
6
2869
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.io.Serializable;
3320
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
8
2869
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.List;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import javax.persistence.Column;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import javax.persistence.Entity;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import javax.persistence.Id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import javax.persistence.JoinColumn;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import javax.persistence.OneToOne;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import javax.persistence.Table;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
3320
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
18 import org.hibernate.Query;
2869
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.hibernate.Session;
3320
8f905390c10d Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2869
diff changeset
20
2869
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import org.hibernate.annotations.Type;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 @Entity
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 @Table(name = "gauge_location")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 public class GaugeLocation
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 implements Serializable
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 private Integer id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private River river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private String name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 private Point geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public GaugeLocation() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 @Id
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 @Column(name = "id")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public Integer getId() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 return id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public void setId(Integer id) {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 this.id = id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 @OneToOne
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 @JoinColumn(name = "river_id")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public River getRiver() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 return river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public void setRiver(River river) {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 this.river = river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 @Column(name = "name")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 public String getName() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 return name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 public void setName(String name) {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 this.name = name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 @Column(name = "geom")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 @Type(type = "org.hibernatespatial.GeometryUserType")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 public Point getGeom() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 return geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 public void setGeom(Point geom) {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 this.geom = geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 /**
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 * Returns a list of RiverAxisKm objects for a given river.
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 *
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 * @param riverid The ID of a river in the database.
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 *
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 * @return a list of RiverAxisKm objects.
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 */
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 public static List<GaugeLocation> getGaugeLocations(int riverid, String name) {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 Session session = SessionHolder.HOLDER.get();
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 Query query = session.createQuery(
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 "from GaugeLocation where river.id =:riverid and name=:name");
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 query.setParameter("riverid", riverid);
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 query.setParameter("name", name);
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 List<GaugeLocation> list = query.list();
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 return list;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org