Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java @ 471:3570e4af8cb2
Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
flys-backend/trunk@1710 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 16:06:15 +0000 |
parents | 29a408f80a89 |
children | db430bd9e0e0 |
comparison
equal
deleted
inserted
replaced
470:f4afea9b7537 | 471:3570e4af8cb2 |
---|---|
15 public class ImportWstColumn | 15 public class ImportWstColumn |
16 { | 16 { |
17 protected ImportWst wst; | 17 protected ImportWst wst; |
18 protected String name; | 18 protected String name; |
19 protected String description; | 19 protected String description; |
20 protected Integer position; | |
20 | 21 |
21 protected List<ImportWstColumnQRange> columnQRanges; | 22 protected List<ImportWstColumnQRange> columnQRanges; |
22 protected List<ImportWstColumnValue> columnValues; | 23 protected List<ImportWstColumnValue> columnValues; |
23 | 24 |
24 protected WstColumn peer; | 25 protected WstColumn peer; |
29 } | 30 } |
30 | 31 |
31 public ImportWstColumn( | 32 public ImportWstColumn( |
32 ImportWst wst, | 33 ImportWst wst, |
33 String name, | 34 String name, |
34 String description | 35 String description, |
36 Integer position | |
35 ) { | 37 ) { |
36 this(); | 38 this(); |
37 this.wst = wst; | 39 this.wst = wst; |
38 this.name = name; | 40 this.name = name; |
39 this.description = description; | 41 this.description = description; |
42 this.position = position; | |
40 } | 43 } |
41 | 44 |
42 public ImportWst getWst() { | 45 public ImportWst getWst() { |
43 return wst; | 46 return wst; |
44 } | 47 } |
59 return description; | 62 return description; |
60 } | 63 } |
61 | 64 |
62 public void setDescription(String description) { | 65 public void setDescription(String description) { |
63 this.description = description; | 66 this.description = description; |
67 } | |
68 | |
69 public Integer getPosition() { | |
70 return position; | |
71 } | |
72 | |
73 public void setPosition(Integer position) { | |
74 this.position = position; | |
64 } | 75 } |
65 | 76 |
66 public void addColumnValue(BigDecimal position, BigDecimal w) { | 77 public void addColumnValue(BigDecimal position, BigDecimal w) { |
67 columnValues.add( | 78 columnValues.add( |
68 new ImportWstColumnValue(this, position, w)); | 79 new ImportWstColumnValue(this, position, w)); |
87 if (peer == null) { | 98 if (peer == null) { |
88 Wst w = wst.getPeer(river); | 99 Wst w = wst.getPeer(river); |
89 Session session = Importer.sessionHolder.get(); | 100 Session session = Importer.sessionHolder.get(); |
90 Query query = session.createQuery( | 101 Query query = session.createQuery( |
91 "from WstColumn where " + | 102 "from WstColumn where " + |
92 "wst=:wst and name=:name and description=:description"); | 103 "wst=:wst and name=:name and description=:description" + |
104 " and position=:position"); | |
93 query.setParameter("wst", w); | 105 query.setParameter("wst", w); |
94 query.setParameter("name", name); | 106 query.setParameter("name", name); |
95 query.setParameter("description", description); | 107 query.setParameter("description", description); |
108 query.setParameter("position", position); | |
96 List<WstColumn> columns = query.list(); | 109 List<WstColumn> columns = query.list(); |
97 if (columns.isEmpty()) { | 110 if (columns.isEmpty()) { |
98 peer = new WstColumn(w, name, description, null); | 111 peer = new WstColumn(w, name, description, position, null); |
99 session.save(peer); | 112 session.save(peer); |
100 } | 113 } |
101 else { | 114 else { |
102 peer = columns.get(0); | 115 peer = columns.get(0); |
103 } | 116 } |