Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java @ 2811:8926571e47fb
Finished importing MINFO bed heights (single and epoch).
flys-backend/trunk@4225 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 13 Apr 2012 07:24:55 +0000 |
parents | 04eeb45df27b |
children | 0d27d02b1208 |
comparison
equal
deleted
inserted
replaced
2810:04eeb45df27b | 2811:8926571e47fb |
---|---|
16 import de.intevation.flys.model.Range; | 16 import de.intevation.flys.model.Range; |
17 import de.intevation.flys.model.River; | 17 import de.intevation.flys.model.River; |
18 import de.intevation.flys.model.TimeInterval; | 18 import de.intevation.flys.model.TimeInterval; |
19 | 19 |
20 | 20 |
21 public class ImportBedHeightEpoch | 21 public class ImportBedHeightEpoch implements ImportBedHeight |
22 { | 22 { |
23 private static Logger log = Logger.getLogger(ImportBedHeightEpoch.class); | 23 private static Logger log = Logger.getLogger(ImportBedHeightEpoch.class); |
24 | 24 |
25 protected String evaluationBy; | 25 protected String evaluationBy; |
26 protected String description; | 26 protected String description; |
44 public String getDescription() { | 44 public String getDescription() { |
45 return description; | 45 return description; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 public List<ImportBedHeightEpochValue> getValues() { | 49 public int getValueCount() { |
50 return values; | 50 return values.size(); |
51 } | |
52 | |
53 public void setTimeInterval(ImportTimeInterval timeInterval) { | |
54 this.timeInterval = timeInterval; | |
51 } | 55 } |
52 | 56 |
53 | 57 |
54 public void setEvaluationBy(String evaluationBy) { | 58 public void setEvaluationBy(String evaluationBy) { |
55 this.evaluationBy = evaluationBy; | 59 this.evaluationBy = evaluationBy; |
69 | 73 |
70 public void setOldElevationModel(ImportElevationModel oldElevationModel) { | 74 public void setOldElevationModel(ImportElevationModel oldElevationModel) { |
71 this.oldElevationModel = oldElevationModel; | 75 this.oldElevationModel = oldElevationModel; |
72 } | 76 } |
73 | 77 |
74 public void addValue(ImportBedHeightEpochValue value) { | 78 public void setYear(int year) { |
75 values.add(value); | 79 // do nothing |
80 } | |
81 | |
82 public void setSoundingWidth(int soundingWidth) { | |
83 // do nothing | |
84 } | |
85 | |
86 public void setLocationSystem(ImportLocationSystem locationSystem) { | |
87 // do nothing | |
88 } | |
89 | |
90 public void setType(ImportBedHeightType type) { | |
91 // do nothing | |
92 } | |
93 | |
94 @Override | |
95 public void addValue(ImportBedHeightValue value) { | |
96 values.add((ImportBedHeightEpochValue) value); | |
76 } | 97 } |
77 | 98 |
78 | 99 |
100 @Override | |
79 public void storeDependencies(River river) | 101 public void storeDependencies(River river) |
80 throws SQLException, ConstraintViolationException | 102 throws SQLException, ConstraintViolationException |
81 { | 103 { |
82 log.info("Store dependencies for epoch: '" + getDescription() + "'"); | 104 log.info("Store dependencies for epoch: '" + getDescription() + "'"); |
83 | 105 |
94 log.debug("store values now..."); | 116 log.debug("store values now..."); |
95 | 117 |
96 for (ImportBedHeightEpochValue value: values) { | 118 for (ImportBedHeightEpochValue value: values) { |
97 value.storeDependencies(peer); | 119 value.storeDependencies(peer); |
98 } | 120 } |
121 | |
122 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
123 session.flush(); | |
99 } | 124 } |
100 | 125 |
101 | 126 |
127 @Override | |
102 public BedHeightEpoch getPeer(River river) { | 128 public BedHeightEpoch getPeer(River river) { |
103 if (peer == null) { | 129 if (peer == null) { |
104 ElevationModel theCurModel = curElevationModel != null | 130 ElevationModel theCurModel = curElevationModel != null |
105 ? curElevationModel.getPeer() | 131 ? curElevationModel.getPeer() |
106 : null; | 132 : null; |
107 | 133 |
134 if (theCurModel == null) { | |
135 log.warn("Skip file - invalid current elevation model."); | |
136 return null; | |
137 } | |
138 | |
108 TimeInterval theTime = timeInterval != null | 139 TimeInterval theTime = timeInterval != null |
109 ? timeInterval.getPeer() | 140 ? timeInterval.getPeer() |
110 : null; | 141 : null; |
111 | 142 |
143 if (theTime == null) { | |
144 log.warn("Skip file - invalid time range."); | |
145 return null; | |
146 } | |
147 | |
112 Range theRange = range != null ? range.getPeer(river) : null; | 148 Range theRange = range != null ? range.getPeer(river) : null; |
113 | 149 |
114 if (theCurModel == null || theRange == null || theTime == null) { | 150 if (theRange == null) { |
115 log.warn("Skip invalid file '" + description + "'"); | 151 log.warn("Skip file - invalid km range."); |
116 return null; | 152 return null; |
117 } | 153 } |
118 | 154 |
119 Session session = ImporterSession.getInstance().getDatabaseSession(); | 155 Session session = ImporterSession.getInstance().getDatabaseSession(); |
120 | 156 |
122 "from BedHeightEpoch where " + | 158 "from BedHeightEpoch where " + |
123 " river=:river and " + | 159 " river=:river and " + |
124 " timeInterval=:timeInterval and " + | 160 " timeInterval=:timeInterval and " + |
125 " curElevationModel=:curElevationModel and " + | 161 " curElevationModel=:curElevationModel and " + |
126 " range=:range and " + | 162 " range=:range and " + |
127 " evaluationBy=: evaluationBy and " + | 163 " evaluationBy=:evaluationBy and " + |
128 " description=:description"); | 164 " description=:description"); |
129 | 165 |
130 query.setParameter("river", river); | 166 query.setParameter("river", river); |
131 query.setParameter("timeInterval", theTime); | 167 query.setParameter("timeInterval", theTime); |
132 query.setParameter("curElevationModel", theCurModel); | 168 query.setParameter("curElevationModel", theCurModel); |
146 theCurModel, | 182 theCurModel, |
147 oldElevationModel != null ? oldElevationModel.getPeer() : null, | 183 oldElevationModel != null ? oldElevationModel.getPeer() : null, |
148 evaluationBy, | 184 evaluationBy, |
149 description | 185 description |
150 ); | 186 ); |
187 | |
188 session.save(peer); | |
151 } | 189 } |
152 else { | 190 else { |
153 peer = bedHeights.get(0); | 191 peer = bedHeights.get(0); |
154 } | 192 } |
155 } | 193 } |