[PATCH] Backend: Store source of a wst column if available
Wald Commits
scm-commit at wald.intevation.org
Fri Jun 28 17:01:00 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1372431655 -7200
# Node ID 7664ab97b4c7f8aeaedcd2caeaf7445f72bf8111
# Parent 7cb247824ed1bd61b11134e4ab4c1aedbffa38be
Backend: Store source of a wst column if available.
diff -r 7cb247824ed1 -r 7664ab97b4c7 backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java Fri Jun 28 14:11:58 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java Fri Jun 28 17:00:55 2013 +0200
@@ -33,6 +33,7 @@
protected String name;
protected String description;
protected Integer position;
+ protected String source;
protected ImportTimeInterval timeInterval;
@@ -50,7 +51,8 @@
ImportWst wst,
String name,
String description,
- Integer position
+ Integer position,
+ String source
) {
this();
this.wst = wst;
@@ -59,6 +61,15 @@
this.position = position;
}
+ public ImportWstColumn(
+ ImportWst wst,
+ String name,
+ String description,
+ Integer position
+ ) {
+ this(wst, name, description, position, null);
+ }
+
public ImportWst getWst() {
return wst;
}
@@ -91,6 +102,14 @@
this.position = position;
}
+ public String getSource() {
+ return source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
public void addColumnValue(BigDecimal position, BigDecimal w) {
columnValues.add(
new ImportWstColumnValue(this, position, w));
@@ -135,12 +154,14 @@
Wst w = wst.getPeer(river);
Session session = ImporterSession.getInstance().getDatabaseSession();
Query query = session.createQuery(
- "from WstColumn where " +
- "wst=:wst and name=:name " +
+ "from WstColumn where" +
+ " wst=:wst and name=:name" +
+ " and source=:source" +
" and position=:position");
- query.setParameter("wst", w);
- query.setParameter("name", name);
- query.setParameter("position", position);
+ query.setParameter("wst", w);
+ query.setParameter("name", name);
+ query.setParameter("position", position);
+ query.setParameter("source", source);
TimeInterval ti = timeInterval != null
? timeInterval.getPeer()
@@ -148,7 +169,8 @@
List<WstColumn> columns = query.list();
if (columns.isEmpty()) {
- peer = new WstColumn(w, name, description, position, ti);
+ peer = new WstColumn(
+ w, name, description, source, position, ti);
session.save(peer);
}
else {
diff -r 7cb247824ed1 -r 7664ab97b4c7 backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Fri Jun 28 14:11:58 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Fri Jun 28 17:00:55 2013 +0200
@@ -111,7 +111,7 @@
String [] lsBezeichner = null;
String [] langBezeichner = null;
int [] colNaWidths = null;
- // String [] quellen = null;
+ String [] quellen = null;
String [] daten = null;
BigDecimal [] aktAbfluesse = null;
@@ -215,7 +215,7 @@
if (spezial.length() == 0) {
continue;
}
- // quellen = StringUtil.splitQuoted(spezial, '"');
+ quellen = StringUtil.splitQuoted(spezial, '"');
}
else if (spezial.startsWith(COLUMN_DATUM)) {
spezial = spezial.substring(COLUMN_DATUM.length()).trim();
@@ -278,6 +278,9 @@
}
ImportWstColumn iwc = wst.getColumn(i);
iwc.setName(candidate);
+ if (quellen != null && i < quellen.length) {
+ iwc.setSource(quellen[i]);
+ }
String potentialDate = daten != null && i < daten.length
? daten[i]
: candidate;
diff -r 7cb247824ed1 -r 7664ab97b4c7 backend/src/main/java/org/dive4elements/river/model/WstColumn.java
--- a/backend/src/main/java/org/dive4elements/river/model/WstColumn.java Fri Jun 28 14:11:58 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/WstColumn.java Fri Jun 28 17:00:55 2013 +0200
@@ -32,6 +32,7 @@
private Wst wst;
private String name;
private String description;
+ private String source;
private Integer position;
private TimeInterval timeInterval;
@@ -45,12 +46,14 @@
Wst wst,
String name,
String description,
+ String source,
Integer position,
TimeInterval timeInterval
) {
this.wst = wst;
this.name = name;
this.description = description;
+ this.source = source;
this.position = position;
this.timeInterval = timeInterval;
}
@@ -91,6 +94,15 @@
this.name = name;
}
+ @Column(name = "source")
+ public String getSource() {
+ return description;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
@Column(name = "description")
public String getDescription() {
return description;
More information about the Dive4elements-commits
mailing list