From 001b9d782fe8616da7914027855e82555f7aac94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20M=C3=BCller?= Date: Thu, 19 Oct 2023 15:18:51 +0200 Subject: [PATCH] cleanup --- .../cdm/io/specimen/SpecimenImportBase.java | 78 ++++++------------- .../io/specimen/SpecimenImportStateBase.java | 10 +-- 2 files changed, 28 insertions(+), 60 deletions(-) diff --git a/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java b/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java index 3af91100b8..9856e52a46 100755 --- a/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java +++ b/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportBase.java @@ -88,19 +88,14 @@ public abstract class SpecimenImportBase kindOfUnitsMap; - @Override protected abstract void doInvoke(STATE state); /** * Handle a single unit - * @param state - * @param item */ protected abstract void handleSingleUnit(STATE state, Object item) ; - - protected TaxonName getOrCreateTaxonName(String scientificName, Rank rank, boolean preferredFlag, STATE state, int unitIndexInAbcdFile){ TaxonName taxonName = null; SpecimenImportConfiguratorBase config = state.getConfig(); @@ -262,6 +257,7 @@ public abstract class SpecimenImportBase state) { ICdmRepository cdmRepository = state.getConfig().getCdmAppController(); if (cdmRepository == null){ cdmRepository = this; @@ -568,8 +560,7 @@ public abstract class SpecimenImportBase specimen = CdmBase.deproxy(cdmBase, SpecimenOrObservationBase.class); return cdmRepository.getOccurrenceService().saveOrUpdate(specimen); }else if (cdmBase.isInstanceOf(Reference.class)){ return cdmRepository.getReferenceService().saveOrUpdate(CdmBase.deproxy(cdmBase, Reference.class)); @@ -580,8 +571,7 @@ public abstract class SpecimenImportBase description = CdmBase.deproxy(cdmBase, DescriptionBase.class); return cdmRepository.getDescriptionService().saveOrUpdate(description); }else if (cdmBase.isInstanceOf(TaxonBase.class)){ return cdmRepository.getTaxonService().saveOrUpdate(CdmBase.deproxy(cdmBase, TaxonBase.class)); @@ -592,11 +582,9 @@ public abstract class SpecimenImportBase findExistingSpecimen(String unitId, SpecimenImportStateBase state){ ICdmRepository cdmAppController = state.getConfig().getCdmAppController(); if(cdmAppController==null){ cdmAppController = this; @@ -609,7 +597,8 @@ public abstract class SpecimenImportBase existingSpecimens = cdmAppController.getOccurrenceService().findByTitle(config); + @SuppressWarnings("rawtypes") + Pager existingSpecimens = cdmAppController.getOccurrenceService().findByTitle(config); if(!existingSpecimens.getRecords().isEmpty()){ if(existingSpecimens.getRecords().size()==1){ return existingSpecimens.getRecords().iterator().next(); @@ -673,7 +662,7 @@ public abstract class SpecimenImportBase config = state.getConfig(); Institution institution=null; institution = (Institution)state.institutions.get(institutionCode); if (institution != null){ @@ -707,10 +696,9 @@ public abstract class SpecimenImportBase config = state.getConfig(); Collection collection = null; List collections; collection = (Collection) state.collections.get(collectionCode); @@ -733,7 +722,7 @@ public abstract class SpecimenImportBase(); + collections = new ArrayList<>(); } if (collections.size() > 0 && config.isReuseExistingMetaData()) { for (Collection coll:collections){ @@ -749,12 +738,9 @@ public abstract class SpecimenImportBase taxonAndSynonyms = taxonName.getTaxonBases(); - for (TaxonBase taxonBase : taxonAndSynonyms) { + @SuppressWarnings("rawtypes") + Set taxonAndSynonyms = taxonName.getTaxonBases(); + for (TaxonBase taxonBase : taxonAndSynonyms) { if(taxonBase.isInstanceOf(Synonym.class)){ Synonym synonym = HibernateProxyHelper.deproxy(taxonBase, Synonym.class); Taxon acceptedTaxonOfSynonym = synonym.getAcceptedTaxon(); @@ -968,7 +956,6 @@ public abstract class SpecimenImportBase config = state.getConfig(); String scientificName = ""; boolean preferredFlag = false; @@ -1280,7 +1267,6 @@ public abstract class SpecimenImportBase linkedSources = derivedUnitBase2.getSources(); for (IdentifiableSource is:linkedSources){ @@ -1315,7 +1295,6 @@ public abstract class SpecimenImportBase boolean sourceNotLinkedToElement(ISourceable sourcable, Reference reference, String microReference) { + private boolean sourceNotLinkedToElement( + ISourceable sourcable, Reference reference, String microReference) { + Set linkedSources = sourcable.getSources(); for (T is:linkedSources){ Reference unitReference = is.getCitation(); @@ -1384,8 +1363,6 @@ public abstract class SpecimenImportBase unit) { SpecimenOrObservationType type = unit.getRecordBasis(); - - if (type.isFeatureObservation()){ return Feature.OBSERVATION(); }else if (type.isFeatureSpecimen()){ @@ -1402,11 +1379,6 @@ public abstract class SpecimenImportBase sourceMap, Set osbSet) { for( OriginalSourceBase osb:osbSet) { if(osb.getCitation()!=null && osb.getCitationMicroReference() !=null && !osb.getCitationMicroReference().isEmpty()) { @@ -1420,8 +1392,4 @@ public abstract class SpecimenImportBase derivedUnitSources = new ArrayList<>(); private boolean derivedUnitSourcesSet=false; private boolean descriptionGroupSet = false; - protected HashMap institutions = new HashMap<>(); - protected HashMap collections= new HashMap<>(); - protected HashMap names= new HashMap<>(); - private HashMap fieldUnits = new HashMap<>(); + protected Map institutions = new HashMap<>(); + protected Map collections= new HashMap<>(); + protected Map names= new HashMap<>(); + private Map fieldUnits = new HashMap<>(); - MapWrapper> personStore; + private MapWrapper> personStore; private Map importReferences = new HashMap<>(); private URI actualAccessPoint; private Set allAccesPoints = new HashSet<>(); -- 2.34.1