Mercurial > lada > lada-server
changeset 1101:2593ba20487e
Added method to get the object found in the db.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 24 Oct 2016 11:53:55 +0200 |
parents | 7683c4162746 |
children | 341911ecc9e0 |
files | src/main/java/de/intevation/lada/importer/Identifier.java src/main/java/de/intevation/lada/importer/MessungIdentifier.java src/main/java/de/intevation/lada/importer/ProbeIdentifier.java |
diffstat | 3 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/importer/Identifier.java Mon Oct 24 11:52:17 2016 +0200 +++ b/src/main/java/de/intevation/lada/importer/Identifier.java Mon Oct 24 11:53:55 2016 +0200 @@ -14,4 +14,5 @@ public Identified find(Object object) throws InvalidTargetObjectTypeException; + public Object getExisting(); }
--- a/src/main/java/de/intevation/lada/importer/MessungIdentifier.java Mon Oct 24 11:52:17 2016 +0200 +++ b/src/main/java/de/intevation/lada/importer/MessungIdentifier.java Mon Oct 24 11:53:55 2016 +0200 @@ -25,10 +25,13 @@ @RepositoryConfig(type=RepositoryType.RO) private Repository repository; + private Messung found; + @Override public Identified find(Object object) throws InvalidTargetObjectTypeException { + found = null; if (!(object instanceof Messung)) { throw new InvalidTargetObjectTypeException( "Object is not of type Messung"); @@ -55,6 +58,7 @@ if (messungen.isEmpty()) { return Identified.NEW; } + found = messungen.get(0); return Identified.UPDATE; } else if (messung.getIdAlt() != null && @@ -71,6 +75,7 @@ if (messungen.isEmpty()) { return Identified.NEW; } + found = messungen.get(0); return Identified.UPDATE; } else { @@ -90,6 +95,7 @@ messung.getNebenprobenNr().isEmpty() || messungen.get(0).getNebenprobenNr().isEmpty() ) { + found = messungen.get(0); return Identified.UPDATE; } else { @@ -97,4 +103,9 @@ } } } + + @Override + public Object getExisting() { + return found; + } }
--- a/src/main/java/de/intevation/lada/importer/ProbeIdentifier.java Mon Oct 24 11:52:17 2016 +0200 +++ b/src/main/java/de/intevation/lada/importer/ProbeIdentifier.java Mon Oct 24 11:53:55 2016 +0200 @@ -25,10 +25,13 @@ @RepositoryConfig(type=RepositoryType.RO) private Repository repository; + private Probe found; + @Override public Identified find(Object object) throws InvalidTargetObjectTypeException { + found = null; if (!(object instanceof Probe)) { throw new InvalidTargetObjectTypeException( "Object is not of type Probe"); @@ -55,6 +58,7 @@ if (proben.isEmpty()) { return Identified.NEW; } + found = proben.get(0); return Identified.UPDATE; } else if (probe.getIdAlt() != null && @@ -71,6 +75,7 @@ if (proben.isEmpty()) { return Identified.NEW; } + found = proben.get(0); return Identified.UPDATE; } else { @@ -89,6 +94,7 @@ probe.getHauptprobenNr().isEmpty() || proben.get(0).getHauptprobenNr().isEmpty() ) { + found = proben.get(0); return Identified.UPDATE; } else { @@ -96,4 +102,11 @@ } } } + + /** + * @return the found probe + */ + public Object getExisting() { + return found; + } }