comparison backend/src/main/java/org/dive4elements/river/importer/ImportBedHeight.java @ 8986:392bbcd8a88b

Database inserts accelerated by suppressing unnecessary database queries for new data series
author mschaefer
date Sun, 08 Apr 2018 18:07:06 +0200
parents a0a0a7f912ab
children 4c5eeaff554c
comparison
equal deleted inserted replaced
8985:27851cfda84a 8986:392bbcd8a88b
10 10
11 import java.util.ArrayList; 11 import java.util.ArrayList;
12 import java.util.List; 12 import java.util.List;
13 13
14 import org.apache.log4j.Logger; 14 import org.apache.log4j.Logger;
15 import org.dive4elements.river.importer.common.StoreMode;
15 import org.dive4elements.river.model.BedHeight; 16 import org.dive4elements.river.model.BedHeight;
16 import org.dive4elements.river.model.BedHeightType; 17 import org.dive4elements.river.model.BedHeightType;
17 import org.dive4elements.river.model.ElevationModel; 18 import org.dive4elements.river.model.ElevationModel;
18 import org.dive4elements.river.model.Range; 19 import org.dive4elements.river.model.Range;
19 import org.dive4elements.river.model.River; 20 import org.dive4elements.river.model.River;
38 protected String sounding_width_info; 39 protected String sounding_width_info;
39 protected String comment; 40 protected String comment;
40 41
41 protected List<ImportBedHeightValue> values; 42 protected List<ImportBedHeightValue> values;
42 43
44 protected StoreMode storeMode;
45
43 protected BedHeight peer; 46 protected BedHeight peer;
44 47
45 48
46 public ImportBedHeight(final String description) { 49 public ImportBedHeight(final String description) {
47 this.description = description; 50 this.description = description;
48 this.values = new ArrayList<>(); 51 this.values = new ArrayList<>();
52 this.storeMode = StoreMode.NONE;
49 } 53 }
50 54
51 55
52 public String getDescription() { 56 public String getDescription() {
53 return this.description; 57 return this.description;
176 log.info("Create new BedHeight DB instance."); 180 log.info("Create new BedHeight DB instance.");
177 this.peer = new BedHeight(river, this.year, theType, this.locationSystem.getPeer(), theCurModel, 181 this.peer = new BedHeight(river, this.year, theType, this.locationSystem.getPeer(), theCurModel,
178 (this.oldElevationModel != null) ? this.oldElevationModel.getPeer() : null, this.range.getPeer(river), 182 (this.oldElevationModel != null) ? this.oldElevationModel.getPeer() : null, this.range.getPeer(river),
179 this.evaluationBy, this.description, this.sounding_width_info, this.comment); 183 this.evaluationBy, this.description, this.sounding_width_info, this.comment);
180 session.save(this.peer); 184 session.save(this.peer);
185 this.storeMode = StoreMode.INSERT;
181 } 186 }
182 else { 187 else {
183 this.peer = bedHeights.get(0); 188 this.peer = bedHeights.get(0);
189 this.storeMode = StoreMode.UPDATE;
184 } 190 }
185 191
186 return this.peer; 192 return this.peer;
187 } 193 }
188 } 194 }

http://dive4elements.wald.intevation.org