Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportGauge.java @ 192:f1fce41347ea
Added missing ImportGauge.getPeer() method
flys-backend/trunk@1530 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 21 Mar 2011 10:27:14 +0000 |
parents | c4fb5141ce11 |
children | 31c48d54f09d |
comparison
equal
deleted
inserted
replaced
191:c4fb5141ce11 | 192:f1fce41347ea |
---|---|
1 package de.intevation.flys.importer; | 1 package de.intevation.flys.importer; |
2 | 2 |
3 import java.io.File; | 3 import java.io.File; |
4 | |
5 import java.util.List; | |
4 | 6 |
5 import java.math.BigDecimal; | 7 import java.math.BigDecimal; |
6 | 8 |
7 import de.intevation.flys.model.River; | 9 import de.intevation.flys.model.River; |
8 import de.intevation.flys.model.Gauge; | 10 import de.intevation.flys.model.Gauge; |
11 | |
12 import org.hibernate.Session; | |
13 import org.hibernate.Query; | |
9 | 14 |
10 import java.io.IOException; | 15 import java.io.IOException; |
11 | 16 |
12 public class ImportGauge | 17 public class ImportGauge |
13 { | 18 { |
17 protected File atFile; | 22 protected File atFile; |
18 | 23 |
19 protected String name; | 24 protected String name; |
20 protected BigDecimal aeo; | 25 protected BigDecimal aeo; |
21 protected BigDecimal datum; | 26 protected BigDecimal datum; |
27 protected BigDecimal station; | |
22 | 28 |
23 protected Gauge peer; | 29 protected Gauge peer; |
24 | 30 |
25 public ImportGauge() { | 31 public ImportGauge() { |
26 } | 32 } |
73 | 79 |
74 public void setDatum(BigDecimal datum) { | 80 public void setDatum(BigDecimal datum) { |
75 this.datum = datum; | 81 this.datum = datum; |
76 } | 82 } |
77 | 83 |
84 public BigDecimal getStation() { | |
85 return station; | |
86 } | |
87 | |
88 public void setStation(BigDecimal station) { | |
89 this.station = station; | |
90 } | |
91 | |
78 public void parseDependencies() throws IOException { | 92 public void parseDependencies() throws IOException { |
79 StaFileParser sfp = new StaFileParser(); | 93 StaFileParser sfp = new StaFileParser(); |
80 sfp.parse(this); | 94 sfp.parse(this); |
81 } | 95 } |
82 | 96 |
83 public void storeDependencies(River river) { | 97 public void storeDependencies(River river) { |
98 Gauge gauge = getPeer(river); | |
84 // TODO: Implement me! | 99 // TODO: Implement me! |
85 } | 100 } |
86 | 101 |
87 public Gauge getPeer(River river) { | 102 public Gauge getPeer(River river) { |
88 if (peer == null) { | 103 if (peer == null) { |
104 Session session = Importer.sessionHolder.get(); | |
105 Query query = session.createQuery( | |
106 "from Gauge where name=:name " + | |
107 "and river.id=:id"); | |
108 query.setString("name", name); | |
109 query.setInteger("id", river.getId()); | |
110 List<Gauge> gauges = query.list(); | |
111 if (gauges.isEmpty()) { | |
112 peer = new Gauge( | |
113 name, river, | |
114 station, aeo, datum, | |
115 range.getPeer(river)); | |
116 session.save(peer); | |
117 } | |
118 else { | |
119 peer = gauges.get(0); | |
120 } | |
89 } | 121 } |
90 return peer; | 122 return peer; |
91 } | 123 } |
92 } | 124 } |
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 125 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |