Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5146:d4fdd98a04f7
Add kind_id to river_axes table and add AxisKind object to model
There are currently three kinds: 0 for unkown, 1 for current,
2 for everything else.
Only current is used for calculation
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 28 Feb 2013 18:04:19 +0100 |
parents | 18ef819a7c92 |
children | c1b60f8c3390 |
comparison
equal
deleted
inserted
replaced
5145:801175535406 | 5146:d4fdd98a04f7 |
---|---|
15 import org.hibernate.annotations.Type; | 15 import org.hibernate.annotations.Type; |
16 | 16 |
17 import com.vividsolutions.jts.geom.MultiLineString; | 17 import com.vividsolutions.jts.geom.MultiLineString; |
18 | 18 |
19 import de.intevation.flys.backend.SessionHolder; | 19 import de.intevation.flys.backend.SessionHolder; |
20 import de.intevation.flys.model.AxisKind; | |
20 | 21 |
21 | 22 |
22 /** | 23 /** |
23 * There is a modeling problem with the RiverAxis. The initial idea was, that a | 24 * A river has one axis that is used for calculation. |
24 * river can have a riveraxis that consist of exact one geometry. Now, it has | 25 * Additional axes of a river can be used to be painted int maps etc. |
25 * turned out, that a single geometry is not enough for a riveraxis (arm of a | 26 * which one is the main river axis can be determined over the axis kind. |
26 * river, inflows, ...). As workaround, we now expect, that a river can just | |
27 * have a single riveraxis. | |
28 */ | 27 */ |
29 @Entity | 28 @Entity |
30 @Table(name = "river_axes") | 29 @Table(name = "river_axes") |
31 public class RiverAxis | 30 public class RiverAxis |
32 implements Serializable | 31 implements Serializable |
33 { | 32 { |
34 private Integer id; | 33 private Integer id; |
35 private Integer kind; | 34 private AxisKind kind; |
36 private River river; | 35 private River river; |
37 private MultiLineString geom; | 36 private MultiLineString geom; |
38 | 37 |
39 public static final int DEFAULT_KIND = 0; | 38 public static final int KIND_UNKOWN = 0; |
40 | 39 public static final int KIND_CURRENT = 1; |
41 public static final int KIND_OFFICIAL = 1; | 40 public static final int KIND_OTHER = 2; |
42 public static final int KIND_OUTSOURCED = 2; | |
43 | 41 |
44 public RiverAxis() { | 42 public RiverAxis() { |
45 } | 43 } |
46 | 44 |
47 | 45 |
67 public void setRiver(River river) { | 65 public void setRiver(River river) { |
68 this.river = river; | 66 this.river = river; |
69 } | 67 } |
70 | 68 |
71 | 69 |
72 @Column(name = "kind") | 70 /** |
73 public Integer getKind() { | 71 * Get kind. |
72 * | |
73 * @return kind as AxisKind. | |
74 */ | |
75 @OneToOne | |
76 @JoinColumn(name = "kind_id") | |
77 public AxisKind getKind() { | |
74 return kind; | 78 return kind; |
75 } | 79 } |
76 | 80 |
77 | 81 /** |
78 public void setKind(Integer kind) { | 82 * Set kind. |
83 * | |
84 * @param kind the value to set. | |
85 */ | |
86 public void setKind(AxisKind kind) { | |
79 this.kind = kind; | 87 this.kind = kind; |
80 } | 88 } |
81 | 89 |
82 | 90 |
83 @Column(name = "geom") | 91 @Column(name = "geom") |
91 this.geom = geom; | 99 this.geom = geom; |
92 } | 100 } |
93 | 101 |
94 | 102 |
95 public static List<RiverAxis> getRiverAxis(String river) { | 103 public static List<RiverAxis> getRiverAxis(String river) { |
96 return getRiverAxis(river, DEFAULT_KIND); | 104 return getRiverAxis(river, KIND_CURRENT); |
97 } | 105 } |
98 | 106 |
99 public static List<RiverAxis> getRiverAxis(String river, int kind) { | 107 public static List<RiverAxis> getRiverAxis(String river, int kind) { |
100 Session session = SessionHolder.HOLDER.get(); | 108 Session session = SessionHolder.HOLDER.get(); |
101 | 109 |
102 Query query = session.createQuery( | 110 Query query = session.createQuery( |
103 "from RiverAxis where river.name =:river AND kind =:kind"); | 111 "from RiverAxis where river.name =:river AND kind.id =:kind"); |
104 query.setParameter("river", river); | 112 query.setParameter("river", river); |
105 query.setParameter("kind", kind); | 113 query.setParameter("kind", kind); |
106 | 114 |
107 List<RiverAxis> list = query.list(); | 115 List<RiverAxis> list = query.list(); |
108 | 116 |