# HG changeset patch # User Raimund Renkert # Date 1477302835 -7200 # Node ID 2593ba20487ed00596b4904046d9d4ea51af06d2 # Parent 7683c4162746c8bbc2ae99d8e3289511d0467ed1 Added method to get the object found in the db. diff -r 7683c4162746 -r 2593ba20487e src/main/java/de/intevation/lada/importer/Identifier.java --- 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(); } diff -r 7683c4162746 -r 2593ba20487e src/main/java/de/intevation/lada/importer/MessungIdentifier.java --- 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; + } } diff -r 7683c4162746 -r 2593ba20487e src/main/java/de/intevation/lada/importer/ProbeIdentifier.java --- 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; + } }