Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5477:ae60bb7b8085
Add proper handling of multiple river_axes for datacage and rivermapfile
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 27 Mar 2013 18:31:31 +0100 |
parents | 9d36ddf7dbd3 |
children |
comparison
equal
deleted
inserted
replaced
5476:f9eee1909e6e | 5477:ae60bb7b8085 |
---|---|
32 implements Serializable | 32 implements Serializable |
33 { | 33 { |
34 private Integer id; | 34 private Integer id; |
35 private AxisKind kind; | 35 private AxisKind kind; |
36 private River river; | 36 private River river; |
37 private String name; | |
37 private MultiLineString geom; | 38 private MultiLineString geom; |
38 | 39 |
39 public static final int KIND_UNKOWN = 0; | 40 public static final int KIND_UNKOWN = 0; |
40 public static final int KIND_CURRENT = 1; | 41 public static final int KIND_CURRENT = 1; |
41 public static final int KIND_OTHER = 2; | 42 public static final int KIND_OTHER = 2; |
65 | 66 |
66 public void setRiver(River river) { | 67 public void setRiver(River river) { |
67 this.river = river; | 68 this.river = river; |
68 } | 69 } |
69 | 70 |
71 @Column(name = "name") | |
72 public String getName() { | |
73 return name; | |
74 } | |
75 | |
76 | |
77 public void setName(String name) { | |
78 this.name = name; | |
79 } | |
70 | 80 |
71 /** | 81 /** |
72 * Get kind. | 82 * Get kind. |
73 * | 83 * |
74 * @return kind as AxisKind. | 84 * @return kind as AxisKind. |
104 public static List<RiverAxis> getRiverAxis(String river) | 114 public static List<RiverAxis> getRiverAxis(String river) |
105 throws IllegalArgumentException { | 115 throws IllegalArgumentException { |
106 return getRiverAxis(river, KIND_CURRENT); | 116 return getRiverAxis(river, KIND_CURRENT); |
107 } | 117 } |
108 | 118 |
119 public static List<RiverAxis> getRiverAxis(String river, String name, int kind) | |
120 throws HibernateException { | |
121 Session session = SessionHolder.HOLDER.get(); | |
122 Query query = session.createQuery( | |
123 "from RiverAxis as ax where river.name =:river" + | |
124 " and kind.id =:kind" + | |
125 " and ax.name=:name"); | |
126 query.setParameter("river", river); | |
127 query.setParameter("kind", kind); | |
128 query.setParameter("name", name); | |
129 | |
130 List<RiverAxis> list = query.list(); | |
131 return list.isEmpty() ? null : list; | |
132 } | |
133 | |
109 public static List<RiverAxis> getRiverAxis(String river, int kind) | 134 public static List<RiverAxis> getRiverAxis(String river, int kind) |
110 throws HibernateException { | 135 throws HibernateException { |
111 Session session = SessionHolder.HOLDER.get(); | 136 Session session = SessionHolder.HOLDER.get(); |
112 Query query = session.createQuery( | 137 Query query = session.createQuery( |
113 "from RiverAxis where river.name =:river AND kind.id =:kind"); | 138 "from RiverAxis where river.name =:river AND kind.id =:kind"); |