annotate flys-backend/src/main/java/de/intevation/flys/model/Jetty.java @ 5509:627584bc0586

Datacage: Added <dc:filter> element. This allows cleaner way to narrow the datasets. Example: <dc:context> <dc:statement> SELECT DISTINCT name AS hws_name, official AS hws_official, kind_id AS hws_kind FROM hws_lines WHERE river_id = ${river_id} </dc:statement> <dc:if test="dc:has-result()"> <lines> <dc:macro name="hws-lines"> <dc:elements> <hws factory="hwsfactory" name="{$hws_name}"/> </dc:elements> </dc:macro> <dc:filter expr="$hws_official=1"> <dc:if test="dc:has-result()"> <official> <dc:filter expr="$hws_kind=1"> <dc:if test="dc:has-result()"> <Durchlass><dc:call-macro name="hws-lines"></Durchlass> </dc:if> </dc:filter> <dc:filter expr="$hws_kind=2"> <dc:if test="dc:has-result()"> <Damm><dc:call-macro name="hws-lines"></Damm> </dc:if> </dc:filter> <dc:filter expr="$hws_kind=3"> <dc:if test="dc:has-result()"> <Graben><dc:call-macro name="hws-lines"></Graben> </dc:if> </dc:filter> </official> </dc:if> </dc:filter> </lines> </dc:if> </dc:context>
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 28 Mar 2013 16:51:15 +0100
parents b582df0c7b00
children
rev   line source
5437
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 import java.io.Serializable;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 import java.util.List;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 import javax.persistence.Column;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 import javax.persistence.Entity;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 import javax.persistence.Id;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 import javax.persistence.JoinColumn;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10 import javax.persistence.OneToOne;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 import javax.persistence.Table;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 import com.vividsolutions.jts.geom.Geometry;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 import org.hibernate.Session;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.hibernate.Query;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 import org.hibernate.annotations.Type;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.backend.SessionHolder;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 @Entity
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 @Table(name = "jetties")
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 public class Jetty
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 implements Serializable
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 private Integer id;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 private River river;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 private Geometry geom;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 public Jetty() {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 @Id
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 @Column(name = "id")
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 public Integer getId() {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 return id;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 public void setId(Integer id) {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 this.id = id;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 @OneToOne
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 @JoinColumn(name = "river_id")
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 public River getRiver() {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 return river;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 public void setRiver(River river) {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 this.river = river;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 @Column(name = "geom")
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 @Type(type = "org.hibernatespatial.GeometryUserType")
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 public Geometry getGeom() {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 return geom;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 public void setGeom(Geometry geom) {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 this.geom = geom;
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 public static List<Jetty> getJetties(int riverId, int kindId) {
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 Session session = SessionHolder.HOLDER.get();
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 Query query = session.createQuery(
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 "from Jetty where river.id =:river_id and kind_id=:kind_id");
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 query.setParameter("kind_id", kindId);
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 query.setParameter("river_id", riverId);
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 return query.list();
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 }
b582df0c7b00 Add Jetties to floodmap
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org