ref #8689 move Cdm2Cdm migration classes from cdm-pesi to cdmlib-io and add Bupleurum...
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 18 Nov 2019 08:27:59 +0000 (09:27 +0100)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 18 Nov 2019 08:27:59 +0000 (09:27 +0100)
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
app-import/src/main/java/eu/etaxonomy/cdm/app/greece/BupleurumExportActivator.java [new file with mode: 0644]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/FauEu2CdmActivator.java
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmDescriptionImport.java [deleted file]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportBase.java [deleted file]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportConfigurator.java [deleted file]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportState.java [deleted file]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTaxonNodeImport.java [deleted file]
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTermImport.java [deleted file]

index c51af3c8d9a971ead47019ebfb893f6329205521..4b9fa9c8eb70eac12e34806360aad8719f88ccaa 100644 (file)
@@ -19,6 +19,7 @@ import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
 
 public class CdmDestinations {
+
        @SuppressWarnings("unused")
        private static Logger logger = Logger.getLogger(CdmDestinations.class);
 
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/app/greece/BupleurumExportActivator.java b/app-import/src/main/java/eu/etaxonomy/cdm/app/greece/BupleurumExportActivator.java
new file mode 100644 (file)
index 0000000..989af5c
--- /dev/null
@@ -0,0 +1,113 @@
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.app.greece;
+
+import java.util.Calendar;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+
+import eu.etaxonomy.cdm.app.common.CdmDestinations;
+import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.filter.TaxonNodeFilter.ORDER;
+import eu.etaxonomy.cdm.io.cdm2cdm.Cdm2CdmImportConfigurator;
+import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
+import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
+import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
+import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
+import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+
+/**
+ * @author a.mueller
+ * @since 17.08.2019
+ */
+public class BupleurumExportActivator {
+
+    @SuppressWarnings("unused")
+    private static final Logger logger = Logger.getLogger(BupleurumExportActivator.class);
+
+    static final ICdmDataSource greeceSource = CdmDestinations.cdm_production_greece_checklist();
+    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql();
+
+    static final String sourceRefTitle = "Flora of Greece";
+    static final UUID sourceRefUuid = UUID.fromString("f88e33e5-1f6a-463e-b6fd-220d5e93d810");
+
+    static final DbSchemaValidation schemaValidation = DbSchemaValidation.CREATE;
+
+    //check - import
+    static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
+
+    static final int partitionSize = 5000;
+
+    static final boolean doTaxa = true;
+    static final boolean doDescriptions = false;
+
+    static final boolean doConcurrent = false;
+    //auditing
+    static final boolean registerAuditing = true;
+
+// ***************** ALL ************************************************//
+
+    UUID uuidBupleurumTaxonNodeFilter = UUID.fromString("51e768cf-321b-4108-8bee-46143996b033");
+
+    private void doImport(ICdmDataSource source, ICdmDataSource destination, DbSchemaValidation hbm2dll){
+
+        String importFrom = " import from "+ source.getDatabase() + " to "+ destination.getDatabase() + " ...";
+        System.out.println("Start"+importFrom);
+
+        Cdm2CdmImportConfigurator config = Cdm2CdmImportConfigurator.NewInstace(source, destination);
+        config.setConcurrent(doConcurrent);
+        config.setDoTaxa(doTaxa);
+        config.setDoDescriptions(doDescriptions);
+        config.setSourceReference(getSourceRef());
+
+        IProgressMonitor monitor = config.getProgressMonitor();
+
+        config.setDbSchemaValidation(hbm2dll);
+        config.getTaxonNodeFilter().orSubtree(uuidBupleurumTaxonNodeFilter);
+        config.getTaxonNodeFilter().setOrder(ORDER.TREEINDEX);
+        if (doConcurrent){
+            ITaxonNodeOutStreamPartitioner partitioner = TaxonNodeOutStreamPartitionerConcurrent
+                    .NewInstance(config.getSource(), config.getTaxonNodeFilter(),
+                            8, monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
+            config.setPartitioner(partitioner);
+        }
+
+        config.setCheck(check);
+//        config.setRecordsPerTransaction(partitionSize);
+
+        config.setRegisterAuditing(registerAuditing);
+
+        // invoke import
+        CdmDefaultImport<Cdm2CdmImportConfigurator> myImport = new CdmDefaultImport<>();
+        myImport.invoke(config);
+
+        System.out.println("End" + importFrom);
+    }
+
+    private Reference getSourceRef() {
+        Reference ref = ReferenceFactory.newDatabase();
+        ref.setTitle(sourceRefTitle);
+        ref.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(Calendar.getInstance()));
+        ref.setUuid(sourceRefUuid);
+        return ref;
+    }
+
+    public static void main(String[] args) {
+        ICdmDataSource cdmDB = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
+        BupleurumExportActivator myImport = new BupleurumExportActivator();
+        myImport.doImport(greeceSource, cdmDB, schemaValidation);
+        System.exit(0);
+    }
+}
index 0ffd0291c201a55cb692f0522cee864d409b03b8..5f218b39391e6ced3465030023ddb2158adebf27 100644 (file)
@@ -18,12 +18,12 @@ import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.cdm.filter.TaxonNodeFilter.ORDER;
+import eu.etaxonomy.cdm.io.cdm2cdm.Cdm2CdmImportConfigurator;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
 import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
 import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
 import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
-import eu.etaxonomy.cdm.io.pesi.fauEu2Cdm.FauEu2CdmImportConfigurator;
 import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
@@ -70,7 +70,7 @@ public class FauEu2CdmActivator {
         String importFrom = " import from "+ source.getDatabase() + " to "+ destination.getDatabase() + " ...";
         System.out.println("Start"+importFrom);
 
-        FauEu2CdmImportConfigurator config = FauEu2CdmImportConfigurator.NewInstance(source,  destination);
+        Cdm2CdmImportConfigurator config = Cdm2CdmImportConfigurator.NewInstace(source, destination);
         config.setConcurrent(doConcurrent);
         config.setDoTaxa(doTaxa);
         config.setDoDescriptions(doDescriptions);
@@ -94,7 +94,7 @@ public class FauEu2CdmActivator {
         config.setRegisterAuditing(registerAuditing);
 
         // invoke import
-        CdmDefaultImport<FauEu2CdmImportConfigurator> myImport = new CdmDefaultImport<>();
+        CdmDefaultImport<Cdm2CdmImportConfigurator> myImport = new CdmDefaultImport<>();
         myImport.invoke(config);
 
         System.out.println("End" + importFrom);
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmDescriptionImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmDescriptionImport.java
deleted file mode 100644 (file)
index dcacd96..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.TransactionStatus;
-
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
-import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
-import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
-import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- */
-@Component
-public class FauEu2CdmDescriptionImport
-        extends FauEu2CdmImportBase {
-
-    private static final long serialVersionUID = -2111102574346601573L;
-    private static final Logger logger = Logger.getLogger(FauEu2CdmDescriptionImport.class);
-
-
-    @Override
-    protected void doInvoke(FauEu2CdmImportState state) {
-        setState(state);
-        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
-
-        FauEu2CdmImportConfigurator config = state.getConfig();
-
-        ITaxonNodeOutStreamPartitioner partitioner = getPartitioner(state, monitor, config);
-        monitor.subTask("Start partitioning");
-        doData(state, partitioner);
-    }
-
-    private void doData(FauEu2CdmImportState state, ITaxonNodeOutStreamPartitioner partitioner){
-        TaxonNode node = partitioner.next();
-        int partitionSize = 100;
-        int count = 0;
-        TransactionStatus tx = startTransaction();
-        while (node != null) {
-            doSingleNode(state, node);
-            count++;
-            if (count>=partitionSize){
-                clearCache();
-                try {
-                    commitTransaction(tx);
-                } catch (Exception e) {
-                    logger.warn("Exception during commit node " + node.treeIndex());
-                    e.printStackTrace();
-                }
-                tx = startTransaction();
-                count=0;
-            }
-            node = partitioner.next();
-        }
-        commitTransaction(tx);
-        partitioner.close();
-    }
-
-    private void doSingleNode(FauEu2CdmImportState state, TaxonNode node) {
-        Set<TaxonDescription> result = new HashSet<>();
-        logger.info(node.treeIndex());
-        try {
-            for (TaxonDescription desc : node.getTaxon().getDescriptions()){
-                result.add(detache(desc));
-            }
-        } catch (Exception e) {
-            logger.warn("Exception during detache node " + node.treeIndex());
-            e.printStackTrace();
-        }
-        try {
-            if (!result.isEmpty()){
-                getDescriptionService().saveOrUpdate((Set)result);
-                getCommonService().saveOrUpdate(toSave);
-                toSave.clear();
-            }
-        } catch (Exception e) {
-            logger.warn("Exception during save node " + node.treeIndex());
-             e.printStackTrace();
-        }
-    }
-
-    private ITaxonNodeOutStreamPartitioner getPartitioner(FauEu2CdmImportState state, IProgressMonitor monitor,
-            FauEu2CdmImportConfigurator config) {
-        ITaxonNodeOutStreamPartitioner partitioner = config.getPartitioner();
-        if (partitioner == null){
-            if(!config.isConcurrent()){
-                partitioner = TaxonNodeOutStreamPartitioner.NewInstance(sourceRepo(state), state,
-                        state.getConfig().getTaxonNodeFilter(), 100,
-                        monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
-                ((TaxonNodeOutStreamPartitioner)partitioner).setLastCommitManually(true);
-            }else{
-                partitioner = TaxonNodeOutStreamPartitionerConcurrent
-                        .NewInstance(state.getConfig().getSource(), state.getConfig().getTaxonNodeFilter(),
-                                1000, monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
-            }
-        }
-        return partitioner;
-    }
-
-
-    @Override
-    protected boolean doDescriptions(FauEu2CdmImportState state) {
-        return true;
-    }
-
-    @Override
-    protected boolean doCheck(FauEu2CdmImportState state) {
-        return false;
-    }
-
-    @Override
-    protected boolean isIgnore(FauEu2CdmImportState state) {
-        return !state.getConfig().isDoDescriptions();
-    }
-
-}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportBase.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportBase.java
deleted file mode 100644 (file)
index 7b334e4..0000000
+++ /dev/null
@@ -1,1047 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-
-import eu.etaxonomy.cdm.api.application.CdmApplicationController;
-import eu.etaxonomy.cdm.api.application.ICdmRepository;
-import eu.etaxonomy.cdm.database.DbSchemaValidation;
-import eu.etaxonomy.cdm.io.common.CdmImportBase;
-import eu.etaxonomy.cdm.model.agent.AgentBase;
-import eu.etaxonomy.cdm.model.agent.Contact;
-import eu.etaxonomy.cdm.model.agent.Institution;
-import eu.etaxonomy.cdm.model.agent.InstitutionalMembership;
-import eu.etaxonomy.cdm.model.agent.Person;
-import eu.etaxonomy.cdm.model.agent.Team;
-import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
-import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
-import eu.etaxonomy.cdm.model.common.Annotation;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.common.Credit;
-import eu.etaxonomy.cdm.model.common.Extension;
-import eu.etaxonomy.cdm.model.common.ExtensionType;
-import eu.etaxonomy.cdm.model.common.IIntextReferencable;
-import eu.etaxonomy.cdm.model.common.IIntextReferenceTarget;
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
-import eu.etaxonomy.cdm.model.common.IdentifiableSource;
-import eu.etaxonomy.cdm.model.common.Identifier;
-import eu.etaxonomy.cdm.model.common.IntextReference;
-import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.LanguageString;
-import eu.etaxonomy.cdm.model.common.LanguageStringBase;
-import eu.etaxonomy.cdm.model.common.Marker;
-import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
-import eu.etaxonomy.cdm.model.common.RelationshipBase;
-import eu.etaxonomy.cdm.model.common.SourcedEntityBase;
-import eu.etaxonomy.cdm.model.common.VersionableEntity;
-import eu.etaxonomy.cdm.model.description.CommonTaxonName;
-import eu.etaxonomy.cdm.model.description.DescriptionBase;
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
-import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.description.Distribution;
-import eu.etaxonomy.cdm.model.description.FeatureState;
-import eu.etaxonomy.cdm.model.description.SpecimenDescription;
-import eu.etaxonomy.cdm.model.description.State;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
-import eu.etaxonomy.cdm.model.description.TextData;
-import eu.etaxonomy.cdm.model.location.Country;
-import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.model.media.ExternalLink;
-import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
-import eu.etaxonomy.cdm.model.media.Media;
-import eu.etaxonomy.cdm.model.media.Rights;
-import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.name.HybridRelationship;
-import eu.etaxonomy.cdm.model.name.NameRelationship;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.cdm.model.name.Registration;
-import eu.etaxonomy.cdm.model.name.TaxonName;
-import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
-import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
-import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.cdm.model.permission.User;
-import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
-import eu.etaxonomy.cdm.model.term.DefinedTerm;
-import eu.etaxonomy.cdm.model.term.DefinedTermBase;
-import eu.etaxonomy.cdm.model.term.OrderedTermBase;
-import eu.etaxonomy.cdm.model.term.Representation;
-import eu.etaxonomy.cdm.model.term.TermBase;
-import eu.etaxonomy.cdm.model.term.TermCollection;
-import eu.etaxonomy.cdm.model.term.TermNode;
-import eu.etaxonomy.cdm.model.term.TermRelationBase;
-import eu.etaxonomy.cdm.model.term.TermVocabulary;
-import eu.etaxonomy.cdm.persistence.query.MatchMode;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- */
-public abstract class FauEu2CdmImportBase
-        extends CdmImportBase<FauEu2CdmImportConfigurator, FauEu2CdmImportState> {
-
-    private static final long serialVersionUID = 8917991155285743172L;
-    private static final Logger logger = Logger.getLogger(FauEu2CdmImportBase.class);
-
-    //quick and dirty
-    private FauEu2CdmImportState state;
-
-    //TODO move to state
-    private Map<UUID, CdmBase> sessionCache = new HashMap<>();
-
-
-    protected Set<CdmBase> toSave = new HashSet<>();
-
-    protected ICdmRepository sourceRepo(FauEu2CdmImportState state){
-        ICdmRepository repo = state.getSourceRepository();
-        if (repo == null){
-            System.out.println("start source repo");
-            boolean omitTermLoading = true;
-            repo = CdmApplicationController.NewInstance(state.getConfig().getSource(),
-                    DbSchemaValidation.VALIDATE, omitTermLoading);
-            state.setSourceRepository(repo);
-            System.out.println("end source repo");
-        }
-        return repo;
-    }
-
-    protected  Contact detache(Contact contact) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        contact = CdmBase.deproxy(contact);
-        if (contact == null){
-            return contact;
-        }else{
-            return handlePersistedContact(contact);
-        }
-    }
-
-    protected  IIntextReferencable detache(IIntextReferencable cdmBase, boolean onlyForDefinedSignature) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        return (IIntextReferencable)detache((CdmBase)cdmBase);
-    }
-    protected  IIntextReferenceTarget detache(IIntextReferenceTarget cdmBase, boolean onlyForDefinedSignature) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        return (IIntextReferenceTarget)detache((CdmBase)cdmBase);
-    }
-
-    protected <T extends CdmBase> T detache(T cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        return detache(cdmBase, false);
-    }
-
-    private Map<Class,Set<UUID>> existingObjects = new HashMap<>();
-    protected <T extends CdmBase> T detache(T cdmBase, boolean notFromSource) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        cdmBase = CdmBase.deproxy(cdmBase);
-        if (cdmBase == null ){
-            return cdmBase;
-        }else if(isInCache(cdmBase)){
-            return getCached(cdmBase);
-        }else {
-            if (existingObjects.get(cdmBase.getClass()) == null){
-                loadExistingUuids(cdmBase.getClass());
-            }
-            boolean exists = existingObjects.get(cdmBase.getClass()).contains(cdmBase.getUuid());
-            if (exists){
-                Class<T> clazz = (Class<T>)cdmBase.getClass();
-                T existingObj = getCommonService().find(clazz, cdmBase.getUuid());
-                if (existingObj != null){
-                    cache(existingObj);
-                    return existingObj;
-                }else{
-                    logger.warn("Object should exist already but does not exist in target. This should not happen: " + cdmBase.getClass().getSimpleName() + "/" + cdmBase.getUuid());
-                }
-            }
-        }
-        if ( !cdmBase.isPersited()){
-            logger.warn("Non persisted object not in cache and not in target DB. This should not happen: " + cdmBase.getUuid());
-            return cdmBase; //should not happen anymore; either in cache or in target or persisted in source
-        }else{
-            return notFromSource? null : (T)handlePersisted(cdmBase);
-        }
-    }
-
-    /**
-     * @param class1
-     * @return
-     */
-    private Set<UUID> loadExistingUuids(Class<? extends CdmBase> clazz) {
-        List<UUID> list = getCommonService().listUuid(clazz);
-        Set<UUID> result = new HashSet<>(list);
-        existingObjects.put(clazz, result);
-        return result;
-    }
-
-    protected <A extends CdmBase> CdmBase handlePersisted(A cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        if(cdmBase instanceof TaxonNode){
-            return handlePersistedTaxonNode((TaxonNode)cdmBase);
-        }else if(cdmBase instanceof Taxon){
-            return handlePersistedTaxon((Taxon)cdmBase);
-        }else if(cdmBase instanceof Synonym){
-            return handlePersistedSynonym((Synonym)cdmBase);
-        }else if(cdmBase instanceof TaxonName){
-            return handlePersistedTaxonName((TaxonName)cdmBase);
-        }else if(cdmBase instanceof Team){
-            return handlePersistedTeam((Team)cdmBase);
-        }else if(cdmBase instanceof Person){
-            return handlePersistedPerson((Person)cdmBase);
-        }else if(cdmBase instanceof Classification){
-            return handlePersistedClassification((Classification)cdmBase);
-        }else if(cdmBase instanceof Reference){
-            return handlePersistedReference((Reference)cdmBase);
-        }else if(cdmBase instanceof SpecimenOrObservationBase){
-            return handlePersistedSpecimenOrObservationBase((SpecimenOrObservationBase)cdmBase);
-        }else if(cdmBase instanceof IdentifiableSource){
-            return handlePersistedIdentifiableSource((IdentifiableSource)cdmBase);
-        }else if(cdmBase instanceof DescriptionElementSource){
-            return handlePersistedDescriptionElementSource((DescriptionElementSource)cdmBase);
-        }else if(cdmBase instanceof CommonTaxonName){
-            return handlePersistedCommonTaxonName((CommonTaxonName)cdmBase);
-        }else if(cdmBase instanceof Distribution){
-            return handlePersistedDistribution((Distribution)cdmBase);
-        }else if(cdmBase instanceof TextData){
-            return handlePersistedTextData((TextData)cdmBase);
-        }else if(cdmBase instanceof HomotypicalGroup){
-            return handlePersistedHomotypicalGroup((HomotypicalGroup)cdmBase);
-        }else if(cdmBase instanceof TypeDesignationBase){
-            return handlePersistedTypeDesignationBase((TypeDesignationBase)cdmBase);
-        }else if(cdmBase instanceof TaxonDescription){
-            return handlePersistedTaxonDescription((TaxonDescription)cdmBase);
-        }else if(cdmBase instanceof NomenclaturalStatus){
-            return handlePersistedNomenclaturalStatus((NomenclaturalStatus)cdmBase);
-        }else if(cdmBase instanceof TaxonNameDescription){
-            return handlePersistedTaxonNameDescription((TaxonNameDescription)cdmBase);
-        }else if(cdmBase instanceof TaxonRelationship){
-            return handlePersistedTaxonRelationship((TaxonRelationship)cdmBase);
-        }else if(cdmBase instanceof HybridRelationship){
-            return handlePersistedHybridRelationship((HybridRelationship)cdmBase);
-        }else if(cdmBase instanceof NameRelationship){
-            return handlePersistedNameRelationship((NameRelationship)cdmBase);
-        }else if(cdmBase instanceof TaxonNodeAgentRelation){
-            return handlePersistedTaxonNodeAgentRelation((TaxonNodeAgentRelation)cdmBase);
-        }else if(cdmBase instanceof User){
-            return handlePersistedUser((User)cdmBase);
-        }else if(cdmBase instanceof Extension){
-            return handlePersistedExtension((Extension)cdmBase);
-        }else if(cdmBase instanceof Marker){
-            return handlePersistedMarker((Marker)cdmBase);
-        }else if(cdmBase instanceof Annotation){
-            return handlePersistedAnnotation((Annotation)cdmBase);
-        }else if(cdmBase instanceof LanguageString){
-            return handlePersistedLanguageString((LanguageString)cdmBase);
-        }else if(cdmBase instanceof TermVocabulary){
-            return handlePersistedVocabulary((TermVocabulary<?>)cdmBase);
-        }else if(cdmBase instanceof NamedArea){
-            return handlePersistedNamedArea((NamedArea)cdmBase);
-        }else if(cdmBase instanceof TermNode){
-            return handlePersistedTermNode((TermNode)cdmBase);
-        }else if(cdmBase instanceof Representation){
-            return handlePersistedRepresentation((Representation)cdmBase);
-        }else if(cdmBase instanceof InstitutionalMembership){
-            return handlePersistedInstitutionalMembership((InstitutionalMembership)cdmBase);
-        }else if(cdmBase instanceof Institution){
-            return handlePersistedInstitution((Institution)cdmBase);
-        }else if(cdmBase instanceof IntextReference){
-            return handlePersistedIntextReference((IntextReference)cdmBase);
-        }else if(cdmBase instanceof ExtensionType){
-            return handlePersistedExtensionType((ExtensionType)cdmBase);
-        }else if(cdmBase instanceof NomenclaturalStatusType){
-            return handlePersistedNomenclaturalStatusType((NomenclaturalStatusType)cdmBase);
-        }else if(cdmBase instanceof MarkerType){
-            return handlePersistedMarkerType((MarkerType)cdmBase);
-        }else if(cdmBase instanceof DefinedTerm){
-            return handlePersistedDefinedTerm((DefinedTerm)cdmBase);
-        }else if(cdmBase instanceof DefinedTermBase){
-            return handlePersistedTerm((DefinedTermBase<?>)cdmBase);
-        }else {
-            throw new RuntimeException("Type not yet supported: " + cdmBase.getClass().getCanonicalName());
-        }
-    }
-
-
-    protected TaxonNode handlePersistedTaxonNode(TaxonNode node) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-
-        TaxonNode result = handlePersisted((AnnotatableEntity)node);
-        if (result ==null){
-            return result;
-        }
-        //complete
-        handleCollection(result, TaxonNode.class, "agentRelations", TaxonNodeAgentRelation.class);
-        result.setTaxon(detache(result.getTaxon()));
-        result.setReference(detache(node.getReference()));
-        result.setSynonymToBeUsed(detache(result.getSynonymToBeUsed()));
-        handleMap(result, TaxonNode.class, "excludedNote", Language.class, LanguageString.class);
-        //classification, parent, children
-        this.setInvisible(node, "classification", detache(node.getClassification()));
-        handleParentTaxonNode(result);
-        setNewCollection(node, TaxonNode.class, "childNodes", TaxonNode.class);
-        return result;
-    }
-
-    private void handleParentTaxonNode(TaxonNode childNode) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TaxonNode parent = detache(childNode.getParent(), true);
-        //TODO
-        String microReference = null;
-        Reference reference = null;
-        if (parent == null && childNode.getClassification().getRootNode().equals(childNode)){
-            //do nothing
-        }else if (parent == null ){
-            childNode.getClassification().addChildNode(childNode, reference, microReference) ;
-        }else{
-            parent.addChildNode(childNode, reference, microReference);
-        }
-    }
-
-    protected Taxon handlePersistedTaxon(Taxon taxon) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Taxon result = handlePersisted((TaxonBase)taxon);
-        //complete
-        handleCollection(result, Taxon.class, "synonyms", Synonym.class);
-//        handleCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
-        setNewCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
-        handleCollection(result, Taxon.class, "relationsFromThisTaxon", TaxonRelationship.class);
-        handleCollection(result, Taxon.class, "relationsToThisTaxon", TaxonRelationship.class);
-        if (this.doDescriptions(state)){
-            handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
-        }else{
-            setNewCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
-        }
-        return result;
-    }
-
-    protected boolean doDescriptions(FauEu2CdmImportState state) {
-        return false;
-    }
-
-    protected Synonym handlePersistedSynonym(Synonym synonym) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Synonym result = handlePersisted((TaxonBase)synonym);
-        //complete
-        setInvisible(result, "acceptedTaxon", detache(result.getAcceptedTaxon()));
-        result.setType(detache(result.getType()));
-        return result;
-    }
-
-    protected TaxonRelationship handlePersistedTaxonRelationship(TaxonRelationship taxRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TaxonRelationship result = handlePersisted((RelationshipBase)taxRel);
-        //complete
-        result.setFromTaxon(detache(result.getFromTaxon()));
-        result.setToTaxon(detache(result.getToTaxon()));
-        result.setType(detache(result.getType()));
-        return result;
-    }
-
-    protected NameRelationship handlePersistedNameRelationship(NameRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        NameRelationship result = handlePersisted((RelationshipBase)rel);
-        //complete
-        setInvisible(result, "relatedFrom", detache(result.getFromName()));
-        setInvisible(result, "relatedTo", detache(result.getToName()));
-//        result.setFromName(detache(result.getFromName()));
-//        result.setToName(detache(result.getToName()));
-        result.setType(detache(result.getType()));
-        return result;
-    }
-
-    protected HybridRelationship handlePersistedHybridRelationship(HybridRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        HybridRelationship result = handlePersisted((RelationshipBase)rel);
-        //complete
-        setInvisible(result, "relatedFrom", detache(result.getParentName()));
-        setInvisible(result, "relatedTo", detache(result.getHybridName()));
-//        result.setFromName(detache(result.getFromName()));
-//        result.setToName(detache(result.getToName()));
-        result.setType(detache(result.getType()));
-        return result;
-    }
-
-    protected NomenclaturalStatus handlePersistedNomenclaturalStatus(NomenclaturalStatus status) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        NomenclaturalStatus result = handlePersisted((ReferencedEntityBase)status);
-        //complete
-        result.setType(detache(result.getType()));
-        return result;
-    }
-
-    protected TypeDesignationBase handlePersistedTypeDesignationBase(TypeDesignationBase<?> designation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TypeDesignationBase result = handlePersisted((SourcedEntityBase)designation);
-        //complete
-        result.setCitation(detache(result.getCitation()));
-        handleCollection(result, TypeDesignationBase.class, "registrations", Registration.class);
-        handleCollection(result, TypeDesignationBase.class, "typifiedNames", TaxonName.class);
-        result.setTypeStatus(detache(result.getTypeStatus()));
-        return result;
-    }
-
-    protected InstitutionalMembership handlePersistedInstitutionalMembership(InstitutionalMembership institutionalMembership) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        InstitutionalMembership result = handlePersisted((VersionableEntity)institutionalMembership);
-        //complete
-//        result.setPerson(detache(result.getPerson()));
-        setInvisible(result, "person", detache(result.getPerson()));
-        result.setInstitute(detache(result.getInstitute()));
-        return result;
-    }
-
-    protected Institution handlePersistedInstitution(Institution institution) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Institution result = handlePersisted((AgentBase)institution);
-        //complete
-        result.setIsPartOf(detache(result.getIsPartOf()));
-        handleCollection(result, Institution.class, "types", DefinedTerm.class);
-        return result;
-    }
-
-    protected TaxonNodeAgentRelation handlePersistedTaxonNodeAgentRelation(TaxonNodeAgentRelation nodeAgentRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TaxonNodeAgentRelation result = handlePersisted((AnnotatableEntity)nodeAgentRel);
-        //complete
-        result.setAgent(detache(result.getAgent()));
-        result.setType(detache(result.getType()));
-        setInvisible(result, "taxonNode", detache(result.getTaxonNode()));
-        return result;
-    }
-
-
-    protected TaxonName handlePersistedTaxonName(TaxonName taxonName) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        @SuppressWarnings("rawtypes")
-        TaxonName result = handlePersisted((IdentifiableEntity)taxonName);
-        //complete
-        result.setRank(detache(result.getRank()));
-        result.setCombinationAuthorship(detache(result.getCombinationAuthorship()));
-        result.setExCombinationAuthorship(detache(result.getExCombinationAuthorship()));
-        result.setBasionymAuthorship(detache(result.getBasionymAuthorship()));
-        result.setExBasionymAuthorship(detache(result.getExBasionymAuthorship()));
-        result.setInBasionymAuthorship(detache(result.getInBasionymAuthorship()));
-        result.setInCombinationAuthorship(detache(result.getInCombinationAuthorship()));
-
-        result.setNomenclaturalReference(detache(result.getNomenclaturalReference()));
-        result.setNomenclaturalSource(detache(result.getNomenclaturalSource()));
-        result.setHomotypicalGroup(detache(result.getHomotypicalGroup()));
-        handleCollection(result, TaxonName.class, "descriptions", TaxonNameDescription.class);
-        handleCollection(result, TaxonName.class, "hybridChildRelations", HybridRelationship.class);
-        handleCollection(result, TaxonName.class, "hybridParentRelations", HybridRelationship.class);
-        handleCollection(result, TaxonName.class, "relationsFromThisName", NameRelationship.class);
-        handleCollection(result, TaxonName.class, "relationsToThisName", NameRelationship.class);
-        handleCollection(result, TaxonName.class, "status", NomenclaturalStatus.class);
-
-        handleCollection(result, TaxonName.class, "registrations", Registration.class);
-        handleCollection(result, TaxonName.class, "typeDesignations", TypeDesignationBase.class);
-
-        handleCollection(result, TaxonName.class, "taxonBases", TaxonBase.class);
-
-        return result;
-    }
-
-    protected HomotypicalGroup handlePersistedHomotypicalGroup(HomotypicalGroup group) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        HomotypicalGroup result = handlePersisted((AnnotatableEntity)group);
-        //complete
-        handleCollection(result, HomotypicalGroup.class, "typifiedNames", TaxonName.class);
-        return result;
-    }
-
-    protected Annotation handlePersistedAnnotation(Annotation annotation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Annotation result = handlePersisted((AnnotatableEntity)annotation);
-        //complete
-        result.setAnnotationType(detache(annotation.getAnnotationType()));
-        result.setCommentator(detache(result.getCommentator()));
-        handleCollection(result, Annotation.class, "intextReferences", IntextReference.class);
-        return result;
-    }
-
-    protected Extension handlePersistedExtension(Extension extension) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Extension result = handlePersisted((VersionableEntity)extension);
-        //complete
-        result.setType(detache(extension.getType()));
-        return result;
-    }
-
-    protected Marker handlePersistedMarker(Marker marker) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Marker result = handlePersisted((VersionableEntity)marker);
-        //complete
-        result.setMarkerType(detache(marker.getMarkerType()));
-        return result;
-    }
-
-    protected Team handlePersistedTeam(Team team) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Team result = handlePersisted((TeamOrPersonBase)team);
-        //complete
-        handleCollection(result, Team.class, "teamMembers", Person.class);
-        return result;
-    }
-
-    protected Contact handlePersistedContact(Contact contact) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Contact result = contact; // getTarget(contact);
-        if (result ==null){
-            return result;
-        }
-        if (!contact.getAddresses().isEmpty() || !contact.getEmailAddresses().isEmpty()
-               || !contact.getFaxNumbers().isEmpty() ||!contact.getPhoneNumbers().isEmpty()
-               ||!contact.getUrls().isEmpty()){
-            logger.warn("Addresses not yet implemented");
-        }
-        setInvisible(result, "addresses", new HashSet<>());
-//        handleCollection(result, Contact.class, "", Address.class);
-        setInvisible(result, "faxNumbers", new ArrayList<>());
-        setInvisible(result, "phoneNumbers", new ArrayList<>());
-        setInvisible(result, "emailAddresses", new ArrayList<>());
-        setInvisible(result, "urls", new ArrayList<>());
-        return result;
-    }
-
-    protected Person handlePersistedPerson(Person person) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Person result = handlePersisted((TeamOrPersonBase)person);
-        //complete
-        handleCollection(result, Person.class, "institutionalMemberships", InstitutionalMembership.class);
-        return result;
-    }
-
-    protected NamedArea handlePersistedNamedArea(NamedArea area) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        NamedArea result = handlePersisted((OrderedTermBase)area);
-        //complete
-        handleCollection(result, NamedArea.class, "countries", Country.class);
-        result.setLevel(detache(result.getLevel()));
-        result.setType(detache(result.getType()));
-        result.setShape(detache(result.getShape()));
-        return result;
-    }
-
-    protected Classification handlePersistedClassification(Classification classification) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Classification result = handlePersisted((IdentifiableEntity)classification);
-        //complete
-        result.setName(detache(classification.getName()));
-        result.setReference(detache(classification.getReference()));
-        result.setRootNode(detache(classification.getRootNode()));
-        handleCollection(result, Classification.class, "geoScopes", NamedArea.class);
-        handleMap(result, Classification.class, "description", Language.class, LanguageString.class);
-        return result;
-    }
-
-    protected Reference handlePersistedReference(Reference reference) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Reference result = handlePersisted((IdentifiableMediaEntity)reference);
-        result.setAuthorship(detache(result.getAuthorship()));
-        result.setInstitution(detache(result.getInstitution()));
-        result.setSchool(detache(result.getSchool()));
-        result.setInReference(detache(result.getInReference()));
-        return result;
-    }
-
-    protected SpecimenOrObservationBase<?> handlePersistedSpecimenOrObservationBase(SpecimenOrObservationBase specimen) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        //TODO implement for classes
-        SpecimenOrObservationBase<?> result = handlePersisted((IdentifiableEntity)specimen);
-        //complete
-        result.setSex(detache(result.getSex()));
-        result.setLifeStage(detache(result.getLifeStage()));
-        result.setKindOfUnit(detache(result.getKindOfUnit()));
-        handleCollection(result, SpecimenOrObservationBase.class, "determinations", DeterminationEvent.class);
-        handleCollection(result, SpecimenOrObservationBase.class, "descriptions", SpecimenDescription.class);
-        handleCollection(result, SpecimenOrObservationBase.class, "derivationEvents", DerivationEvent.class);
-        handleMap(result, SpecimenOrObservationBase.class, "definition", Language.class, LanguageString.class);
-        return result;
-    }
-
-    protected IdentifiableSource handlePersistedIdentifiableSource(IdentifiableSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        IdentifiableSource result = handlePersisted((OriginalSourceBase)source);
-        //complete
-        return result;
-    }
-
-    protected DescriptionElementSource handlePersistedDescriptionElementSource(DescriptionElementSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        DescriptionElementSource result = handlePersisted((OriginalSourceBase)source);
-        //complete
-        result.setNameUsedInSource(detache(result.getNameUsedInSource()));
-        return result;
-    }
-
-    protected <T extends CommonTaxonName> T  handlePersistedCommonTaxonName(CommonTaxonName element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((DescriptionElementBase)element);
-        //complete
-        result.setLanguage(detache(result.getLanguage()));
-        result.setArea(detache(result.getArea()));
-        return result;
-    }
-
-    protected <T extends TextData> T  handlePersistedTextData(TextData element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((DescriptionElementBase)element);
-        //complete
-        result.setFormat(detache(result.getFormat()));
-        handleMap(result, TextData.class, "multilanguageText", Language.class, LanguageString.class);
-        return result;
-    }
-
-    protected <T extends Distribution> T  handlePersistedDistribution(Distribution element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((DescriptionElementBase)element);
-        //complete
-        result.setArea(detache(result.getArea()));
-        result.setStatus(detache(result.getStatus()));
-        return result;
-    }
-
-    protected ExtensionType handlePersistedExtensionType(ExtensionType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        ExtensionType result = handlePersisted((DefinedTermBase)term);
-        //complete
-        return result;
-    }
-
-    protected MarkerType handlePersistedMarkerType(MarkerType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        MarkerType result = handlePersisted((DefinedTermBase)term);
-        //complete
-        return result;
-    }
-
-    protected NomenclaturalStatusType handlePersistedNomenclaturalStatusType(NomenclaturalStatusType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        NomenclaturalStatusType result = handlePersisted((OrderedTermBase)term);
-        //complete
-        return result;
-    }
-
-    protected DefinedTerm handlePersistedDefinedTerm(DefinedTerm term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        DefinedTerm result = handlePersisted((DefinedTermBase)term);
-        //complete
-        return result;
-    }
-
-    //placeholder for not implemented methods for subclasses
-    protected DefinedTermBase<?> handlePersistedTerm(DefinedTermBase term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        DefinedTermBase<?> result = handlePersisted(term);
-        logger.warn("Class not yet handled: " + term.getClass().getSimpleName());
-        return result;
-    }
-
-    protected TermVocabulary<?> handlePersistedVocabulary(TermVocabulary voc) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TermVocabulary<?> result = (TermVocabulary<?>)handlePersisted((TermCollection)voc);
-        handleCollection(result, TermVocabulary.class, "terms", DefinedTermBase.class);
-        return result;
-    }
-
-    protected TermNode<?> handlePersistedTermNode(TermNode node) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        TermNode<?> result = (TermNode<?>)handlePersisted((TermRelationBase)node);
-        //complete
-        setInvisible(result, "parent", detache(result.getParent()));
-        handleCollection(result, TermNode.class, "inapplicableIf", FeatureState.class);
-        handleCollection(result, TermNode.class, "onlyApplicableIf", FeatureState.class);
-        handleCollection(result, TermNode.class, "inapplicableIf_old", State.class);
-        handleCollection(result, TermNode.class, "onlyApplicableIf_old", State.class);
-        handleCollection(result, TermNode.class, "children", TermNode.class);
-
-        return result;
-    }
-
-    protected Representation handlePersistedRepresentation(Representation representation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Representation result = (Representation)handlePersisted((LanguageStringBase)representation);
-        return result;
-    }
-
-    protected <T extends TermBase> T  handlePersisted(TermBase termBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((IdentifiableEntity)termBase);
-        //complete
-        handleCollection(result, TermBase.class, "representations", Representation.class);
-        return result;
-    }
-
-    protected <T extends TermCollection> T  handlePersisted(TermCollection termCollection) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((TermBase)termCollection);
-        //complete
-        handleCollection(result, TermCollection.class, "termRelations", TermRelationBase.class);
-        return result;
-    }
-
-    protected <T extends TermRelationBase> T  handlePersisted(TermRelationBase termRelationBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((VersionableEntity)termRelationBase);
-        result.setTerm(detache(result.getTerm()));
-        setInvisible(result, TermRelationBase.class, "graph", detache(result.getGraph()));
-        return result;
-    }
-
-    protected User handlePersistedUser(User user) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
-        User result = (User)handlePersistedCdmBase(user);
-        if (result.getUsername().equals("admin")){
-            result = getUserService().listByUsername("admin", MatchMode.EXACT, null, null, null, null, null).iterator().next();
-            getState().putPermanent(user.getUuid(), result);
-            cache(result); //necessary?
-            toSave.add(result);
-            toSave.remove(user);
-        }
-        if (!result.isPersited()){
-            result.setAuthorities(new HashSet<>());
-            result.setGrantedAuthorities(new HashSet<>());
-            setInvisible(result, "groups", new HashSet<>());
-        }
-        return result;
-    }
-
-
-    protected LanguageString handlePersistedLanguageString(LanguageString languageString) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        LanguageString result = handlePersisted((LanguageStringBase)languageString);
-        //complete
-        handleCollection(result, LanguageString.class, "intextReferences", IntextReference.class);
-        return result;
-    }
-
-    protected IntextReference handlePersistedIntextReference(IntextReference intextReference) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        IntextReference result = handlePersisted((VersionableEntity)intextReference);
-        result.setReferencedEntity(detache(result.getReferencedEntity(), false));
-        Method targetMethod = IntextReference.class.getDeclaredMethod("setTarget", IIntextReferenceTarget.class);
-        targetMethod.setAccessible(true);
-        targetMethod.invoke(result, detache(result.getTarget(), false));
-        return result;
-    }
-
-    protected <T extends TaxonDescription> T  handlePersistedTaxonDescription(TaxonDescription taxDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((DescriptionBase)taxDescription);
-        //complete
-        setInvisible(taxDescription, "taxon", detache(taxDescription.getTaxon()));
-        handleCollection(taxDescription, TaxonDescription.class, "geoScopes", NamedArea.class);
-        handleCollection(taxDescription, TaxonDescription.class, "scopes", DefinedTerm.class);
-        return result;
-    }
-
-    protected <T extends TaxonDescription> T  handlePersistedTaxonNameDescription(TaxonNameDescription nameDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((DescriptionBase)nameDescription);
-        //complete
-        setInvisible(nameDescription, "taxonName", detache(nameDescription.getTaxonName()));
-        return result;
-    }
-
-
-// ***************************** BASE CLASSES ********************************************/
-
-    protected <T extends CdmBase> T handlePersistedCdmBase(CdmBase cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = (T)getTarget(cdmBase);
-        //complete
-        cdmBase.setCreatedBy(detache(cdmBase.getCreatedBy()));
-        return result;
-    }
-
-    protected <T extends VersionableEntity> T handlePersisted(VersionableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = (T)handlePersistedCdmBase((CdmBase)entity);
-        //complete
-        entity.setUpdatedBy(detache(entity.getUpdatedBy()));
-        return result;
-    }
-
-    protected <T extends AnnotatableEntity> T handlePersisted(AnnotatableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((VersionableEntity)entity);
-        //complete
-        handleCollection(result, AnnotatableEntity.class, "annotations", Annotation.class);
-        handleCollection(result, AnnotatableEntity.class, "markers", Marker.class);
-        return result;
-    }
-
-    protected <T extends SourcedEntityBase> T  handlePersisted(SourcedEntityBase sourcedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        int originalId = sourcedEntity.getId();
-        T result = handlePersisted((AnnotatableEntity)sourcedEntity);
-        if (!result.isPersited() && getState().getConfig().isAddSources()){
-            result.addImportSource(String.valueOf(originalId), sourcedEntity.getClass().getSimpleName(),
-                    getSourceReference(getState()), null);
-        }
-        //complete
-        handleCollection(result, SourcedEntityBase.class, "sources", OriginalSourceBase.class);
-        return result;
-    }
-
-    protected <T extends IdentifiableEntity> T  handlePersisted(IdentifiableEntity identifiableEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((SourcedEntityBase)identifiableEntity);
-        //complete
-        handleCollection(result, IdentifiableEntity.class, "credits", Credit.class);
-        handleCollection(result, IdentifiableEntity.class, "extensions", Extension.class);
-        handleCollection(result, IdentifiableEntity.class, "identifiers", Identifier.class);
-        handleCollection(result, IdentifiableEntity.class, "rights", Rights.class);
-        return result;
-    }
-
-    protected <T extends DefinedTermBase> T  handlePersisted(DefinedTermBase definedTermBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((TermBase)definedTermBase);
-        //complete
-        handleCollection(result, DefinedTermBase.class, "media", Media.class);
-        handleCollection(result, DefinedTermBase.class, "generalizationOf", DefinedTermBase.class);
-        handleCollection(result, DefinedTermBase.class, "includes", DefinedTermBase.class);
-        result.setKindOf(detache(result.getKindOf()));
-        result.setPartOf(detache(result.getPartOf()));
-        setInvisible(result, DefinedTermBase.class, "vocabulary", detache(result.getVocabulary()));
-
-        return result;
-    }
-
-    protected <T extends OriginalSourceBase> T  handlePersisted(OriginalSourceBase source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((ReferencedEntityBase)source);
-        //complete
-        handleCollection(result, OriginalSourceBase.class, "links", ExternalLink.class);
-        return result;
-    }
-
-    protected <T extends LanguageStringBase> T  handlePersisted(LanguageStringBase lsBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((AnnotatableEntity)lsBase);
-        //complete
-        result.setLanguage(detache(lsBase.getLanguage()));
-        return result;
-    }
-
-    protected <T extends TeamOrPersonBase> T  handlePersisted(TeamOrPersonBase teamOrPerson) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((AgentBase)teamOrPerson);
-        //complete
-        return result;
-    }
-
-    protected <T extends AgentBase> T  handlePersisted(AgentBase agent) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((IdentifiableMediaEntity)agent);
-        result.setContact(detache(result.getContact()));
-        //complete
-        return result;
-    }
-
-    protected <T extends TaxonBase> T  handlePersisted(TaxonBase taxonBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((IdentifiableEntity)taxonBase);
-        //complete
-        result.setName(detache(taxonBase.getName()));
-        result.setSec(detache(taxonBase.getSec()));
-        return result;
-    }
-
-    protected <T extends IdentifiableMediaEntity> T  handlePersisted(IdentifiableMediaEntity mediaEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((IdentifiableEntity)mediaEntity);
-        //complete
-        handleCollection(result, IdentifiableMediaEntity.class, "media", Media.class);
-        return result;
-    }
-
-    protected <T extends ReferencedEntityBase> T  handlePersisted(ReferencedEntityBase referencedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((AnnotatableEntity)referencedEntity);
-        //complete
-        result.setCitation(detache(result.getCitation()));
-        return result;
-    }
-
-    protected <T extends DescriptionBase> T  handlePersisted(DescriptionBase descriptionBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((IdentifiableEntity)descriptionBase);
-        //complete
-        handleCollection(result, DescriptionBase.class, "descriptionElements", DescriptionElementBase.class);
-        handleCollection(result, DescriptionBase.class, "descriptiveDataSets", DescriptiveDataSet.class);
-        handleCollection(result, DescriptionBase.class, "descriptionSources", Reference.class);
-        result.setDescribedSpecimenOrObservation(detache(descriptionBase.getDescribedSpecimenOrObservation()));
-        return result;
-    }
-
-    protected <T extends DescriptionElementBase> T  handlePersisted(DescriptionElementBase element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((AnnotatableEntity)element);
-        //complete
-        result.setFeature(detache(result.getFeature()));
-        setInvisible(result, DescriptionElementBase.class, "inDescription", detache(result.getInDescription()));
-        handleCollection(result, DescriptionElementBase.class, "sources", DescriptionElementSource.class);
-        handleCollection(result, DescriptionElementBase.class, "media", Media.class);
-        handleCollection(result, DescriptionElementBase.class, "modifiers", DefinedTerm.class);
-        handleMap(result, DescriptionElementBase.class, "modifyingText", Language.class, LanguageString.class);
-
-        return result;
-    }
-
-    protected <T extends RelationshipBase> T  handlePersisted(RelationshipBase relBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        T result = handlePersisted((ReferencedEntityBase)relBase);
-        return result;
-    }
-
-
-//************************** COLLECTIONS / MAPS ****************************************/
-
-    protected <HOLDER extends CdmBase, ITEM extends CdmBase> void handleCollection(
-            HOLDER holder, Class<? super HOLDER> declaringClass, String parameter, Class<ITEM> itemClass)
-            throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
-
-        Collection<ITEM> oldCollection = setNewCollection(holder, declaringClass, parameter, itemClass);
-        Collection<ITEM> newCollection = getTargetCollection(itemClass, oldCollection);
-        Field field = declaringClass.getDeclaredField(parameter);
-        field.setAccessible(true);
-        field.set(holder, newCollection);
-    }
-
-    protected <HOLDER extends CdmBase, KEY extends CdmBase, ITEM extends CdmBase>
-            void handleMap(
-            HOLDER holder, Class<? super HOLDER> declaringClass, String parameter,
-            Class<KEY> keyClass, Class<ITEM> itemClass)
-            throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
-
-        //TODO we do not need to set the new map 2x
-        Map<KEY,ITEM> oldMap = setNewMap(holder, declaringClass, parameter, keyClass, itemClass);
-        Map<KEY,ITEM> newMap = getTargetMap(oldMap);
-        Field field = declaringClass.getDeclaredField(parameter);
-        field.setAccessible(true);
-        field.set(holder, newMap);
-    }
-
-    protected <T extends CdmBase> Collection<T> setNewCollection(CdmBase obj, Class<?> holderClass,
-            String parameter, Class<T> entityClass) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
-        Field field = holderClass.getDeclaredField(parameter);
-        field.setAccessible(true);
-        Collection<T> oldValue = (Collection<T>)field.get(obj);
-        Collection<T> newValue = null;
-        if (Set.class.isAssignableFrom(field.getType())){
-            newValue = new HashSet<>();
-        }else if (List.class.isAssignableFrom(field.getType())){
-            newValue = new ArrayList<>();
-        }else{
-            throw new RuntimeException("Unsupported collection type: " + field.getType().getCanonicalName());
-        }
-        field.set(obj, newValue);
-        return oldValue;
-    }
-
-    protected <KEY extends CdmBase, ITEM extends CdmBase> Map<KEY,ITEM> setNewMap(CdmBase obj, Class<?> holderClass,
-            String parameter, Class<KEY> keyClass, Class<ITEM> itemClass) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
-        Field field = holderClass.getDeclaredField(parameter);
-        field.setAccessible(true);
-        Map<KEY,ITEM> oldValue = (Map<KEY,ITEM>)field.get(obj);
-        Map<KEY,ITEM> newValue = null;
-        if (Map.class.isAssignableFrom(field.getType())){
-            newValue = new HashMap<>();
-        }else{
-            throw new RuntimeException("Unsupported map type: " + field.getType().getCanonicalName());
-        }
-        field.set(obj, newValue);
-        return oldValue;
-    }
-
-
-    private <T extends Collection<S>, S extends CdmBase> Collection<S> getTargetCollection(Class<S> clazz, T sourceCollection) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Collection<S> result =  new ArrayList<>();
-        if (Set.class.isAssignableFrom(sourceCollection.getClass())){
-            result = new HashSet<>();
-        }
-        for (S entity : sourceCollection){
-            S target = detache(entity);
-            result.add(target);
-        }
-        return result;
-    }
-
-    private <K extends CdmBase, V extends CdmBase> Map<K,V> getTargetMap(Map<K,V> sourceMap) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
-        Map<K,V> result = new HashMap<>();
-        for (K key : sourceMap.keySet()){
-            K targetKey = detache(key);
-            V targetValue = detache(sourceMap.get(key));
-            result.put(targetKey, targetValue);
-        }
-        return result;
-    }
-
-// ****************************** INVISIBLE **************************************/
-
-    protected void setInvisible(Object holder, String fieldName, Object value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
-        setInvisible(holder, holder.getClass(), fieldName, value);
-    }
-    protected void setInvisible(Object holder, Class<?> holderClazz, String fieldName, Object value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
-        Field field = holderClazz.getDeclaredField(fieldName);
-        field.setAccessible(true);
-        field.set(holder, value);
-    }
-
-// ************************* GET TARGET ******************************************/
-
-
-    //TODO this should be cached for partition
-    private <T extends CdmBase> T getTarget(T source) {
-        if (source == null){
-            return null;
-        }
-        T result = getCached(source);
-//        if (result == null){
-//            Class<T> clazz = (Class<T>)source.getClass();
-//            result = getCommonService().find(clazz, source.getUuid());
-//        }
-        if (result == null){
-            //Alternative: clone?
-            result = CdmBase.deproxy(source);
-            result.setId(0);
-            cache(result);
-            toSave.add(result);
-        }
-        return result;
-    }
-
-// ******************* CACHE *******************************************************/
-
-
-    protected void cache(CdmBase cdmBase) {
-       if (cdmBase instanceof User || cdmBase instanceof DefinedTermBase){
-           getState().putPermanent(cdmBase.getUuid(), cdmBase);
-       }else{
-           sessionCache.put(cdmBase.getUuid(), cdmBase);
-       }
-       addExistingObject(cdmBase);
-
-    }
-
-    private void addExistingObject(CdmBase cdmBase) {
-        cdmBase = CdmBase.deproxy(cdmBase);
-        Set<UUID> set = existingObjects.get(cdmBase.getClass());
-        if (set == null){
-            set = loadExistingUuids(cdmBase.getClass());
-//            set = new HashSet<>();
-//            existingObjects.put(cdmBase.getClass(), set);
-        }
-        set.add(cdmBase.getUuid());
-    }
-
-    protected boolean isInCache(CdmBase cdmBase) {
-        return getCached(cdmBase) != null;
-    }
-
-    protected <T extends CdmBase> T getCached(T cdmBase) {
-        T result = (T)sessionCache.get(cdmBase.getUuid());
-        if (result == null){
-            result = (T)getState().getPermanent(cdmBase.getUuid());
-        }
-        return result;
-    }
-
-    protected void clearCache() {
-        sessionCache.clear();
-    }
-
-    private Reference getSourceReference(FauEu2CdmImportState state) {
-        UUID uuid = state.getConfig().getSourceRefUuid();
-        if (uuid == null){
-            uuid = state.getConfig().getSourceReference().getUuid();
-            state.getConfig().setSourceRefUuid(uuid);
-        }
-        Reference result = (Reference)sessionCache.get(uuid);
-        if (result == null){
-            result = (Reference)getState().getPermanent(uuid);
-        }
-        if (result == null){
-            result = getReferenceService().find(uuid);
-        }
-        if (result == null){
-            result = state.getConfig().getSourceReference();
-            getReferenceService().save(result);
-            sessionCache.put(result.getUuid(), result);
-        }
-        return result;
-    }
-
-    public FauEu2CdmImportState getState() {
-        return state;
-    }
-
-    public void setState(FauEu2CdmImportState state) {
-        this.state = state;
-    }
-
-}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportConfigurator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportConfigurator.java
deleted file mode 100644 (file)
index 59faf1d..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import eu.etaxonomy.cdm.database.ICdmDataSource;
-import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
-import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
-import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
-import eu.etaxonomy.cdm.model.reference.Reference;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- */
-public class FauEu2CdmImportConfigurator
-        extends ImportConfiguratorBase<FauEu2CdmImportState, ICdmDataSource>{
-
-    private static final long serialVersionUID = -5452466831212722546L;
-
-    private static IInputTransformer myTransformer = null;
-
-    private TaxonNodeFilter taxonNodeFilter = new TaxonNodeFilter();
-    private ITaxonNodeOutStreamPartitioner partitioner;
-    private boolean concurrent = false;
-
-    private boolean doTaxa = true;
-    private boolean doDescriptions = true;
-    private boolean addSources = true;
-
-    public static FauEu2CdmImportConfigurator NewInstance(ICdmDataSource source, ICdmDataSource destination) {
-        return new FauEu2CdmImportConfigurator(source, destination);
-    }
-
-    public FauEu2CdmImportConfigurator(ICdmDataSource source, ICdmDataSource destination) {
-        super(myTransformer);
-        this.setSource(source);
-        this.setDestination(destination);
-    }
-
-    @Override
-    public FauEu2CdmImportState getNewState() {
-        return new FauEu2CdmImportState(this);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    protected void makeIoClassList() {
-        ioClassList = new Class[]{
-                FauEu2CdmTaxonNodeImport.class ,
-                FauEu2CdmDescriptionImport.class ,
-        };
-    }
-
-    @Override
-    @Deprecated
-    public Reference getSourceReference() {
-        return sourceReference;
-    }
-
-
-    public TaxonNodeFilter getTaxonNodeFilter() {
-        return taxonNodeFilter;
-    }
-    public void setTaxonNodeFilter(TaxonNodeFilter taxonNodeFilter) {
-        this.taxonNodeFilter = taxonNodeFilter;
-    }
-
-    public ITaxonNodeOutStreamPartitioner getPartitioner() {
-        return partitioner;
-    }
-    public void setPartitioner(ITaxonNodeOutStreamPartitioner partitioner) {
-        this.partitioner = partitioner;
-    }
-
-    public boolean isConcurrent() {
-        return concurrent;
-    }
-    public void setConcurrent(boolean concurrent) {
-        this.concurrent = concurrent;
-    }
-
-    public boolean isDoDescriptions() {
-        return doDescriptions;
-    }
-    public void setDoDescriptions(boolean doDescriptions) {
-        this.doDescriptions = doDescriptions;
-    }
-
-    public boolean isDoTaxa() {
-        return doTaxa;
-    }
-    public void setDoTaxa(boolean doTaxa) {
-        this.doTaxa = doTaxa;
-    }
-
-    public boolean isAddSources() {
-        return addSources;
-    }
-    public void setAddSources(boolean addSources) {
-        this.addSources = addSources;
-    }
-}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportState.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportState.java
deleted file mode 100644 (file)
index 63cb426..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import eu.etaxonomy.cdm.api.application.ICdmRepository;
-import eu.etaxonomy.cdm.io.common.CdmImportBase;
-import eu.etaxonomy.cdm.io.common.ImportStateBase;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- */
-public class FauEu2CdmImportState
-        extends ImportStateBase<FauEu2CdmImportConfigurator,CdmImportBase>{
-
-    private ICdmRepository sourceRepository;
-
-    private Map<UUID, CdmBase> permanentCache = new HashMap<>();
-
-    protected FauEu2CdmImportState(FauEu2CdmImportConfigurator config) {
-        super(config);
-    }
-
-    public ICdmRepository getSourceRepository() {
-        return sourceRepository;
-    }
-    public void setSourceRepository(ICdmRepository sourceRepository) {
-        this.sourceRepository = sourceRepository;
-    }
-
-    public CdmBase getPermanent(UUID uuid) {
-        return permanentCache.get(uuid);
-    }
-    public void putPermanent(UUID uuid, CdmBase cdmBase) {
-        permanentCache.put(uuid, cdmBase);
-    }
-}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTaxonNodeImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTaxonNodeImport.java
deleted file mode 100644 (file)
index 5471eae..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.TransactionStatus;
-
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
-import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
-import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
-import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- */
-@Component
-public class FauEu2CdmTaxonNodeImport
-        extends FauEu2CdmImportBase {
-
-    private static final long serialVersionUID = -2111102574346601573L;
-    private static final Logger logger = Logger.getLogger(FauEu2CdmTaxonNodeImport.class);
-
-
-    @Override
-    protected void doInvoke(FauEu2CdmImportState state) {
-        setState(state);
-        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
-
-        FauEu2CdmImportConfigurator config = state.getConfig();
-
-        ITaxonNodeOutStreamPartitioner partitioner = getPartitioner(state, monitor, config);
-        monitor.subTask("Start partitioning");
-        doData(state, partitioner);
-    }
-
-    private void doData(FauEu2CdmImportState state, ITaxonNodeOutStreamPartitioner partitioner){
-        TaxonNode node = partitioner.next();
-        int partitionSize = 100;
-        int count = 0;
-        TransactionStatus tx = startTransaction();
-        while (node != null) {
-            node = doSingleNode(state, node);
-            count++;
-            if (count>=partitionSize){
-                clearCache();
-                try {
-                    commitTransaction(tx);
-                } catch (Exception e) {
-                    logger.warn("Exception during commit node " + node.treeIndex());
-                    e.printStackTrace();
-                }
-                tx = startTransaction();
-                count=0;
-            }
-            node = partitioner.next();
-        }
-        commitTransaction(tx);
-        partitioner.close();
-    }
-
-    private TaxonNode doSingleNode(FauEu2CdmImportState state, TaxonNode node) {
-        TaxonNode result = null;
-        logger.info(node.treeIndex());
-        try {
-            result = detache(node);
-        } catch (Exception e) {
-            logger.warn("Exception during detache node " + node.treeIndex());
-            e.printStackTrace();
-        }
-        try {
-            if (result != null){
-                getTaxonNodeService().saveOrUpdate(node);
-                getCommonService().saveOrUpdate(toSave);
-                toSave.clear();
-            }
-        } catch (Exception e) {
-            logger.warn("Exception during save node " + node.treeIndex());
-             e.printStackTrace();
-        }
-
-        return result;
-    }
-
-    private ITaxonNodeOutStreamPartitioner getPartitioner(FauEu2CdmImportState state, IProgressMonitor monitor,
-            FauEu2CdmImportConfigurator config) {
-        ITaxonNodeOutStreamPartitioner partitioner = config.getPartitioner();
-        if (partitioner == null){
-            if(!config.isConcurrent()){
-                partitioner = TaxonNodeOutStreamPartitioner.NewInstance(sourceRepo(state), state,
-                        state.getConfig().getTaxonNodeFilter(), 100,
-                        monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
-                ((TaxonNodeOutStreamPartitioner)partitioner).setLastCommitManually(true);
-            }else{
-                partitioner = TaxonNodeOutStreamPartitionerConcurrent
-                        .NewInstance(state.getConfig().getSource(), state.getConfig().getTaxonNodeFilter(),
-                                1000, monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
-            }
-        }
-        return partitioner;
-    }
-
-
-    @Override
-    protected boolean doCheck(FauEu2CdmImportState state) {
-        return false;
-    }
-
-    @Override
-    protected boolean isIgnore(FauEu2CdmImportState state) {
-        return !state.getConfig().isDoTaxa();
-    }
-
-}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTermImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTermImport.java
deleted file mode 100644 (file)
index f781d5d..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
-* Copyright (C) 2019 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.io.pesi.fauEu2Cdm;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.TransactionStatus;
-
-import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.term.DefinedTermBase;
-
-/**
- * @author a.mueller
- * @since 17.08.2019
- * NOT YET USED
- */
-@Component
-public class FauEu2CdmTermImport
-        extends FauEu2CdmImportBase {
-
-    private static final long serialVersionUID = 3995116783196060465L;
-
-    private static final Logger logger = Logger.getLogger(FauEu2CdmTermImport.class);
-
-    //TODO move to state
-    private Map<UUID, CdmBase> sessionCache = new HashMap<>();
-    private Map<UUID, CdmBase> permanentCache = new HashMap<>();
-    private Set<UUID> movedObjects = new HashSet<>();
-
-    private Set<CdmBase> toSave = new HashSet<>();
-
-
-    @Override
-    protected void doInvoke(FauEu2CdmImportState state) {
-        setState(state);
-        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
-
-        FauEu2CdmImportConfigurator config = state.getConfig();
-
-        doData(state);
-    }
-
-
-    private void doData(FauEu2CdmImportState state){
-      //term uuids laden
-        //gegen existierende Terme abgleichen
-        //fehlende Terme importieren
-
-        TransactionStatus tx = startTransaction();
-        List<String> propertyPaths = null;
-        List<DefinedTermBase> terms = sourceRepo(state).getTermService().list(null, null, null, null, propertyPaths);
-        int count = 0;
-        for(DefinedTermBase term: terms){
-            doSingleTerm(state, term);
-            count++;
-        }
-        commitTransaction(tx);
-    }
-
-    private DefinedTermBase doSingleTerm(FauEu2CdmImportState state, DefinedTermBase term) {
-        DefinedTermBase result = null;
-        if (logger.isInfoEnabled()){logger.info(term.getTitleCache());}
-        try {
-            result = detache(term);
-        } catch (Exception e) {
-            logger.warn("Exception during detache node " + term.getUuid());
-            e.printStackTrace();
-        }
-        try {
-            if (result != null){
-                getTermService().saveOrUpdate(term);
-                getCommonService().saveOrUpdate(toSave);
-                toSave.clear();
-            }
-        } catch (Exception e) {
-            logger.warn("Exception during save node " + term.getUuid());
-             e.printStackTrace();
-        }
-
-        return result;
-    }
-
-
-
-
-
-    @Override
-    protected boolean doCheck(FauEu2CdmImportState state) {
-        return false;
-    }
-
-    @Override
-    protected boolean isIgnore(FauEu2CdmImportState state) {
-        return false;
-    }
-
-}