annotate flys-backend/src/main/java/de/intevation/flys/model/GaugeLocation.java @ 2875:444e52222941

Added lower and upper km to functions that return bed height singles and epochs for a given river. flys-backend/trunk@4442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 18 May 2012 12:31:26 +0000
parents e29781310140
children 8f905390c10d
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
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.Serializable;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.math.BigDecimal;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.util.List;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import javax.persistence.Column;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import javax.persistence.Entity;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import javax.persistence.Id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import javax.persistence.JoinColumn;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import javax.persistence.OneToOne;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import javax.persistence.Table;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.hibernate.Session;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.hibernate.Query;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 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
17
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import com.vividsolutions.jts.geom.Point;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.backend.SessionHolder;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
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 @Entity
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 @Table(name = "gauge_location")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 public class GaugeLocation
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 implements Serializable
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 private Integer id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 private River river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private String name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private Point geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
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 public GaugeLocation() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 }
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 @Id
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 @Column(name = "id")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public Integer getId() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 return id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 }
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 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
46 this.id = id;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 }
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 @OneToOne
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 @JoinColumn(name = "river_id")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public River getRiver() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 return river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 }
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 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
58 this.river = river;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 }
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 @Column(name = "name")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 public String getName() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 return name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 }
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 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
69 this.name = name;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
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 @Column(name = "geom")
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 @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
75 public Point getGeom() {
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 return geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
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 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
81 this.geom = geom;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
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 * 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
87 *
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 * @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
89 *
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 * @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
91 */
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 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
93 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
94
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 Query query = session.createQuery(
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 "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
97 query.setParameter("riverid", riverid);
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 query.setParameter("name", name);
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 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
101
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 return list;
e29781310140 Added new model class GaugeLocation for storing locations of gauges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org