Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java @ 6504:7664ab97b4c7
Backend: Store source of a wst column if available.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 17:00:55 +0200 |
parents | 4c3ccf2b0304 |
children | 1c68d4b2a1c0 |
comparison
equal
deleted
inserted
replaced
6501:7cb247824ed1 | 6504:7664ab97b4c7 |
---|---|
31 | 31 |
32 protected ImportWst wst; | 32 protected ImportWst wst; |
33 protected String name; | 33 protected String name; |
34 protected String description; | 34 protected String description; |
35 protected Integer position; | 35 protected Integer position; |
36 protected String source; | |
36 | 37 |
37 protected ImportTimeInterval timeInterval; | 38 protected ImportTimeInterval timeInterval; |
38 | 39 |
39 protected List<ImportWstColumnQRange> columnQRanges; | 40 protected List<ImportWstColumnQRange> columnQRanges; |
40 protected List<ImportWstColumnValue> columnValues; | 41 protected List<ImportWstColumnValue> columnValues; |
48 | 49 |
49 public ImportWstColumn( | 50 public ImportWstColumn( |
50 ImportWst wst, | 51 ImportWst wst, |
51 String name, | 52 String name, |
52 String description, | 53 String description, |
53 Integer position | 54 Integer position, |
55 String source | |
54 ) { | 56 ) { |
55 this(); | 57 this(); |
56 this.wst = wst; | 58 this.wst = wst; |
57 this.name = name; | 59 this.name = name; |
58 this.description = description; | 60 this.description = description; |
59 this.position = position; | 61 this.position = position; |
62 } | |
63 | |
64 public ImportWstColumn( | |
65 ImportWst wst, | |
66 String name, | |
67 String description, | |
68 Integer position | |
69 ) { | |
70 this(wst, name, description, position, null); | |
60 } | 71 } |
61 | 72 |
62 public ImportWst getWst() { | 73 public ImportWst getWst() { |
63 return wst; | 74 return wst; |
64 } | 75 } |
87 return position; | 98 return position; |
88 } | 99 } |
89 | 100 |
90 public void setPosition(Integer position) { | 101 public void setPosition(Integer position) { |
91 this.position = position; | 102 this.position = position; |
103 } | |
104 | |
105 public String getSource() { | |
106 return source; | |
107 } | |
108 | |
109 public void setSource(String source) { | |
110 this.source = source; | |
92 } | 111 } |
93 | 112 |
94 public void addColumnValue(BigDecimal position, BigDecimal w) { | 113 public void addColumnValue(BigDecimal position, BigDecimal w) { |
95 columnValues.add( | 114 columnValues.add( |
96 new ImportWstColumnValue(this, position, w)); | 115 new ImportWstColumnValue(this, position, w)); |
133 public WstColumn getPeer(River river) { | 152 public WstColumn getPeer(River river) { |
134 if (peer == null) { | 153 if (peer == null) { |
135 Wst w = wst.getPeer(river); | 154 Wst w = wst.getPeer(river); |
136 Session session = ImporterSession.getInstance().getDatabaseSession(); | 155 Session session = ImporterSession.getInstance().getDatabaseSession(); |
137 Query query = session.createQuery( | 156 Query query = session.createQuery( |
138 "from WstColumn where " + | 157 "from WstColumn where" + |
139 "wst=:wst and name=:name " + | 158 " wst=:wst and name=:name" + |
159 " and source=:source" + | |
140 " and position=:position"); | 160 " and position=:position"); |
141 query.setParameter("wst", w); | 161 query.setParameter("wst", w); |
142 query.setParameter("name", name); | 162 query.setParameter("name", name); |
143 query.setParameter("position", position); | 163 query.setParameter("position", position); |
164 query.setParameter("source", source); | |
144 | 165 |
145 TimeInterval ti = timeInterval != null | 166 TimeInterval ti = timeInterval != null |
146 ? timeInterval.getPeer() | 167 ? timeInterval.getPeer() |
147 : null; | 168 : null; |
148 | 169 |
149 List<WstColumn> columns = query.list(); | 170 List<WstColumn> columns = query.list(); |
150 if (columns.isEmpty()) { | 171 if (columns.isEmpty()) { |
151 peer = new WstColumn(w, name, description, position, ti); | 172 peer = new WstColumn( |
173 w, name, description, source, position, ti); | |
152 session.save(peer); | 174 session.save(peer); |
153 } | 175 } |
154 else { | 176 else { |
155 peer = columns.get(0); | 177 peer = columns.get(0); |
156 } | 178 } |