[PATCH] Renamed ImportSedimentYield to ImportSedimentLoadLS
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 11 13:10:08 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1405077005 -7200
# Node ID 6954ac9b7591ab2c58b899838c3a73cce6ea6112
# Parent fac1aa67931be54acac75ea7d24d29379ef0cc2d
Renamed ImportSedimentYield to ImportSedimentLoadLS.
diff -r fac1aa67931b -r 6954ac9b7591 backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Fri Jul 11 11:32:18 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Fri Jul 11 13:10:05 2014 +0200
@@ -172,7 +172,7 @@
protected List<ImportFlowVelocityMeasurement> flowVelocityMeasurements;
- protected List<ImportSedimentYield> sedimentYields;
+ protected List<ImportSedimentLoadLS> sedimentYields;
protected List<ImportMeasurementStation> measurementStations;
@@ -288,7 +288,7 @@
morphologicalWidths = new ArrayList<ImportMorphWidth>();
flowVelocityModels = new ArrayList<ImportFlowVelocityModel>();
flowVelocityMeasurements = new ArrayList<ImportFlowVelocityMeasurement>();
- sedimentYields = new ArrayList<ImportSedimentYield>();
+ sedimentYields = new ArrayList<ImportSedimentLoadLS>();
measurementStations = new ArrayList<ImportMeasurementStation>();
sqRelations = new ArrayList<ImportSQRelation>();
}
@@ -1501,7 +1501,7 @@
River river = getPeer();
- for (ImportSedimentYield sedimentYield: sedimentYields) {
+ for (ImportSedimentLoadLS sedimentYield: sedimentYields) {
sedimentYield.storeDependencies(river);
}
}
diff -r fac1aa67931b -r 6954ac9b7591 backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadLS.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadLS.java Fri Jul 11 13:10:05 2014 +0200
@@ -0,0 +1,136 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import org.dive4elements.river.model.GrainFraction;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.SedimentLoadLS;
+import org.dive4elements.river.model.TimeInterval;
+import org.dive4elements.river.model.Unit;
+
+
+public class ImportSedimentLoadLS {
+
+ private static Logger log = Logger.getLogger(ImportSedimentLoadLS.class);
+
+ private ImportGrainFraction grainFraction;
+
+ private ImportUnit unit;
+
+ private ImportTimeInterval timeInterval;
+
+ private String description;
+
+ private Integer kind;
+
+ private List<ImportSedimentLoadLSValue> values;
+
+ private SedimentLoadLS peer;
+
+ public ImportSedimentLoadLS(String description) {
+ this.values = new ArrayList<ImportSedimentLoadLSValue>();
+ this.description = description;
+ }
+
+ public void setTimeInterval(ImportTimeInterval timeInterval) {
+ this.timeInterval = timeInterval;
+ }
+
+ public void setUnit(ImportUnit unit) {
+ this.unit = unit;
+ }
+
+ public void setGrainFraction(ImportGrainFraction grainFraction) {
+ this.grainFraction = grainFraction;
+ }
+
+ public void setKind(Integer kind) {
+ this.kind = kind;
+ }
+
+ public void addValue(ImportSedimentLoadLSValue value) {
+ this.values.add(value);
+ }
+
+ public void storeDependencies(River river) {
+ log.debug("store dependencies");
+
+ if (grainFraction != null) {
+ grainFraction.storeDependencies();
+ }
+
+ SedimentLoadLS peer = getPeer(river);
+
+ if (peer != null) {
+ int i = 0;
+
+ for (ImportSedimentLoadLSValue value : values) {
+ value.storeDependencies(peer);
+ i++;
+ }
+
+ log.info("stored " + i + " sediment yield values.");
+ }
+ }
+
+ public SedimentLoadLS getPeer(River river) {
+ log.debug("get peer");
+
+ GrainFraction gf = grainFraction != null ? grainFraction.getPeer()
+ : null;
+
+ Unit u = unit != null ? unit.getPeer() : null;
+
+ TimeInterval ti = timeInterval != null ? timeInterval.getPeer() : null;
+
+ if (ti == null || u == null) {
+ log.warn("Skip invalid SedimentYield: time interval or unit null!");
+ return null;
+ }
+
+ if (peer == null) {
+ Session session = ImporterSession.getInstance()
+ .getDatabaseSession();
+ Query query = session.createQuery("from SedimentYield where "
+ + " river=:river and "
+ + " grainFraction=:grainFraction and " + " unit=:unit and "
+ + " timeInterval=:timeInterval and "
+ + " description=:description");
+
+ query.setParameter("river", river);
+ query.setParameter("grainFraction", gf);
+ query.setParameter("unit", u);
+ query.setParameter("timeInterval", ti);
+ query.setParameter("description", description);
+
+ List<SedimentLoadLS> yields = query.list();
+ if (yields.isEmpty()) {
+ log.debug("create new SedimentYield");
+
+ peer = new SedimentLoadLS(river, u, ti, gf, description);
+ peer.setKind(this.kind);
+ session.save(peer);
+ }
+ else {
+ peer = yields.get(0);
+ }
+ }
+
+ return peer;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fac1aa67931b -r 6954ac9b7591 backend/src/main/java/org/dive4elements/river/importer/ImportSedimentYield.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportSedimentYield.java Fri Jul 11 11:32:18 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.importer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.Query;
-
-import org.dive4elements.river.model.GrainFraction;
-import org.dive4elements.river.model.River;
-import org.dive4elements.river.model.SedimentLoadLS;
-import org.dive4elements.river.model.TimeInterval;
-import org.dive4elements.river.model.Unit;
-
-
-public class ImportSedimentYield {
-
- private static Logger log = Logger.getLogger(ImportSedimentYield.class);
-
- private ImportGrainFraction grainFraction;
-
- private ImportUnit unit;
-
- private ImportTimeInterval timeInterval;
-
- private String description;
-
- private Integer kind;
-
- private List<ImportSedimentLoadLSValue> values;
-
- private SedimentLoadLS peer;
-
- public ImportSedimentYield(String description) {
- this.values = new ArrayList<ImportSedimentLoadLSValue>();
- this.description = description;
- }
-
- public void setTimeInterval(ImportTimeInterval timeInterval) {
- this.timeInterval = timeInterval;
- }
-
- public void setUnit(ImportUnit unit) {
- this.unit = unit;
- }
-
- public void setGrainFraction(ImportGrainFraction grainFraction) {
- this.grainFraction = grainFraction;
- }
-
- public void setKind(Integer kind) {
- this.kind = kind;
- }
-
- public void addValue(ImportSedimentLoadLSValue value) {
- this.values.add(value);
- }
-
- public void storeDependencies(River river) {
- log.debug("store dependencies");
-
- if (grainFraction != null) {
- grainFraction.storeDependencies();
- }
-
- SedimentLoadLS peer = getPeer(river);
-
- if (peer != null) {
- int i = 0;
-
- for (ImportSedimentLoadLSValue value : values) {
- value.storeDependencies(peer);
- i++;
- }
-
- log.info("stored " + i + " sediment yield values.");
- }
- }
-
- public SedimentLoadLS getPeer(River river) {
- log.debug("get peer");
-
- GrainFraction gf = grainFraction != null ? grainFraction.getPeer()
- : null;
-
- Unit u = unit != null ? unit.getPeer() : null;
-
- TimeInterval ti = timeInterval != null ? timeInterval.getPeer() : null;
-
- if (ti == null || u == null) {
- log.warn("Skip invalid SedimentYield: time interval or unit null!");
- return null;
- }
-
- if (peer == null) {
- Session session = ImporterSession.getInstance()
- .getDatabaseSession();
- Query query = session.createQuery("from SedimentYield where "
- + " river=:river and "
- + " grainFraction=:grainFraction and " + " unit=:unit and "
- + " timeInterval=:timeInterval and "
- + " description=:description");
-
- query.setParameter("river", river);
- query.setParameter("grainFraction", gf);
- query.setParameter("unit", u);
- query.setParameter("timeInterval", ti);
- query.setParameter("description", description);
-
- List<SedimentLoadLS> yields = query.list();
- if (yields.isEmpty()) {
- log.debug("create new SedimentYield");
-
- peer = new SedimentLoadLS(river, u, ti, gf, description);
- peer.setKind(this.kind);
- session.save(peer);
- }
- else {
- peer = yields.get(0);
- }
- }
-
- return peer;
- }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fac1aa67931b -r 6954ac9b7591 backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadLSParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadLSParser.java Fri Jul 11 11:32:18 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadLSParser.java Fri Jul 11 13:10:05 2014 +0200
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.dive4elements.river.importer.ImportGrainFraction;
-import org.dive4elements.river.importer.ImportSedimentYield;
+import org.dive4elements.river.importer.ImportSedimentLoadLS;
import org.dive4elements.river.importer.ImportSedimentLoadLSValue;
import org.dive4elements.river.importer.ImportTimeInterval;
import org.dive4elements.river.importer.ImportUnit;
@@ -92,9 +92,9 @@
Pattern.compile("(<|>){1}\\s*((([0-9]+?,[0-9]+?)|([0-9]++))\\s*(\\w+))");
- protected List<ImportSedimentYield> sedimentYields;
+ protected List<ImportSedimentLoadLS> sedimentYields;
- protected ImportSedimentYield[] current;
+ protected ImportSedimentLoadLS[] current;
protected ImportGrainFraction grainFraction;
@@ -106,7 +106,7 @@
public SedimentLoadLSParser() {
- sedimentYields = new ArrayList<ImportSedimentYield>();
+ sedimentYields = new ArrayList<ImportSedimentLoadLS>();
}
@@ -129,7 +129,7 @@
@Override
protected void finish() {
if (current != null) {
- for (ImportSedimentYield isy: current) {
+ for (ImportSedimentLoadLS isy: current) {
sedimentYields.add(isy);
}
}
@@ -247,7 +247,7 @@
* with respect to file location (offical epoch or not?) */
private void initializeSedimentYields() {
// skip first column (Fluss-km) and last column (Hinweise)
- current = new ImportSedimentYield[columnNames.length-2];
+ current = new ImportSedimentLoadLS[columnNames.length-2];
Integer kind;
@@ -259,7 +259,7 @@
}
for (int i = 0, n = columnNames.length; i < n-2; i++) {
- current[i] = new ImportSedimentYield(this.description);
+ current[i] = new ImportSedimentLoadLS(this.description);
current[i].setTimeInterval(getTimeInterval(columnNames[i+1]));
current[i].setUnit(unit);
current[i].setGrainFraction(grainFraction);
@@ -407,7 +407,7 @@
}
- public List<ImportSedimentYield> getSedimentYields() {
+ public List<ImportSedimentLoadLS> getSedimentYields() {
return sedimentYields;
}
}
More information about the Dive4Elements-commits
mailing list