annotate flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java @ 5745:ed9d7e360658

Merged.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 15:00:38 +0200
parents c8e74e5e828c
children
rev   line source
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.Serializable;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.math.BigDecimal;
1235
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
5 import java.util.List;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import javax.persistence.Column;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import javax.persistence.Entity;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import javax.persistence.Id;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import javax.persistence.JoinColumn;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import javax.persistence.OneToOne;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import javax.persistence.Table;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
1235
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
14 import org.hibernate.Query;
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
15 import org.hibernate.Session;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.hibernate.annotations.Type;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import com.vividsolutions.jts.geom.LineString;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
1235
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
20 import de.intevation.flys.backend.SessionHolder;
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
21
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 @Entity
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 @Table(name = "cross_section_tracks")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 public class CrossSectionTrack
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 implements Serializable
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 private Integer id;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 private River river;
3330
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
30 private String name;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private LineString geom;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 private BigDecimal km;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 private BigDecimal z;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public CrossSectionTrack() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 @Id
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 @Column(name = "id")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public Integer getId() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 return id;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public void setId(Integer id) {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 this.id = id;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 @OneToOne
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 @JoinColumn(name = "river_id")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public River getRiver() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 return river;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public void setRiver(River river) {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 this.river = river;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
3330
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
63 @Column(name = "name")
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
64 public String getName() {
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
65 return name;
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
66 }
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
67
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
68
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
69 public void setName(String name) {
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
70 this.name = name;
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
71 }
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
72
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
73
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 @Column(name = "geom")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 @Type(type = "org.hibernatespatial.GeometryUserType")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 public LineString getGeom() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 return geom;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 public void setGeom(LineString geom) {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 this.geom = geom;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 @Column(name = "km")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 public BigDecimal getKm() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 return km;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 public void setKm(BigDecimal km) {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 this.km = km;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 @Column(name = "z")
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 public BigDecimal getZ() {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 return z;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 public void setZ(BigDecimal z) {
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 this.z = z;
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
1235
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
106
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
107
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
108 public static List<CrossSectionTrack> getCrossSectionTrack(
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
109 String river)
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
110 {
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
111 Session session = SessionHolder.HOLDER.get();
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
112
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
113 Query query = session.createQuery(
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
114 "from CrossSectionTrack where river.name =:river");
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
115 query.setParameter("river", river);
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
116
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
117 return query.list();
47ce1fab8464 Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
118 }
2341
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
119
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
120
3330
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
121 public static List<CrossSectionTrack> getCrossSectionTrack(
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
122 String river,
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
123 String name
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
124 ) {
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
125 Session session = SessionHolder.HOLDER.get();
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
126
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
127 Query query = session.createQuery(
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
128 "from CrossSectionTrack as cst " +
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
129 " where river.name =:river" +
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
130 " and cst.name=:name");
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
131 query.setParameter("river", river);
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
132 query.setParameter("name", name);
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
133
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
134 return query.list();
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
135 }
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
136
5465
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
137 public static List<CrossSectionTrack> getCrossSectionTrack(
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
138 String river,
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
139 int kind_id
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
140 ) {
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
141 Session session = SessionHolder.HOLDER.get();
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
142
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
143 Query query = session.createQuery(
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
144 "from CrossSectionTrack as cst " +
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
145 " where river.name =:river" +
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
146 " and kind_id=:kind_id");
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
147 query.setParameter("river", river);
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
148 query.setParameter("kind_id", kind_id);
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
149
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
150 return query.list();
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
151 }
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
152
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
153 public static List<CrossSectionTrack> getCrossSectionTrack(
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
154 String river,
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
155 String name,
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
156 int kind_id
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
157 ) {
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
158 Session session = SessionHolder.HOLDER.get();
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
159
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
160 Query query = session.createQuery(
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
161 "from CrossSectionTrack as cst " +
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
162 " where river.name =:river" +
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
163 " and cst.name=:name" +
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
164 " and kind_id=:kind_id");
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
165 query.setParameter("river", river);
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
166 query.setParameter("name", name);
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
167 query.setParameter("kind_id", kind_id);
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
168
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
169 return query.list();
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
170 }
c8e74e5e828c Add crosssection track accessors that filter by kind and by kind and name
Andre Heinecke <aheinecke@intevation.de>
parents: 5242
diff changeset
171
3330
d42249d91f47 Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2341
diff changeset
172
2341
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
173 /**
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
174 * Returns the nearest CrossSectionTrack of <i>river</i> to a given
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
175 * <i>km</i>.
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
176 *
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
177 * @param river The name of a river.
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
178 * @param km The kilometer value.
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
179 *
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
180 * @return the nearest CrossSectionTrack to <i>km</i> of river <i>river</i>.
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
181 */
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
182 public static CrossSectionTrack getCrossSectionTrack(
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
183 String river,
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
184 double km
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
185 ) {
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
186 Session session = SessionHolder.HOLDER.get();
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
187
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
188 Query query = session.createQuery(
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
189 "from CrossSectionTrack where river.name =:river " +
5242
88e3473a3846 Add kind handling for floodplains and crossectiontracks
Andre Heinecke <aheinecke@intevation.de>
parents: 3330
diff changeset
190 "and kind_id = 1 " +
2341
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
191 "order by abs( km - :mykm)");
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
192 query.setParameter("river", river);
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
193 query.setParameter("mykm", new BigDecimal(km));
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
194
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
195 List<CrossSectionTrack> cst = query.list();
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
196
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
197 return cst != null && !cst.isEmpty() ? cst.get(0) : null;
8e2fe935ddf1 Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1235
diff changeset
198 }
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 }
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org