comparison backend/src/main/java/org/dive4elements/river/importer/ImportMeasurementStation.java @ 8412:17db08570637

SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
author Tom Gottfried <tom@intevation.de>
date Wed, 15 Oct 2014 19:20:26 +0200
parents cdb9f6d97f6a
children 5e38e2924c07
comparison
equal deleted inserted replaced
8411:b8c6cb36607e 8412:17db08570637
26 .getLogger(ImportMeasurementStation.class); 26 .getLogger(ImportMeasurementStation.class);
27 27
28 private MeasurementStation peer; 28 private MeasurementStation peer;
29 29
30 public String name; 30 public String name;
31 public Double station;
32 public ImportRange range; 31 public ImportRange range;
33 public String measurementType; 32 public String measurementType;
34 public String riverside; 33 public String riverside;
35 public String gauge; 34 public String gauge;
36 public ImportTimeInterval observationTimerange; 35 public ImportTimeInterval observationTimerange;
37 public String operator; 36 public String operator;
38 public String description; 37 public String comment;
39 38
40 public ImportMeasurementStation() { 39 public ImportMeasurementStation() {
41 } 40 }
42 41
43 public ImportMeasurementStation(MeasurementStation peer) { 42 public ImportMeasurementStation(MeasurementStation peer) {
69 log.warn("No gauge found for measurement station '" + name 68 log.warn("No gauge found for measurement station '" + name
70 + "'"); 69 + "'");
71 } 70 }
72 } 71 }
73 catch (Exception e) { 72 catch (Exception e) {
74 log.error("Exception: " + e.getMessage()); 73 log.error(e.getMessage());
75 } 74 }
76 75
77 Range range = null; 76 Range range = null;
78 77
79 if (this.range != null) { 78 if (this.range != null) {
95 .getDatabaseSession(); 94 .getDatabaseSession();
96 95
97 org.hibernate.Query query = session 96 org.hibernate.Query query = session
98 .createQuery( 97 .createQuery(
99 "FROM MeasurementStation " + 98 "FROM MeasurementStation " +
100 "WHERE river=:river" + 99 "WHERE range=:range " +
101 " AND station=:station " +
102 " AND measurement_type=:measurement_type "); 100 " AND measurement_type=:measurement_type ");
103 101
104 query.setParameter("river", river); 102 query.setParameter("range", range);
105 query.setParameter("station", station);
106 query.setParameter("measurement_type", measurementType); 103 query.setParameter("measurement_type", measurementType);
107 104
108 List<MeasurementStation> stations = query.list(); 105 List<MeasurementStation> stations = query.list();
109 106
110 if (stations.isEmpty()) { 107 if (stations.isEmpty()) {
111 log.info("create new measurement station '" + name + "'"); 108 log.info("create new measurement station '" + name + "'");
112 109
113 peer = new MeasurementStation(river, name, measurementType, 110 peer = new MeasurementStation(name, measurementType,
114 riverside, station, range, gauge, this.gauge, 111 riverside, range, gauge, this.gauge,
115 observationTimerange, operator, description); 112 observationTimerange, operator, comment);
116 113
117 session.save(peer); 114 session.save(peer);
118 } 115 }
119 } 116 }
120 117

http://dive4elements.wald.intevation.org