Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTable.java @ 493:b35c5dc0f8b7
Importer: Make import of historical discharge tables work.
flys-backend/trunk@1842 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 06 May 2011 10:27:32 +0000 |
parents | 14de9246b356 |
children | 67fd63e4ef66 |
comparison
equal
deleted
inserted
replaced
492:14de9246b356 | 493:b35c5dc0f8b7 |
---|---|
8 | 8 |
9 import de.intevation.flys.model.DischargeTable; | 9 import de.intevation.flys.model.DischargeTable; |
10 import de.intevation.flys.model.Gauge; | 10 import de.intevation.flys.model.Gauge; |
11 import de.intevation.flys.model.TimeInterval; | 11 import de.intevation.flys.model.TimeInterval; |
12 | 12 |
13 import org.apache.log4j.Logger; | |
14 | |
13 public class ImportDischargeTable | 15 public class ImportDischargeTable |
14 { | 16 { |
15 protected DischargeTable peer; | 17 protected DischargeTable peer; |
16 | 18 |
17 protected Integer kind; | 19 protected String description; |
20 | |
21 protected Integer kind; | |
18 | 22 |
19 protected List<ImportDischargeTableValue> dischargeTableValues; | 23 protected List<ImportDischargeTableValue> dischargeTableValues; |
20 | 24 |
21 protected ImportTimeInterval timeInterval; | 25 protected ImportTimeInterval timeInterval; |
22 | 26 |
23 public ImportDischargeTable() { | 27 public ImportDischargeTable() { |
24 this(0); | 28 this(0, null); |
25 } | 29 } |
26 | 30 |
27 public ImportDischargeTable(int kind) { | 31 public ImportDischargeTable(int kind, String description) { |
28 this.kind = kind; | 32 this.kind = kind; |
33 this.description = description; | |
29 dischargeTableValues = new ArrayList<ImportDischargeTableValue>(); | 34 dischargeTableValues = new ArrayList<ImportDischargeTableValue>(); |
35 } | |
36 | |
37 | |
38 public String getDescription() { | |
39 return description; | |
40 } | |
41 | |
42 public void setDescription(String description) { | |
43 this.description = description; | |
30 } | 44 } |
31 | 45 |
32 | 46 |
33 public void addDischargeTableValue(ImportDischargeTableValue value) { | 47 public void addDischargeTableValue(ImportDischargeTableValue value) { |
34 dischargeTableValues.add(value); | 48 dischargeTableValues.add(value); |
60 : null; | 74 : null; |
61 Session session = Importer.sessionHolder.get(); | 75 Session session = Importer.sessionHolder.get(); |
62 | 76 |
63 Query query = session.createQuery( | 77 Query query = session.createQuery( |
64 "from DischargeTable where " + | 78 "from DischargeTable where " + |
65 "gauge.id=:gauge and kind=:kind and timeInterval=:interval"); | 79 "gauge.id=:gauge and kind=:kind and " + |
66 query.setParameter("gauge", gauge.getId()); | 80 "description=:description and timeInterval=:interval"); |
67 query.setParameter("kind", kind); | 81 query.setParameter("gauge", gauge.getId()); |
68 query.setParameter("interval", ti); | 82 query.setParameter("description", description); |
83 query.setParameter("kind", kind); | |
84 query.setParameter("interval", ti); | |
69 | 85 |
70 List<DischargeTable> dischargeTables = query.list(); | 86 List<DischargeTable> dischargeTables = query.list(); |
71 if (dischargeTables.isEmpty()) { | 87 if (dischargeTables.isEmpty()) { |
72 peer = new DischargeTable(gauge, kind); | 88 peer = new DischargeTable(gauge, description, kind, ti); |
73 session.save(peer); | 89 session.save(peer); |
74 } | 90 } |
75 else { | 91 else { |
76 peer = dischargeTables.get(0); | 92 peer = dischargeTables.get(0); |
77 } | 93 } |