specimen import/search changes
authorKatja Luther <k.luther@bgbm.org>
Fri, 30 Sep 2016 14:09:54 +0000 (16:09 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 30 Sep 2016 14:09:54 +0000 (16:09 +0200)
17 files changed:
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/bioCase/BioCaseQueryGenerator.java
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifJsonOccurrenceParser.java
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/occurrence/gbif/GbifQueryGenerator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/service/IOServiceImpl.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenDataHolder.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportConfiguratorBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/UnitsGatheringEvent.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206DataHolder.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206ImportState.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206XMLFieldGetter.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportReport.java [changed mode: 0755->0644]
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/AbcdGgbnImportTest.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/HHH_9751_Util.java
cdmlib-services/src/main/resources/eu/etaxonomy/cdm/httpInvokerServices.xml
cdmlib-services/src/main/resources/eu/etaxonomy/cdm/remoting-services.xml

index 877813121eff80e3b2c324b3a31bdd2d8b670170..e721e260b5dad6a2a004233a61f13cb26adc2392 100644 (file)
@@ -146,7 +146,11 @@ public class BioCaseQueryGenerator {
             }
         }
         if(query.accessionNumber!=null && !query.accessionNumber.trim().isEmpty()){
-            addLikeFilter(elAnd, query.accessionNumber, ACCESSION_NUMBER_PATH_ABCD_2_0);
+            Element elOr = new Element(OR);
+            addLikeFilter(elOr, query.accessionNumber, ACCESSION_NUMBER_PATH_ABCD_2_0);
+            addLikeFilter(elOr, query.accessionNumber, CAT_PATH_ABCD_2_0);
+            addLikeFilter(elOr, query.accessionNumber, UNIT_ID_PATH_ABCD_2_0);
+            elAnd.addContent(elOr);
         }
         if(query.collector!=null && !query.collector.trim().isEmpty()){
             addLikeFilter(elAnd, query.collector, COLLECTOR_PATH_ABCD_2_0);
index e5093acbe45d9e3f1d15a954713b3f148dd7a176..8a09953394d9398468b37de25cda9e6fb01cc895 100644 (file)
@@ -24,10 +24,12 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpException;
 import org.apache.log4j.Logger;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.common.UriUtils;
+import eu.etaxonomy.cdm.common.media.ImageInfo;
 import eu.etaxonomy.cdm.model.agent.Institution;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
@@ -35,6 +37,9 @@ import eu.etaxonomy.cdm.model.common.TimePeriod;
 import eu.etaxonomy.cdm.model.location.Country;
 import eu.etaxonomy.cdm.model.location.Point;
 import eu.etaxonomy.cdm.model.location.ReferenceSystem;
+import eu.etaxonomy.cdm.model.media.ImageFile;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.name.BacterialName;
 import eu.etaxonomy.cdm.model.name.BotanicalName;
 import eu.etaxonomy.cdm.model.name.CultivarPlantName;
@@ -158,6 +163,9 @@ public class GbifJsonOccurrenceParser {
 
     private static final String BACTERIA = "Bacteria";
 
+    private static final String MULTIMEDIA = "media";
+
+
 
 
 
@@ -419,6 +427,64 @@ public class GbifJsonOccurrenceParser {
                     derivedUnitFacade.addSource(source);
                 }
 
+                if (record.has(MULTIMEDIA)){
+                    //http://ww2.bgbm.org/herbarium/images/B/-W/08/53/B_-W_08537%20-00%201__3.jpg
+                    JSONArray multimediaArray = record.getJSONArray(MULTIMEDIA);
+                    JSONObject mediaRecord;
+                    Media media;
+                    URI uri = null;
+                    ImageInfo imageInf = null;
+                    MediaRepresentation representation = null;
+                    SpecimenOrObservationType type = null;
+                    for(Object object:multimediaArray){
+                        //parse every record
+                       media = Media.NewInstance();
+                       uri = null;
+                       imageInf = null;
+
+                        if(object instanceof JSONObject){
+                            mediaRecord = (JSONObject) object;
+
+                            if (mediaRecord.has("identifier")){
+                                try {
+                                    uri = new URI(mediaRecord.getString("identifier"));
+                                    imageInf = ImageInfo.NewInstance(uri, 0);
+
+                                } catch (URISyntaxException |IOException | HttpException e) {
+                                    // TODO Auto-generated catch block
+                                    e.printStackTrace();
+                                }
+                               // media.addIdentifier(mediaRecord.getString("identifier"), null);
+                            }
+                            if (mediaRecord.has("references")){
+
+
+                            }
+                            if (mediaRecord.has("format")){
+
+                            }
+                            if (mediaRecord.has("type")){
+                                if (mediaRecord.get("type").equals("StillImage")){
+                                    type = SpecimenOrObservationType.StillImage;
+                                }
+                            }
+
+                            }
+                            ImageFile imageFile = ImageFile.NewInstance(uri, null, imageInf);
+                            representation = MediaRepresentation.NewInstance();
+
+                            representation.addRepresentationPart(imageFile);
+                            media.addRepresentation(representation);
+
+                            derivedUnitFacade.addDerivedUnitMedia(media);
+                        }
+                    //identifier=http://ww2.bgbm.org/herbarium/images/B/-W/08/53/B_-W_08537%20-00%201__3.jpg
+                   //references=http://ww2.bgbm.org/herbarium/view_biocase.cfm?SpecimenPK=136628
+                    //format=image/jpeg
+                    //type=StillImage
+
+                }
+
                 // create dataset URL
                 URI uri = null;
                 try {
index e16dd09ba0030ac20a3c2fdd58d2b537c448ccfb..2da830573c5973212a47e6a922bebf7b02893ed0 100644 (file)
@@ -36,7 +36,7 @@ public class GbifQueryGenerator {
         // only look for preserved specimens
 
         if (checkForValidQuery(query)) {
-            ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "basisOfRecord", "PRESERVED_SPECIMEN");
+            //ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "basisOfRecord", "PRESERVED_SPECIMEN");
 
             ServiceWrapperBase.addNameValuePairTo(queryParamsGET, "limit", "100");
             if (query.tripleIds != null){
index 7b6401cd0e0ce1a74473015b5a4a4b9a88ec449f..3c61e6c6ab6a01dec022dbac3b543b80eede2a78 100644 (file)
@@ -53,6 +53,7 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+import eu.etaxonomy.cdm.model.reference.ReferenceType;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
@@ -636,8 +637,12 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                                ref.setAuthorship(taxonNameBase.getCombinationAuthorship());
                            }
 
-                           ref.setProtectedAbbrevTitleCache(false);
-                           ref.setProtectedTitleCache(false);
+                           if (ref.getAbbrevTitle() == null && !ref.isOfType(ReferenceType.Article)) {
+                    ref.setAbbrevTitle(reference);
+                    ref.setProtectedAbbrevTitleCache(false);
+                }
+
+                ref.setProtectedTitleCache(false);
 
                            taxonNameBase.setNomenclaturalReference(ref);
                        }
index af4b97f30312b0c2e3a86ba5d40b7c318718b3ea..a1593f45c9d3852a14bf898eeb6924de02b06e99 100644 (file)
-// $Id$
-/**
- * Copyright (C) 2015 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.service;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.UUID;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
-import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
-import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread;
-import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
-import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;
-import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
-import eu.etaxonomy.cdm.io.common.ExportResult;
-import eu.etaxonomy.cdm.io.common.IExportConfigurator;
-import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;
-import eu.etaxonomy.cdm.io.common.IImportConfigurator;
-import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
-import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
-import eu.etaxonomy.cdm.io.common.ImportResult;
-import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
-
-/**
- * @author cmathew
- * @date 31 Jul 2015
- *
- */
-@Service
-@Transactional(readOnly = false)
-public class IOServiceImpl implements IIOService {
-
-    @Autowired
-    CdmApplicationAwareDefaultExport cdmExport;
-
-    @Autowired
-    @Qualifier("defaultImport")
-    CdmApplicationAwareDefaultImport cdmImport;
-
-    @Autowired
-    IProgressMonitorService progressMonitorService;
-
-
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.io.service.IExportService#export(eu.etaxonomy.cdm.io.common.IExportConfigurator)
-     */
-    @Override
-    public ExportResult export(IExportConfigurator config) {
-        config.setTarget(TARGET.EXPORT_DATA);
-        return cdmExport.execute(config);
-    }
-
-
-    @Override
-    public UUID monitImportData(final IImportConfigurator configurator, final byte[] importData, final SOURCE_TYPE type) {
-        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
-            @Override
-            public Serializable doRun(IRemotingProgressMonitor monitor) {
-                configurator.setProgressMonitor(monitor);
-                ImportResult result = importData(configurator, importData, type);
-                for(byte[] report : result.getReports()) {
-                    monitor.addReport(new String(report));
-                }
-                return result;
-            }
-        };
-        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
-        monitorThread.setPriority(3);
-        monitorThread.start();
-        return uuid;
-    }
-
-    @Override
-    public ImportResult importData(IImportConfigurator configurator, byte[] importData, SOURCE_TYPE type) {
-        ImportResult result;
-        switch(type) {
-        case URI:
-            return importDataFromUri(configurator, importData);
-        case INPUTSTREAM:
-            return importDataFromInputStream(configurator,importData);
-        default :
-            throw new RuntimeException("Source type is not recongnised");
-        }
-    }
-
-    @Override
-    public ImportResult importDataFromUri(IImportConfigurator configurator, byte[] importData) {
-        ImportResult result;
-
-        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
-        String suffix = ".import";
-        String prefix = "cdm-";
-        FileOutputStream stream = null;
-
-        try {
-            Path tempFilePath = Files.createTempFile(prefix, suffix);
-            stream = new FileOutputStream(tempFilePath.toFile());
-            stream.write(importData);
-            config.setSource(tempFilePath.toUri());
-            result = cdmImport.execute(config);
-            Files.delete(tempFilePath);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            if(stream != null) {
-                try {
-                    stream.close();
-                } catch (IOException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public ImportResult importDataFromInputStream(IImportConfigurator configurator, byte[] importData) {
-        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
-        ImportResult result;
-        try {
-            config.setSource(new ByteArrayInputStream(importData));
-            result = cdmImport.execute(config);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-        return result;
-    }
-
-
-    @Override
-    public ImportResult importDataFromStream(SpecimenImportConfiguratorBase configurator) {
-        ImportResult result = new ImportResult();
-
-            OccurenceQuery query;
-            result = cdmImport.execute(configurator);
-            return result;
-    }
-
-    @Override
-    public ImportResult importDataFromStream(List<Abcd206ImportConfigurator> configurators) {
-        ImportResult result = new ImportResult();
-
-            OccurenceQuery query;
-            for (SpecimenImportConfiguratorBase configurator:configurators){
-                result = cdmImport.execute(configurator);
-            }
-            return result;
-    }
-
-
-
-
-
-}
+// $Id$\r
+/**\r
+ * Copyright (C) 2015 EDIT\r
+ * European Distributed Institute of Taxonomy\r
+ * http://www.e-taxonomy.eu\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version 1.1\r
+ * See LICENSE.TXT at the top of this package for the full license terms.\r
+ */\r
+package eu.etaxonomy.cdm.io.service;\r
+\r
+import java.io.ByteArrayInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.Serializable;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
+import java.util.List;\r
+import java.util.UUID;\r
+\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.beans.factory.annotation.Qualifier;\r
+import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Transactional;\r
+\r
+import eu.etaxonomy.cdm.api.service.IProgressMonitorService;\r
+import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;\r
+import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread;\r
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;\r
+import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;\r
+import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;\r
+import eu.etaxonomy.cdm.io.common.ExportResult;\r
+import eu.etaxonomy.cdm.io.common.IExportConfigurator;\r
+import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;\r
+import eu.etaxonomy.cdm.io.common.IImportConfigurator;\r
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;\r
+import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;\r
+import eu.etaxonomy.cdm.io.common.ImportResult;\r
+import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;\r
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;\r
+\r
+/**\r
+ * @author cmathew\r
+ * @date 31 Jul 2015\r
+ *\r
+ */\r
+@Service\r
+@Transactional(readOnly = false)\r
+public class IOServiceImpl implements IIOService {\r
+\r
+    @Autowired\r
+    CdmApplicationAwareDefaultExport cdmExport;\r
+\r
+    @Autowired\r
+    @Qualifier("defaultImport")\r
+    CdmApplicationAwareDefaultImport cdmImport;\r
+\r
+    @Autowired\r
+    IProgressMonitorService progressMonitorService;\r
+\r
+\r
+\r
+    /* (non-Javadoc)\r
+     * @see eu.etaxonomy.cdm.io.service.IExportService#export(eu.etaxonomy.cdm.io.common.IExportConfigurator)\r
+     */\r
+    @Override\r
+    public ExportResult export(IExportConfigurator config) {\r
+        config.setTarget(TARGET.EXPORT_DATA);\r
+        return cdmExport.execute(config);\r
+    }\r
+\r
+\r
+    @Override\r
+    public UUID monitImportData(final IImportConfigurator configurator, final byte[] importData, final SOURCE_TYPE type) {\r
+        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {\r
+            @Override\r
+            public Serializable doRun(IRemotingProgressMonitor monitor) {\r
+                configurator.setProgressMonitor(monitor);\r
+                ImportResult result = importData(configurator, importData, type);\r
+                for(byte[] report : result.getReports()) {\r
+                    monitor.addReport(new String(report));\r
+                }\r
+                return result;\r
+            }\r
+        };\r
+        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);\r
+        monitorThread.setPriority(3);\r
+        monitorThread.start();\r
+        return uuid;\r
+    }\r
+\r
+    @Override\r
+    public ImportResult importData(IImportConfigurator configurator, byte[] importData, SOURCE_TYPE type) {\r
+        ImportResult result;\r
+        switch(type) {\r
+        case URI:\r
+            return importDataFromUri(configurator, importData);\r
+        case INPUTSTREAM:\r
+            return importDataFromInputStream(configurator,importData);\r
+        default :\r
+            throw new RuntimeException("Source type is not recongnised");\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public ImportResult importDataFromUri(IImportConfigurator configurator, byte[] importData) {\r
+        ImportResult result;\r
+\r
+        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;\r
+        String suffix = ".import";\r
+        String prefix = "cdm-";\r
+        FileOutputStream stream = null;\r
+\r
+        try {\r
+            Path tempFilePath = Files.createTempFile(prefix, suffix);\r
+            stream = new FileOutputStream(tempFilePath.toFile());\r
+            stream.write(importData);\r
+            config.setSource(tempFilePath.toUri());\r
+            result = cdmImport.execute(config);\r
+     //       Files.delete(tempFilePath);\r
+        } catch (Exception e) {\r
+            throw new RuntimeException(e);\r
+        } finally {\r
+            if(stream != null) {\r
+                try {\r
+                    stream.close();\r
+                } catch (IOException e) {\r
+                    throw new RuntimeException(e);\r
+                }\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public ImportResult importDataFromInputStream(IImportConfigurator configurator, byte[] importData) {\r
+        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;\r
+        ImportResult result;\r
+        try {\r
+            config.setSource(new ByteArrayInputStream(importData));\r
+            result = cdmImport.execute(config);\r
+        } catch (Exception e) {\r
+            throw new RuntimeException(e);\r
+        }\r
+        return result;\r
+    }\r
+\r
+\r
+    @Override\r
+    public ImportResult importDataFromStream(SpecimenImportConfiguratorBase configurator) {\r
+        ImportResult result = new ImportResult();\r
+\r
+            OccurenceQuery query;\r
+            result = cdmImport.execute(configurator);\r
+            return result;\r
+    }\r
+\r
+    @Override\r
+    public ImportResult importDataFromStream(List<Abcd206ImportConfigurator> configurators) {\r
+        ImportResult result = new ImportResult();\r
+\r
+            OccurenceQuery query;\r
+            for (SpecimenImportConfiguratorBase configurator:configurators){\r
+                result = cdmImport.execute(configurator);\r
+            }\r
+            return result;\r
+    }\r
+\r
+\r
+\r
+\r
+\r
+}\r
index 486f76d15f9ab9198715895abf9aa2c1c8eee9de..e69a57802a47f2f10c1652f415d330bc053e22d0 100644 (file)
-// $Id$
-/**
-* Copyright (C) 2016 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.specimen;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification;
-import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
-
-/**
- * @author k.luther
- * @date 18.07.2016
- *
- */
-public class SpecimenDataHolder {
-
-    protected String nomenclatureCode;
-    protected List<HashMap<String, String>> atomisedIdentificationList;
-    private String recordBasis;
-    protected String gatheringElevationText;
-    private String gatheringElevationMin;
-    private String gatheringElevationMax;
-    private String gatheringNotes;
-    private String gatheringDateText;
-
-    protected String gatheringElevation;
-
-    private String gatheringElevationUnit;
-    private String gatheringSpatialDatum;
-    private String gatheringCoordinateErrorMethod;
-    private String kindOfUnit;
-
-    private Map<String, String> namedAreaList;
-    private String fieldNumber;
-    private String unitNotes; //  occurenceRemarks(DwCA)
-
-    private List<String> multimediaObjects;
-    private List<Identification> identificationList;
-
-    private List<SpecimenTypeDesignationStatus> statusList;
-
-    private List<String[]> referenceList;
-    private List<String> docSources;
-    private String unitID;
-
-
-
-
-
-    /**
-     * @return the nomenclatureCode
-     */
-    public String getNomenclatureCode() {
-        return nomenclatureCode;
-    }
-
-
-
-    /**
-     * @param nomenclatureCode the nomenclatureCode to set
-     */
-    public void setNomenclatureCode(String nomenclatureCode) {
-        this.nomenclatureCode = nomenclatureCode;
-    }
-
-
-
-    /**
-     * @return the atomisedIdentificationList
-     */
-    public List<HashMap<String, String>> getAtomisedIdentificationList() {
-        return atomisedIdentificationList;
-    }
-
-
-
-    /**
-     * @param atomisedIdentificationList the atomisedIdentificationList to set
-     */
-    public void setAtomisedIdentificationList(List<HashMap<String, String>> atomisedIdentificationList) {
-        this.atomisedIdentificationList = atomisedIdentificationList;
-    }
-
-
-
-    /**
-     * @return the gatheringElevationText
-     */
-    public String getGatheringElevationText() {
-        return gatheringElevationText;
-    }
-
-
-
-    /**
-     * @param gatheringElevationText the gatheringElevationText to set
-     */
-    public void setGatheringElevationText(String gatheringElevationText) {
-        this.gatheringElevationText = gatheringElevationText;
-    }
-
-
-
-    /**
-     * @return the gatheringElevationMax
-     */
-    public String getGatheringElevationMax() {
-        return gatheringElevationMax;
-    }
-
-
-
-    /**
-     * @param gatheringElevationMax the gatheringElevationMax to set
-     */
-    public void setGatheringElevationMax(String gatheringElevationMax) {
-        this.gatheringElevationMax = gatheringElevationMax;
-    }
-
-
-
-    /**
-     * @return the gatheringElevationMin
-     */
-    public String getGatheringElevationMin() {
-        return gatheringElevationMin;
-    }
-
-
-
-    /**
-     * @param gatheringElevationMin the gatheringElevationMin to set
-     */
-    public void setGatheringElevationMin(String gatheringElevationMin) {
-        this.gatheringElevationMin = gatheringElevationMin;
-    }
-
-
-
-    /**
-     * @return the kindOfUnit
-     */
-    public String getKindOfUnit() {
-        return kindOfUnit;
-    }
-
-
-
-    /**
-     * @param kindOfUnit the kindOfUnit to set
-     */
-    public void setKindOfUnit(String kindOfUnit) {
-        this.kindOfUnit = kindOfUnit;
-    }
-
-
-
-    /**
-     * @return the gatheringElevationUnit
-     */
-    public String getGatheringElevationUnit() {
-        return gatheringElevationUnit;
-    }
-
-
-
-    /**
-     * @param gatheringElevationUnit the gatheringElevationUnit to set
-     */
-    public void setGatheringElevationUnit(String gatheringElevationUnit) {
-        this.gatheringElevationUnit = gatheringElevationUnit;
-    }
-
-
-
-    /**
-     * @return the gatheringDateText
-     */
-    public String getGatheringDateText() {
-        return gatheringDateText;
-    }
-
-
-
-    /**
-     * @param gatheringDateText the gatheringDateText to set
-     */
-    public void setGatheringDateText(String gatheringDateText) {
-        this.gatheringDateText = gatheringDateText;
-    }
-
-
-
-    /**
-     * @return the gatheringNotes
-     */
-    public String getGatheringNotes() {
-        return gatheringNotes;
-    }
-
-
-
-    /**
-     * @param gatheringNotes the gatheringNotes to set
-     */
-    public void setGatheringNotes(String gatheringNotes) {
-        this.gatheringNotes = gatheringNotes;
-    }
-
-
-
-    /**
-     * @return the gatheringSpatialDatum
-     */
-    public String getGatheringSpatialDatum() {
-        return gatheringSpatialDatum;
-    }
-
-
-
-    /**
-     * @param gatheringSpatialDatum the gatheringSpatialDatum to set
-     */
-    public void setGatheringSpatialDatum(String gatheringSpatialDatum) {
-        this.gatheringSpatialDatum = gatheringSpatialDatum;
-    }
-
-
-
-    /**
-     * @return the namedAreaList
-     */
-    public Map<String, String> getNamedAreaList() {
-        return namedAreaList;
-    }
-
-
-
-    /**
-     * @param namedAreaList the namedAreaList to set
-     */
-    public void setNamedAreaList(Map<String, String> namedAreaList) {
-        this.namedAreaList = namedAreaList;
-    }
-
-
-
-    /**
-     * @return the gatheringCoordinateErrorMethod
-     */
-    public String getGatheringCoordinateErrorMethod() {
-        return gatheringCoordinateErrorMethod;
-    }
-
-
-
-    /**
-     * @param gatheringCoordinateErrorMethod the gatheringCoordinateErrorMethod to set
-     */
-    public void setGatheringCoordinateErrorMethod(String gatheringCoordinateErrorMethod) {
-        this.gatheringCoordinateErrorMethod = gatheringCoordinateErrorMethod;
-    }
-
-
-
-    /**
-     *
-     */
-    public void reset() {
-        nomenclatureCode = null;
-        atomisedIdentificationList = new ArrayList<HashMap<String,String>>();
-        gatheringDateText = null;
-        gatheringNotes = null;
-        kindOfUnit = null;
-
-        setRecordBasis(null);
-        gatheringElevationText = null;
-        gatheringElevationMin = null;
-        gatheringElevationMax = null;
-        gatheringNotes = null;
-        gatheringDateText = null;
-
-        gatheringElevation = null;
-
-        gatheringElevationUnit = null;
-        gatheringSpatialDatum = null;
-       gatheringCoordinateErrorMethod = null;
-
-
-    }
-
-
-
-    /**
-     * @return the fieldNumber
-     */
-    public String getFieldNumber() {
-        return fieldNumber;
-    }
-
-
-
-    /**
-     * @param fieldNumber the fieldNumber to set
-     */
-    public void setFieldNumber(String fieldNumber) {
-        this.fieldNumber = fieldNumber;
-    }
-
-
-
-    /**
-     * @return the unitNotes
-     */
-    public String getUnitNotes() {
-        return unitNotes;
-    }
-
-
-
-    /**
-     * @param unitNotes the unitNotes to set
-     */
-    public void setUnitNotes(String unitNotes) {
-        this.unitNotes = unitNotes;
-    }
-
-
-
-    /**
-     * @return the multimediaObjects
-     */
-    public List<String> getMultimediaObjects() {
-        return multimediaObjects;
-    }
-
-
-
-    /**
-     * @param multimediaObjects the multimediaObjects to set
-     */
-    public void setMultimediaObjects(List<String> multimediaObjects) {
-        this.multimediaObjects = multimediaObjects;
-    }
-
-
-
-    /**
-     * @return the identificationList
-     */
-    public List<Identification> getIdentificationList() {
-        return identificationList;
-    }
-
-
-
-    /**
-     * @param identificationList the identificationList to set
-     */
-    public void setIdentificationList(List<Identification> identificationList) {
-        this.identificationList = identificationList;
-    }
-
-
-
-    /**
-     * @return the statusList
-     */
-    public List<SpecimenTypeDesignationStatus> getStatusList() {
-        return statusList;
-    }
-
-
-
-    /**
-     * @param statusList the statusList to set
-     */
-    public void setStatusList(List<SpecimenTypeDesignationStatus> statusList) {
-        this.statusList = statusList;
-    }
-
-
-
-    /**
-     * @return the referenceList
-     */
-    public List<String[]> getReferenceList() {
-        return referenceList;
-    }
-
-
-
-    /**
-     * @param referenceList the referenceList to set
-     */
-    public void setReferenceList(List<String[]> referenceList) {
-        this.referenceList = referenceList;
-    }
-
-
-
-    /**
-     * @return the docSources
-     */
-    public List<String> getDocSources() {
-        return docSources;
-    }
-
-
-
-    /**
-     * @param docSources the docSources to set
-     */
-    public void setDocSources(List<String> docSources) {
-        this.docSources = docSources;
-    }
-
-
-
-    /**
-     * @return the unitID
-     */
-    public String getUnitID() {
-        return unitID;
-    }
-
-
-
-    /**
-     * @param unitID the unitID to set
-     */
-    public void setUnitID(String unitID) {
-        this.unitID = unitID;
-    }
-
-
-
-    /**
-     * @return the recordBasis
-     */
-    public String getRecordBasis() {
-        return recordBasis;
-    }
-
-
-
-    /**
-     * @param recordBasis the recordBasis to set
-     */
-    public void setRecordBasis(String recordBasis) {
-        this.recordBasis = recordBasis;
-    }
-}
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.cdm.io.specimen;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;\r
+\r
+/**\r
+ * @author k.luther\r
+ * @date 18.07.2016\r
+ *\r
+ */\r
+public class SpecimenDataHolder {\r
+\r
+    protected String nomenclatureCode;\r
+    protected List<HashMap<String, String>> atomisedIdentificationList;\r
+    private String recordBasis;\r
+    protected String gatheringElevationText;\r
+    private String gatheringElevationMin;\r
+    private String gatheringElevationMax;\r
+    private String gatheringNotes;\r
+    private String gatheringDateText;\r
+\r
+    protected String gatheringElevation;\r
+\r
+    private String gatheringElevationUnit;\r
+    protected Double depth;\r
+    /**\r
+     * @return the depth\r
+     */\r
+    public Double getDepth() {\r
+        return depth;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param depth the depth to set\r
+     */\r
+    public void setDepth(Double depth) {\r
+        this.depth = depth;\r
+    }\r
+\r
+\r
+\r
+    private String gatheringSpatialDatum;\r
+    private String gatheringCoordinateErrorMethod;\r
+    private String kindOfUnit;\r
+\r
+    private Map<String, String> namedAreaList;\r
+    private String fieldNumber;\r
+    private String unitNotes; //  occurenceRemarks(DwCA)\r
+\r
+    private HashMap<String, Map<String,String>> multimediaObjects;\r
+    private HashMap<String, Map<String,String>> gatheringMultimediaObjects;\r
+    private List<Identification> identificationList;\r
+\r
+    private List<SpecimenTypeDesignationStatus> statusList;\r
+\r
+    private List<String[]> referenceList;\r
+    private List<String> docSources;\r
+    private String unitID;\r
+\r
+\r
+\r
+\r
+\r
+    /**\r
+     * @return the nomenclatureCode\r
+     */\r
+    public String getNomenclatureCode() {\r
+        return nomenclatureCode;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param nomenclatureCode the nomenclatureCode to set\r
+     */\r
+    public void setNomenclatureCode(String nomenclatureCode) {\r
+        this.nomenclatureCode = nomenclatureCode;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the atomisedIdentificationList\r
+     */\r
+    public List<HashMap<String, String>> getAtomisedIdentificationList() {\r
+        return atomisedIdentificationList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param atomisedIdentificationList the atomisedIdentificationList to set\r
+     */\r
+    public void setAtomisedIdentificationList(List<HashMap<String, String>> atomisedIdentificationList) {\r
+        this.atomisedIdentificationList = atomisedIdentificationList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringElevationText\r
+     */\r
+    public String getGatheringElevationText() {\r
+        return gatheringElevationText;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringElevationText the gatheringElevationText to set\r
+     */\r
+    public void setGatheringElevationText(String gatheringElevationText) {\r
+        this.gatheringElevationText = gatheringElevationText;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringElevationMax\r
+     */\r
+    public String getGatheringElevationMax() {\r
+        return gatheringElevationMax;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringElevationMax the gatheringElevationMax to set\r
+     */\r
+    public void setGatheringElevationMax(String gatheringElevationMax) {\r
+        this.gatheringElevationMax = gatheringElevationMax;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringElevationMin\r
+     */\r
+    public String getGatheringElevationMin() {\r
+        return gatheringElevationMin;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringElevationMin the gatheringElevationMin to set\r
+     */\r
+    public void setGatheringElevationMin(String gatheringElevationMin) {\r
+        this.gatheringElevationMin = gatheringElevationMin;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the kindOfUnit\r
+     */\r
+    public String getKindOfUnit() {\r
+        return kindOfUnit;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param kindOfUnit the kindOfUnit to set\r
+     */\r
+    public void setKindOfUnit(String kindOfUnit) {\r
+        this.kindOfUnit = kindOfUnit;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringElevationUnit\r
+     */\r
+    public String getGatheringElevationUnit() {\r
+        return gatheringElevationUnit;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringElevationUnit the gatheringElevationUnit to set\r
+     */\r
+    public void setGatheringElevationUnit(String gatheringElevationUnit) {\r
+        this.gatheringElevationUnit = gatheringElevationUnit;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringDateText\r
+     */\r
+    public String getGatheringDateText() {\r
+        return gatheringDateText;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringDateText the gatheringDateText to set\r
+     */\r
+    public void setGatheringDateText(String gatheringDateText) {\r
+        this.gatheringDateText = gatheringDateText;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringNotes\r
+     */\r
+    public String getGatheringNotes() {\r
+        return gatheringNotes;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringNotes the gatheringNotes to set\r
+     */\r
+    public void setGatheringNotes(String gatheringNotes) {\r
+        this.gatheringNotes = gatheringNotes;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringSpatialDatum\r
+     */\r
+    public String getGatheringSpatialDatum() {\r
+        return gatheringSpatialDatum;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringSpatialDatum the gatheringSpatialDatum to set\r
+     */\r
+    public void setGatheringSpatialDatum(String gatheringSpatialDatum) {\r
+        this.gatheringSpatialDatum = gatheringSpatialDatum;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the namedAreaList\r
+     */\r
+    public Map<String, String> getNamedAreaList() {\r
+        return namedAreaList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param namedAreaList the namedAreaList to set\r
+     */\r
+    public void setNamedAreaList(Map<String, String> namedAreaList) {\r
+        this.namedAreaList = namedAreaList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringCoordinateErrorMethod\r
+     */\r
+    public String getGatheringCoordinateErrorMethod() {\r
+        return gatheringCoordinateErrorMethod;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringCoordinateErrorMethod the gatheringCoordinateErrorMethod to set\r
+     */\r
+    public void setGatheringCoordinateErrorMethod(String gatheringCoordinateErrorMethod) {\r
+        this.gatheringCoordinateErrorMethod = gatheringCoordinateErrorMethod;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     *\r
+     */\r
+    public void reset() {\r
+        nomenclatureCode = null;\r
+        atomisedIdentificationList = new ArrayList<HashMap<String,String>>();\r
+        gatheringDateText = null;\r
+        gatheringNotes = null;\r
+        kindOfUnit = null;\r
+\r
+        setRecordBasis(null);\r
+        gatheringElevationText = null;\r
+        gatheringElevationMin = null;\r
+        gatheringElevationMax = null;\r
+        gatheringNotes = null;\r
+        gatheringDateText = null;\r
+\r
+        gatheringElevation = null;\r
+\r
+        gatheringElevationUnit = null;\r
+        gatheringSpatialDatum = null;\r
+        gatheringCoordinateErrorMethod = null;\r
+        depth = null;\r
+\r
+\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the fieldNumber\r
+     */\r
+    public String getFieldNumber() {\r
+        return fieldNumber;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param fieldNumber the fieldNumber to set\r
+     */\r
+    public void setFieldNumber(String fieldNumber) {\r
+        this.fieldNumber = fieldNumber;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the unitNotes\r
+     */\r
+    public String getUnitNotes() {\r
+        return unitNotes;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param unitNotes the unitNotes to set\r
+     */\r
+    public void setUnitNotes(String unitNotes) {\r
+        this.unitNotes = unitNotes;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the multimediaObjects\r
+     */\r
+    public HashMap<String,Map<String, String>> getMultimediaObjects() {\r
+        return multimediaObjects;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param multimediaObjects the multimediaObjects to set\r
+     */\r
+    public void setMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {\r
+        this.multimediaObjects = multimediaObjects;\r
+    }\r
+\r
+    public void putMultiMediaObject(String uri, Map<String, String> attributes){\r
+        this.multimediaObjects.put(uri, attributes);\r
+    }\r
+\r
+    /**\r
+     * @return the multimediaObjects\r
+     */\r
+    public HashMap<String,Map<String, String>> getGatheringMultimediaObjects() {\r
+        return gatheringMultimediaObjects;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param multimediaObjects the multimediaObjects to set\r
+     */\r
+    public void setGatheringMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {\r
+        this.gatheringMultimediaObjects = multimediaObjects;\r
+    }\r
+\r
+    public void putGatheringMultiMediaObject(String uri, Map<String, String> attributes){\r
+        this.gatheringMultimediaObjects.put(uri, attributes);\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the identificationList\r
+     */\r
+    public List<Identification> getIdentificationList() {\r
+        return identificationList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param identificationList the identificationList to set\r
+     */\r
+    public void setIdentificationList(List<Identification> identificationList) {\r
+        this.identificationList = identificationList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the statusList\r
+     */\r
+    public List<SpecimenTypeDesignationStatus> getStatusList() {\r
+        return statusList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param statusList the statusList to set\r
+     */\r
+    public void setStatusList(List<SpecimenTypeDesignationStatus> statusList) {\r
+        this.statusList = statusList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the referenceList\r
+     */\r
+    public List<String[]> getReferenceList() {\r
+        return referenceList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param referenceList the referenceList to set\r
+     */\r
+    public void setReferenceList(List<String[]> referenceList) {\r
+        this.referenceList = referenceList;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the docSources\r
+     */\r
+    public List<String> getDocSources() {\r
+        return docSources;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param docSources the docSources to set\r
+     */\r
+    public void setDocSources(List<String> docSources) {\r
+        this.docSources = docSources;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the unitID\r
+     */\r
+    public String getUnitID() {\r
+        return unitID;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param unitID the unitID to set\r
+     */\r
+    public void setUnitID(String unitID) {\r
+        this.unitID = unitID;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the recordBasis\r
+     */\r
+    public String getRecordBasis() {\r
+        return recordBasis;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param recordBasis the recordBasis to set\r
+     */\r
+    public void setRecordBasis(String recordBasis) {\r
+        this.recordBasis = recordBasis;\r
+    }\r
+}\r
index 235dd163374f369378573f8d6a5b7f2054d01fb5..08a42c5d1fabea4c4067efba211f98f8e8da4c40 100644 (file)
-// $Id$
-/**
-* Copyright (C) 2016 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.specimen;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
-import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
-import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
-import eu.etaxonomy.cdm.model.agent.Person;
-import eu.etaxonomy.cdm.model.agent.Team;
-
-/**
- * @author k.luther
- * @date 15.07.2016
- *
- */
-public abstract class SpecimenImportConfiguratorBase<STATE extends SpecimenImportStateBase, InputStream>  extends ImportConfiguratorBase<STATE, InputStream> {
-
-    /**
-     * @param transformer
-     */
-    public SpecimenImportConfiguratorBase(IInputTransformer transformer) {
-        super(transformer);
-
-    }
-
-    private boolean ignoreImportOfExistingSpecimen = true;
-    private boolean reuseExistingTaxaWhenPossible = true;
-    private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
-
-    private Map<String, Team> titleCacheTeam;
-    private Map<String, Person> titleCachePerson;
-    private boolean ignoreAuthorship = false;
-    private boolean removeCountryFromLocalityText = false;
-    protected OccurenceQuery query ;
-
-    private boolean addMediaAsMediaSpecimen = false;
-    private boolean reuseExistingMetaData = true;
-
-    private static String sourceReferenceTitle = null;
-
-    private String taxonReference = null;
-    private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations = true;
-    private boolean reuseExistingDescriptiveGroups = false;
-
-
-    private String defaultAuthor="";
-    private boolean allowReuseOtherClassifications =true;
-
-    private boolean deduplicateReferences = false;
-    private boolean deduplicateClassifications = false;
-
-    private boolean moveNewTaxaToDefaultClassification = true;
-
-    private boolean mapUnitIdToCatalogNumber = true;
-    private boolean mapUnitIdToAccessionNumber = false;
-    private boolean mapUnitIdToBarcode = false;
-
-    private boolean overwriteExistingSpecimens = false;
-
-
-    private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();
-
-    protected Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
-
-    private URI reportUri;
-
-
-    public boolean isIgnoreImportOfExistingSpecimen() {
-        return ignoreImportOfExistingSpecimen;
-    }
-
-    public void setIgnoreImportOfExistingSpecimen(boolean ignoreImportOfExistingSpecimen) {
-        this.ignoreImportOfExistingSpecimen = ignoreImportOfExistingSpecimen;
-    }
-
-    public Map<String, Team> getTitleCacheTeam() {
-        return titleCacheTeam;
-    }
-
-    public void setTitleCacheTeam(Map<String, Team> titleCacheTeam) {
-        this.titleCacheTeam = titleCacheTeam;
-    }
-
-    public Map<String, Person> getTitleCachePerson() {
-        return titleCachePerson;
-    }
-
-    public void setTitleCachePerson(Map<String, Person> titleCachePerson) {
-        this.titleCachePerson = titleCachePerson;
-    }
-
-    public OccurenceQuery getQuery() {
-        return query;
-    }
-
-    public void setQuery(OccurenceQuery query) {
-        this.query = query;
-    }
-
-
-
-
-
-    public String getTaxonReference() {
-        return taxonReference;
-    }
-
-    public void setTaxonReference(String taxonReference) {
-        this.taxonReference = taxonReference;
-    }
-
-    public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
-        return addIndividualsAssociationsSuchAsSpecimenAndObservations;
-    }
-
-    public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
-            boolean addIndividualsAssociationsSuchAsSpecimenAndObservations) {
-        this.addIndividualsAssociationsSuchAsSpecimenAndObservations = addIndividualsAssociationsSuchAsSpecimenAndObservations;
-    }
-
-    public boolean isReuseExistingDescriptiveGroups() {
-        return reuseExistingDescriptiveGroups;
-    }
-
-    public void setReuseExistingDescriptiveGroups(boolean reuseExistingDescriptiveGroups) {
-        this.reuseExistingDescriptiveGroups = reuseExistingDescriptiveGroups;
-    }
-
-    public String getDefaultAuthor() {
-        return defaultAuthor;
-    }
-
-    public void setDefaultAuthor(String defaultAuthor) {
-        this.defaultAuthor = defaultAuthor;
-    }
-
-    public boolean isAllowReuseOtherClassifications() {
-        return allowReuseOtherClassifications;
-    }
-
-    public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications) {
-        this.allowReuseOtherClassifications = allowReuseOtherClassifications;
-    }
-
-    public boolean isDeduplicateReferences() {
-        return deduplicateReferences;
-    }
-
-    public void setDeduplicateReferences(boolean deduplicateReferences) {
-        this.deduplicateReferences = deduplicateReferences;
-    }
-
-    public boolean isDeduplicateClassifications() {
-        return deduplicateClassifications;
-    }
-
-    public void setDeduplicateClassifications(boolean deduplicateClassifications) {
-        this.deduplicateClassifications = deduplicateClassifications;
-    }
-
-    public boolean isMoveNewTaxaToDefaultClassification() {
-        return moveNewTaxaToDefaultClassification;
-    }
-
-    public void setMoveNewTaxaToDefaultClassification(boolean moveNewTaxaToDefaultClassification) {
-        this.moveNewTaxaToDefaultClassification = moveNewTaxaToDefaultClassification;
-    }
-
-    public boolean isMapUnitIdToCatalogNumber() {
-        return mapUnitIdToCatalogNumber;
-    }
-
-    public void setMapUnitIdToCatalogNumber(boolean mapUnitIdToCatalogNumber) {
-        this.mapUnitIdToCatalogNumber = mapUnitIdToCatalogNumber;
-    }
-
-    public boolean isMapUnitIdToAccessionNumber() {
-        return mapUnitIdToAccessionNumber;
-    }
-
-    public void setMapUnitIdToAccessionNumber(boolean mapUnitIdToAccessionNumber) {
-        this.mapUnitIdToAccessionNumber = mapUnitIdToAccessionNumber;
-    }
-
-    public boolean isMapUnitIdToBarcode() {
-        return mapUnitIdToBarcode;
-    }
-
-    public void setMapUnitIdToBarcode(boolean mapUnitIdToBarcode) {
-        this.mapUnitIdToBarcode = mapUnitIdToBarcode;
-    }
-
-    public Map<String, UUID> getNamedAreaDecisions() {
-        return namedAreaDecisions;
-    }
-
-
-    public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {
-        this.namedAreaDecisions = namedAreaDecisions;
-    }
-
-    public void putNamedAreaDecision(String areaStr,UUID uuid){
-        this.namedAreaDecisions.put(areaStr,uuid);
-    }
-
-    public UUID getNamedAreaDecision(String areaStr){
-        return namedAreaDecisions.get(areaStr);
-    }
-
-    public Map<UUID, UUID> getTaxonToDescriptionMap() {
-        return taxonToDescriptionMap;
-    }
-
-
-
-    public SpecimenUserInteraction getSpecimenUserInteraction() {
-        return specimenUserInteraction;
-    }
-
-    public void setReuseExistingTaxaWhenPossible(boolean reuseExistingTaxaWhenPossible) {
-        this.reuseExistingTaxaWhenPossible = reuseExistingTaxaWhenPossible;
-    }
-
-    public void setIgnoreAuthorship(boolean ignoreAuthorship) {
-        this.ignoreAuthorship = ignoreAuthorship;
-    }
-
-    public void setRemoveCountryFromLocalityText(boolean removeCountryFromLocalityText) {
-        this.removeCountryFromLocalityText = removeCountryFromLocalityText;
-    }
-
-    public void setAddMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen) {
-        this.addMediaAsMediaSpecimen = addMediaAsMediaSpecimen;
-    }
-
-    public void setOverwriteExistingSpecimens(boolean overwriteExistingSpecimens) {
-        this.overwriteExistingSpecimens = overwriteExistingSpecimens;
-    }
-
-    public boolean isOverwriteExistingSpecimens(){
-        return overwriteExistingSpecimens;
-    }
-
-
-
-
-    /**
-     * @return
-     */
-    public boolean isReuseExistingTaxaWhenPossible() {
-
-        return reuseExistingTaxaWhenPossible;
-    }
-
-    /**
-     * @param titleCacheTeam
-     */
-    public void setTeams(Map<String, Team> titleCacheTeam) {
-       this.titleCacheTeam  = titleCacheTeam;
-
-    }
-
-    public Team getTeam(String titleCache){
-        return titleCacheTeam.get(titleCache);
-    }
-
-    public Map<String, Team> getTeams(){
-        return titleCacheTeam;
-    }
-    /**
-     * @param titleCachePerson
-     */
-    public void setPersons(Map<String, Person> titleCachePerson) {
-        this.titleCachePerson = titleCachePerson;
-    }
-
-    public Map<String, Person> getPersons(){
-        return titleCachePerson;
-    }
-
-    public Person getPerson(String titleCache){
-        return titleCachePerson.get(titleCache);
-    }
-
-    public boolean isAddMediaAsMediaSpecimen(){
-        return addMediaAsMediaSpecimen;
-    }
-
-    public void addMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen){
-       this.addMediaAsMediaSpecimen = addMediaAsMediaSpecimen;
-    }
-
-
-    /**
-     * @return
-     */
-    public boolean isIgnoreAuthorship() {
-        return ignoreAuthorship;
-    }
-
-    /**
-     * @return
-     */
-    public boolean isRemoveCountryFromLocalityText() {
-        return removeCountryFromLocalityText;
-    }
-
-    public OccurenceQuery getOccurenceQuery(){
-        return query;
-    }
-
-    public void setOccurenceQuery(OccurenceQuery query){
-        this.query = query;
-    }
-
-
-
-    /**
-     * @return the reuseExistingMetaData
-     */
-    public boolean isReuseExistingMetaData() {
-        return reuseExistingMetaData;
-    }
-
-    /**
-     * @param reuseExistingMetaData the reuseExistingMetaData to set
-     */
-    public void setReuseExistingMetaData(boolean reuseExistingMetaData) {
-        this.reuseExistingMetaData = reuseExistingMetaData;
-    }
-
-    public void setReportUri(URI reportUri) {
-        this.reportUri = reportUri;
-    }
-
-    public URI getReportUri() {
-        return reportUri;
-    }
-
-    @Override
-    public String getSourceReferenceTitle(){
-        return this.sourceReferenceTitle;
-    }
-
-    @Override
-    public void setSourceReferenceTitle(String name){
-        this.sourceReferenceTitle=name;
-    }
-
-    @Override
-    public boolean isValid(){
-        return true;
-    }
-
-
-
-}
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.cdm.io.specimen;\r
+\r
+import java.net.URI;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.UUID;\r
+\r
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;\r
+import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;\r
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;\r
+import eu.etaxonomy.cdm.model.agent.Person;\r
+import eu.etaxonomy.cdm.model.agent.Team;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;\r
+\r
+/**\r
+ * @author k.luther\r
+ * @date 15.07.2016\r
+ *\r
+ */\r
+public abstract class SpecimenImportConfiguratorBase<STATE extends SpecimenImportStateBase, InputStream>  extends ImportConfiguratorBase<STATE, InputStream> {\r
+\r
+    /**\r
+     * @param transformer\r
+     */\r
+    public SpecimenImportConfiguratorBase(IInputTransformer transformer) {\r
+        super(transformer);\r
+\r
+    }\r
+\r
+    private boolean ignoreImportOfExistingSpecimen = true;\r
+    private boolean reuseExistingTaxaWhenPossible = true;\r
+    private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();\r
+\r
+    private Map<String, Team> titleCacheTeam;\r
+    private Map<String, Person> titleCachePerson;\r
+    private boolean ignoreAuthorship = false;\r
+    private boolean removeCountryFromLocalityText = false;\r
+    protected OccurenceQuery query ;\r
+\r
+    private boolean addMediaAsMediaSpecimen = false;\r
+    private boolean reuseExistingMetaData = true;\r
+\r
+    private static String sourceReferenceTitle = null;\r
+\r
+    private String taxonReference = null;\r
+    private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations = true;\r
+    private boolean reuseExistingDescriptiveGroups = false;\r
+\r
+\r
+    private String defaultAuthor="";\r
+    private boolean allowReuseOtherClassifications =true;\r
+\r
+    private boolean deduplicateReferences = false;\r
+    private boolean deduplicateClassifications = false;\r
+\r
+    private boolean moveNewTaxaToDefaultClassification = true;\r
+\r
+    private boolean mapUnitIdToCatalogNumber = true;\r
+    private boolean mapUnitIdToAccessionNumber = false;\r
+    private boolean mapUnitIdToBarcode = false;\r
+\r
+    private boolean overwriteExistingSpecimens = false;\r
+\r
+    private SpecimenOrObservationType type;\r
+\r
+\r
+    /**\r
+     * @return the type\r
+     */\r
+    public SpecimenOrObservationType getType() {\r
+        return type;\r
+    }\r
+\r
+    /**\r
+     * @param type the type to set\r
+     */\r
+    public void setType(SpecimenOrObservationType type) {\r
+        this.type = type;\r
+    }\r
+\r
+    private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();\r
+\r
+    protected Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();\r
+\r
+    private URI reportUri;\r
+\r
+\r
+    public boolean isIgnoreImportOfExistingSpecimen() {\r
+        return ignoreImportOfExistingSpecimen;\r
+    }\r
+\r
+    public void setIgnoreImportOfExistingSpecimen(boolean ignoreImportOfExistingSpecimen) {\r
+        this.ignoreImportOfExistingSpecimen = ignoreImportOfExistingSpecimen;\r
+    }\r
+\r
+    public Map<String, Team> getTitleCacheTeam() {\r
+        return titleCacheTeam;\r
+    }\r
+\r
+    public void setTitleCacheTeam(Map<String, Team> titleCacheTeam) {\r
+        this.titleCacheTeam = titleCacheTeam;\r
+    }\r
+\r
+    public Map<String, Person> getTitleCachePerson() {\r
+        return titleCachePerson;\r
+    }\r
+\r
+    public void setTitleCachePerson(Map<String, Person> titleCachePerson) {\r
+        this.titleCachePerson = titleCachePerson;\r
+    }\r
+\r
+    public OccurenceQuery getQuery() {\r
+        return query;\r
+    }\r
+\r
+    public void setQuery(OccurenceQuery query) {\r
+        this.query = query;\r
+    }\r
+\r
+\r
+\r
+\r
+\r
+    public String getTaxonReference() {\r
+        return taxonReference;\r
+    }\r
+\r
+    public void setTaxonReference(String taxonReference) {\r
+        this.taxonReference = taxonReference;\r
+    }\r
+\r
+    public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {\r
+        return addIndividualsAssociationsSuchAsSpecimenAndObservations;\r
+    }\r
+\r
+    public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(\r
+            boolean addIndividualsAssociationsSuchAsSpecimenAndObservations) {\r
+        this.addIndividualsAssociationsSuchAsSpecimenAndObservations = addIndividualsAssociationsSuchAsSpecimenAndObservations;\r
+    }\r
+\r
+    public boolean isReuseExistingDescriptiveGroups() {\r
+        return reuseExistingDescriptiveGroups;\r
+    }\r
+\r
+    public void setReuseExistingDescriptiveGroups(boolean reuseExistingDescriptiveGroups) {\r
+        this.reuseExistingDescriptiveGroups = reuseExistingDescriptiveGroups;\r
+    }\r
+\r
+    public String getDefaultAuthor() {\r
+        return defaultAuthor;\r
+    }\r
+\r
+    public void setDefaultAuthor(String defaultAuthor) {\r
+        this.defaultAuthor = defaultAuthor;\r
+    }\r
+\r
+    public boolean isAllowReuseOtherClassifications() {\r
+        return allowReuseOtherClassifications;\r
+    }\r
+\r
+    public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications) {\r
+        this.allowReuseOtherClassifications = allowReuseOtherClassifications;\r
+    }\r
+\r
+    public boolean isDeduplicateReferences() {\r
+        return deduplicateReferences;\r
+    }\r
+\r
+    public void setDeduplicateReferences(boolean deduplicateReferences) {\r
+        this.deduplicateReferences = deduplicateReferences;\r
+    }\r
+\r
+    public boolean isDeduplicateClassifications() {\r
+        return deduplicateClassifications;\r
+    }\r
+\r
+    public void setDeduplicateClassifications(boolean deduplicateClassifications) {\r
+        this.deduplicateClassifications = deduplicateClassifications;\r
+    }\r
+\r
+    public boolean isMoveNewTaxaToDefaultClassification() {\r
+        return moveNewTaxaToDefaultClassification;\r
+    }\r
+\r
+    public void setMoveNewTaxaToDefaultClassification(boolean moveNewTaxaToDefaultClassification) {\r
+        this.moveNewTaxaToDefaultClassification = moveNewTaxaToDefaultClassification;\r
+    }\r
+\r
+    public boolean isMapUnitIdToCatalogNumber() {\r
+        return mapUnitIdToCatalogNumber;\r
+    }\r
+\r
+    public void setMapUnitIdToCatalogNumber(boolean mapUnitIdToCatalogNumber) {\r
+        this.mapUnitIdToCatalogNumber = mapUnitIdToCatalogNumber;\r
+    }\r
+\r
+    public boolean isMapUnitIdToAccessionNumber() {\r
+        return mapUnitIdToAccessionNumber;\r
+    }\r
+\r
+    public void setMapUnitIdToAccessionNumber(boolean mapUnitIdToAccessionNumber) {\r
+        this.mapUnitIdToAccessionNumber = mapUnitIdToAccessionNumber;\r
+    }\r
+\r
+    public boolean isMapUnitIdToBarcode() {\r
+        return mapUnitIdToBarcode;\r
+    }\r
+\r
+    public void setMapUnitIdToBarcode(boolean mapUnitIdToBarcode) {\r
+        this.mapUnitIdToBarcode = mapUnitIdToBarcode;\r
+    }\r
+\r
+    public Map<String, UUID> getNamedAreaDecisions() {\r
+        return namedAreaDecisions;\r
+    }\r
+\r
+\r
+    public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {\r
+        this.namedAreaDecisions = namedAreaDecisions;\r
+    }\r
+\r
+    public void putNamedAreaDecision(String areaStr,UUID uuid){\r
+        this.namedAreaDecisions.put(areaStr,uuid);\r
+    }\r
+\r
+    public UUID getNamedAreaDecision(String areaStr){\r
+        return namedAreaDecisions.get(areaStr);\r
+    }\r
+\r
+    public Map<UUID, UUID> getTaxonToDescriptionMap() {\r
+        return taxonToDescriptionMap;\r
+    }\r
+\r
+\r
+\r
+    public SpecimenUserInteraction getSpecimenUserInteraction() {\r
+        return specimenUserInteraction;\r
+    }\r
+\r
+    public void setReuseExistingTaxaWhenPossible(boolean reuseExistingTaxaWhenPossible) {\r
+        this.reuseExistingTaxaWhenPossible = reuseExistingTaxaWhenPossible;\r
+    }\r
+\r
+    public void setIgnoreAuthorship(boolean ignoreAuthorship) {\r
+        this.ignoreAuthorship = ignoreAuthorship;\r
+    }\r
+\r
+    public void setRemoveCountryFromLocalityText(boolean removeCountryFromLocalityText) {\r
+        this.removeCountryFromLocalityText = removeCountryFromLocalityText;\r
+    }\r
+\r
+    public void setAddMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen) {\r
+        this.addMediaAsMediaSpecimen = addMediaAsMediaSpecimen;\r
+    }\r
+\r
+    public void setOverwriteExistingSpecimens(boolean overwriteExistingSpecimens) {\r
+        this.overwriteExistingSpecimens = overwriteExistingSpecimens;\r
+    }\r
+\r
+    public boolean isOverwriteExistingSpecimens(){\r
+        return overwriteExistingSpecimens;\r
+    }\r
+\r
+\r
+\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    public boolean isReuseExistingTaxaWhenPossible() {\r
+\r
+        return reuseExistingTaxaWhenPossible;\r
+    }\r
+\r
+    /**\r
+     * @param titleCacheTeam\r
+     */\r
+    public void setTeams(Map<String, Team> titleCacheTeam) {\r
+       this.titleCacheTeam  = titleCacheTeam;\r
+\r
+    }\r
+\r
+    public Team getTeam(String titleCache){\r
+        return titleCacheTeam.get(titleCache);\r
+    }\r
+\r
+    public Map<String, Team> getTeams(){\r
+        return titleCacheTeam;\r
+    }\r
+    /**\r
+     * @param titleCachePerson\r
+     */\r
+    public void setPersons(Map<String, Person> titleCachePerson) {\r
+        this.titleCachePerson = titleCachePerson;\r
+    }\r
+\r
+    public Map<String, Person> getPersons(){\r
+        return titleCachePerson;\r
+    }\r
+\r
+    public Person getPerson(String titleCache){\r
+        return titleCachePerson.get(titleCache);\r
+    }\r
+\r
+    public boolean isAddMediaAsMediaSpecimen(){\r
+        return addMediaAsMediaSpecimen;\r
+    }\r
+\r
+    public void addMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen){\r
+       this.addMediaAsMediaSpecimen = addMediaAsMediaSpecimen;\r
+    }\r
+\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    public boolean isIgnoreAuthorship() {\r
+        return ignoreAuthorship;\r
+    }\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    public boolean isRemoveCountryFromLocalityText() {\r
+        return removeCountryFromLocalityText;\r
+    }\r
+\r
+    public OccurenceQuery getOccurenceQuery(){\r
+        return query;\r
+    }\r
+\r
+    public void setOccurenceQuery(OccurenceQuery query){\r
+        this.query = query;\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @return the reuseExistingMetaData\r
+     */\r
+    public boolean isReuseExistingMetaData() {\r
+        return reuseExistingMetaData;\r
+    }\r
+\r
+    /**\r
+     * @param reuseExistingMetaData the reuseExistingMetaData to set\r
+     */\r
+    public void setReuseExistingMetaData(boolean reuseExistingMetaData) {\r
+        this.reuseExistingMetaData = reuseExistingMetaData;\r
+    }\r
+\r
+    public void setReportUri(URI reportUri) {\r
+        this.reportUri = reportUri;\r
+    }\r
+\r
+    public URI getReportUri() {\r
+        return reportUri;\r
+    }\r
+\r
+    @Override\r
+    public String getSourceReferenceTitle(){\r
+        return this.sourceReferenceTitle;\r
+    }\r
+\r
+    @Override\r
+    public void setSourceReferenceTitle(String name){\r
+        this.sourceReferenceTitle=name;\r
+    }\r
+\r
+    @Override\r
+    public boolean isValid(){\r
+        return true;\r
+    }\r
+\r
+\r
+\r
+}\r
index 1a0af42d5c7080fd55b71b464df2d7ee6dad31ae..cc18a7460f68a7ee12e43fe54a38d211f192d249 100644 (file)
@@ -10,9 +10,9 @@
 package eu.etaxonomy.cdm.io.specimen;
 
 
-import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import org.apache.commons.lang.StringUtils;
@@ -26,6 +26,7 @@ import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenSynthesysExcelImportConfigu
 import eu.etaxonomy.cdm.io.taxonx2013.TaxonXImportConfigurator;
 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.Annotation;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Language;
@@ -95,23 +96,27 @@ public class UnitsGatheringEvent {
      */
     public UnitsGatheringEvent(ITermService termService, String locality, String languageIso, Double longitude,
             Double latitude, String elevationText, String elevationMin, String elevationMax, String elevationUnit,
-            String date, String gatheringNotes, ReferenceSystem referenceSystem, List<String> collectorName,
-            List<String> team, Abcd206ImportConfigurator config) {
+            String date, String gatheringNotes, ReferenceSystem referenceSystem,
+             Abcd206ImportConfigurator config) {
         this.setLocality(termService, locality, languageIso);
         this.setCoordinates(longitude, latitude, referenceSystem);
         this.setDate(date);
         this.setNotes(gatheringNotes);
         this.setElevation(elevationText, elevationMin, elevationMax, elevationUnit);
-        if (!collectorName.isEmpty()) {
-            List<String> tmp =  new ArrayList<String>(new HashSet<String>(collectorName));
-            this.setCollector(tmp.get(0), config);
-        }
-        if (!team.isEmpty()) {
-            List<String> tmpTeam = new ArrayList<String>(new HashSet<String>(team));
-            this.setTeam(StringUtils.join(tmpTeam," & "), config);
-        }
+
+
+
+
+
     }
 
+    /**
+     * @param gatheringImages
+     */
+    public void setGatheringImages(HashMap<String, Map<String, String>> gatheringImages) {
+
+
+    }
     public GatheringEvent getGatheringEvent(){
         return this.gatheringEvent;
     }
@@ -236,6 +241,49 @@ public class UnitsGatheringEvent {
         }
     }
 
+    public void setHeight(String heightText, String heightMin, String heightMax, String heightUnit){
+        if(heightText!=null){
+            this.gatheringEvent.setAbsoluteElevationText(heightText);
+        }
+        else{
+            //TODO check for unit at string end
+            String pattern = "\\D";// regex for non-digits
+            if(heightMin!=null){
+                Double min = Double.parseDouble(heightMin.replaceAll(pattern, ""));
+                this.gatheringEvent.setDistanceToGround(min);
+            }
+            if(heightMax!=null){
+                Double max = Double.parseDouble(heightMax.replaceAll(pattern, ""));
+                this.gatheringEvent.setDistanceToGroundMax(max);
+            }
+            if(heightUnit!=null){
+                if (!heightUnit.equals("m")){
+                    logger.debug("The unit " + heightUnit + " of the distance to ground is not meter.");
+                }
+            }
+        }
+    }
+
+    public void setGatheringDepth(String depthText, Double depthMin, Double depthMax, String depthUnit){
+        if(depthText!=null){
+            this.gatheringEvent.setDistanceToWaterSurfaceText(depthText);
+        }
+        else{
+
+            if(depthMin!=null){
+                this.gatheringEvent.setDistanceToWaterSurface(depthMin);
+            }
+            if(depthMax!=null){
+                this.gatheringEvent.setDistanceToWaterSurfaceMax(depthMax);
+            }
+            if(depthUnit!=null){
+                if (!depthUnit.equals("m")){
+                    logger.debug("The unit " + depthUnit + " of the distance to ground is not meter.");
+                }
+            }
+        }
+    }
+
     /*
      * Add a NamedArea to the GatheringEvent
      * @param area: the NamedArea to add
@@ -293,15 +341,13 @@ public class UnitsGatheringEvent {
      * @param: collectorNames: the list of names to add as collector/collectorTeam
      * USED - create each time a new Collector
      */
-    public void setCollector(String collectorName, Abcd206ImportConfigurator config){
+    public void setCollector(TeamOrPersonBase collector, Abcd206ImportConfigurator config){
         //        System.out.println("collectors : "+collectorNames.toString());
-        Person collector;
-        collector = Person.NewInstance();
-        collector.setTitleCache(collectorName, true);
+
         if (DEBUG) {
             System.out.println("getcoll:"+config.getPersons().get(collector.getTitleCache()));
         }
-       // this.gatheringEvent.setCollector(config.getPersons().get(collector.getTitleCache()));
+        this.gatheringEvent.setCollector(collector);
     }
 
     /**
index d4d87d0344adcdb20cb17a6330ed1fb70d7754f4..d87b928b0292c386f3efc677e8d56ef9f1ca3073 100644 (file)
@@ -12,6 +12,7 @@ package eu.etaxonomy.cdm.io.specimen.abcd206.in;
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
@@ -30,8 +31,8 @@ public class Abcd206DataHolder extends SpecimenDataHolder{
 \r
     protected List<String> knownABCDelements = new ArrayList<String>();\r
     protected HashMap<String,String> allABCDelements = new HashMap<String,String>();\r
-    public List<String> gatheringAgentList;\r
-    protected List<String> gatheringTeamList;\r
+    public String gatheringAgents ="";\r
+\r
 \r
     //per unit\r
 \r
@@ -55,9 +56,17 @@ public class Abcd206DataHolder extends SpecimenDataHolder{
     protected String languageIso;\r
     protected String country;\r
     protected String isocountry;\r
-    protected Integer depth;\r
+\r
+\r
     protected Integer altitude;\r
 \r
+    private String gatheringDepthUnit;\r
+\r
+    private Double gatheringDepthMax;\r
+\r
+    private Double gatheringDepthMin;\r
+    private String gatheringDepthText;\r
+\r
 \r
 \r
 \r
@@ -77,7 +86,7 @@ public class Abcd206DataHolder extends SpecimenDataHolder{
         languageIso = null;\r
         country = null;\r
         isocountry = null;\r
-        depth = null;\r
+\r
         altitude = null;\r
 \r
         gatheringElevationText = null;\r
@@ -85,7 +94,8 @@ public class Abcd206DataHolder extends SpecimenDataHolder{
 \r
 \r
         setReferenceList(new ArrayList<String[]>());\r
-        setMultimediaObjects(new ArrayList<String>());\r
+        setMultimediaObjects(new HashMap<String,Map<String, String>>());\r
+        setGatheringMultimediaObjects(new HashMap<String,Map<String, String>>());\r
         setDocSources(new ArrayList<String>());\r
         associatedUnitIds = new ArrayList<String>();\r
     }\r
@@ -93,4 +103,69 @@ public class Abcd206DataHolder extends SpecimenDataHolder{
 \r
 \r
 \r
+    /**\r
+     * @param textContent\r
+     */\r
+    public void setGatheringDepthMin(Double gatheringDepthMin) {\r
+        this.gatheringDepthMin = gatheringDepthMin;\r
+\r
+    }\r
+\r
+    public Double getGatheringDepthMin() {\r
+        return gatheringDepthMin;\r
+\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param textContent\r
+     */\r
+    public void setGatheringDepthMax(Double gatheringDepthMax) {\r
+        this.gatheringDepthMax = gatheringDepthMax;\r
+\r
+    }\r
+\r
+    public Double getGatheringDepthMax() {\r
+        return gatheringDepthMax;\r
+\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * @param textContent\r
+     */\r
+    public void setGatheringDepthUnit(String gatheringDepthUnit) {\r
+        this.gatheringDepthUnit = gatheringDepthUnit;\r
+\r
+    }\r
+\r
+    public String getGatheringDepthUnit() {\r
+        return gatheringDepthUnit;\r
+\r
+    }\r
+\r
+\r
+\r
+\r
+\r
+    /**\r
+     * @return the gatheringDepthText\r
+     */\r
+    public String getGatheringDepthText() {\r
+        return gatheringDepthText;\r
+    }\r
+\r
+\r
+\r
+\r
+    /**\r
+     * @param gatheringDepthText the gatheringDepthText to set\r
+     */\r
+    public void setGatheringDepthText(String gatheringDepthText) {\r
+        this.gatheringDepthText = gatheringDepthText;\r
+    }\r
+\r
+\r
 }\r
index 3f2ace41fc8d2c06a09921760f9d086bf8bd0931..f6f11317f5dd43279f29049cdc31a3e34d1db163 100644 (file)
@@ -29,21 +29,24 @@ import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.io.common.ICdmIO;
+import eu.etaxonomy.cdm.io.common.MapWrapper;
 import eu.etaxonomy.cdm.io.specimen.SpecimenImportBase;
 import eu.etaxonomy.cdm.io.specimen.SpecimenUserInteraction;
 import eu.etaxonomy.cdm.io.specimen.UnitsGatheringArea;
 import eu.etaxonomy.cdm.io.specimen.UnitsGatheringEvent;
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.molecular.AbcdDnaParser;
-import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Institution;
 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.Annotation;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.LanguageString;
 import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.common.OriginalSourceType;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
@@ -63,7 +66,7 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
 import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 
 /**
  * @author p.kelbert
@@ -96,6 +99,11 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
     @SuppressWarnings("rawtypes")
     public void doInvoke(Abcd206ImportState state) {
         Abcd206ImportConfigurator config = state.getConfig();
+        Map<String, MapWrapper<? extends CdmBase>> stores = state.getStores();
+        MapWrapper<TeamOrPersonBase<?>> authorStore = (MapWrapper<TeamOrPersonBase<?>>)stores.get(ICdmIO.TEAM_STORE);
+        state.setPersonStore(authorStore);
+        MapWrapper<Reference> referenceStore = (MapWrapper<Reference>)stores.get(ICdmIO.REFERENCE_STORE);
+        MapWrapper<TaxonBase> taxonBaseStore = (MapWrapper<TaxonBase>)stores.get(ICdmIO.TAXON_STORE);
         try{
             state.setTx(startTransaction());
             logger.info("INVOKE Specimen Import from ABCD2.06 XML ");
@@ -118,7 +126,7 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
 
             //init import reference
         //  List<Reference> references = getReferenceService().list(Reference.class, null, null, null, null);
-            List<Reference> references = new ArrayList<Reference>();
+         //   List<Reference> references = new ArrayList<Reference>();
 
 //            if (state.getConfig().isInteractWithUser()){
 //                Map<String,Reference> refMap = new HashMap<String, Reference>();
@@ -144,7 +152,7 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
 //            }else{
                 if (state.getRef()==null){
                     String name = NB(((Abcd206ImportConfigurator) state.getConfig()).getSourceReferenceTitle());
-                    for (Reference reference : references) {
+                    for (Reference reference : referenceStore.getAllValues()) {
                         if (! StringUtils.isBlank(reference.getTitleCache())) {
                             if (reference.getTitleCache().equalsIgnoreCase(name)) {
                                 state.setRef(reference);
@@ -223,6 +231,13 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
 
                 prepareCollectors(state, unitsList, abcdFieldGetter);
 
+
+                // save authors
+                getAgentService().saveOrUpdate((java.util.Collection)state.getPersonStore().objects());
+
+                commitTransaction(state.getTx());
+                state.setTx(startTransaction());
+
                 state.setAssociationRefs(new ArrayList<OriginalSourceBase<?>>());
                 state.setDescriptionRefs(new ArrayList<OriginalSourceBase<?>>());
                 state.setDerivedUnitSources(new ArrayList<OriginalSourceBase<?>>());
@@ -330,10 +345,13 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
                     state.getDataHolder().getGatheringElevationMin(), state.getDataHolder().getGatheringElevationMax(),
                     state.getDataHolder().getGatheringElevationUnit(), state.getDataHolder().getGatheringDateText(),
                     state.getDataHolder().getGatheringNotes(), state.getTransformer().getReferenceSystemByKey(
-                            state.getDataHolder().getGatheringSpatialDatum()), state.getDataHolder().gatheringAgentList,
-                    state.getDataHolder().gatheringTeamList, state.getConfig());
+                            state.getDataHolder().getGatheringSpatialDatum()),
+                     state.getConfig());
 
-            // country
+            unitsGatheringEvent.setGatheringDepth(state.getDataHolder().getGatheringDepthText(),state.getDataHolder().getGatheringDepthMin(), state.getDataHolder().getGatheringDepthMax(), state.getDataHolder().getGatheringDepthUnit());
+            //unitsGatheringEvent.setHeight(heightText, heightMin, heightMax, heightUnit);
+            unitsGatheringEvent.setCollector(state.getPersonStore().get(state.getDataHolder().gatheringAgents), config);
+            // count
             UnitsGatheringArea unitsGatheringArea = new UnitsGatheringArea();
             //  unitsGatheringArea.setConfig(state.getConfig(),getOccurrenceService(), getTermService());
             unitsGatheringArea.setParams(state.getDataHolder().isocountry, state.getDataHolder().country, (state.getConfig()), cdmAppController.getTermService(), cdmAppController.getOccurrenceService());
@@ -360,6 +378,12 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
             derivedUnitFacade.setAbsoluteElevationText(gatheringEvent.getAbsoluteElevationText());
             derivedUnitFacade.setAbsoluteElevation(gatheringEvent.getAbsoluteElevation());
             derivedUnitFacade.setAbsoluteElevationMax(gatheringEvent.getAbsoluteElevationMax());
+            derivedUnitFacade.setDistanceToGroundText(gatheringEvent.getDistanceToGroundText());
+            derivedUnitFacade.setDistanceToGroundMax(gatheringEvent.getDistanceToGroundMax());
+            derivedUnitFacade.setDistanceToGround(gatheringEvent.getDistanceToGround());
+            derivedUnitFacade.setDistanceToWaterSurfaceText(gatheringEvent.getDistanceToWaterSurfaceText());
+            derivedUnitFacade.setDistanceToWaterSurfaceMax(gatheringEvent.getDistanceToWaterSurfaceMax());
+            derivedUnitFacade.setDistanceToWaterSurface(gatheringEvent.getDistanceToWaterSurface());
             derivedUnitFacade.setGatheringPeriod(gatheringEvent.getTimeperiod());
 
             for(DefinedTermBase<?> area:unitsGatheringArea.getAreas()){
@@ -374,17 +398,54 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
             // add unitNotes
             derivedUnitFacade.addAnnotation(Annotation.NewDefaultLanguageInstance(NB(state.getDataHolder().getUnitNotes())));
 
+
+
             // //add Multimedia URLs
             if (state.getDataHolder().getMultimediaObjects().size() != -1) {
-                for (String multimediaObject : state.getDataHolder().getMultimediaObjects()) {
+                for (String multimediaObject : state.getDataHolder().getMultimediaObjects().keySet()) {
                     Media media;
                     try {
                         media = getImageMedia(multimediaObject, READ_MEDIA_DATA);
+                        Map<String, String> attributes = state.getDataHolder().getMultimediaObjects().get(multimediaObject);
+                        if (attributes.containsKey("Context")){
+                            LanguageString description = LanguageString.NewInstance(attributes.get("Context"), Language.ENGLISH());
+                            media.addDescription(description);
+                        }
+                        if (attributes.containsKey("Comment")){
+                            LanguageString description = LanguageString.NewInstance(attributes.get("Comment"), Language.ENGLISH());
+                            media.addDescription(description);
+                        }
+                        if (attributes.containsKey("Creators")){
+                            String creators = attributes.get("Creators");
+                            Person artist;
+                            Team artistTeam;
+                            String[] artists;
+                            if (creators != null){
+                                if (creators.contains("&")){
+                                    artists = creators.split("&");
+                                    artistTeam = new Team();
+                                    for (String creator:artists){
+                                        artist = Person.NewTitledInstance(creator);
+                                        artistTeam.addTeamMember(artist);
+                                    }
+                                    media.setArtist(artistTeam);
+                                } else{
+
+                                    artist = Person.NewTitledInstance(creators);
+                                    media.setArtist(artist);
+                                }
+                            }
+
+
+
+                        }
+
                         derivedUnitFacade.addDerivedUnitMedia(media);
                         if(((Abcd206ImportConfigurator)state.getConfig()).isAddMediaAsMediaSpecimen()){
                             //add media also as specimen scan
                             MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
                             mediaSpecimen.setMediaSpecimen(media);
+                            //do it only once!!
                             DefinedTermBase specimenScanTerm = getTermService().load(SPECIMEN_SCAN_TERM);
                             if(specimenScanTerm instanceof DefinedTerm){
                                 mediaSpecimen.setKindOfUnit((DefinedTerm) specimenScanTerm);
@@ -401,6 +462,56 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
 
                 }
             }
+            //multimedia for fieldUnit
+            if (state.getDataHolder().getGatheringMultimediaObjects().size() != -1) {
+                for (String multimediaObject : state.getDataHolder().getGatheringMultimediaObjects().keySet()) {
+                    Media media;
+                    try {
+                        media = getImageMedia(multimediaObject, READ_MEDIA_DATA);
+                        Map<String, String> attributes = state.getDataHolder().getGatheringMultimediaObjects().get(multimediaObject);
+                        if (attributes.containsKey("Context")){
+                            LanguageString description = LanguageString.NewInstance(attributes.get("Context"), Language.ENGLISH());
+                            media.addDescription(description);
+                        }
+                        if (attributes.containsKey("Comment")){
+                            LanguageString description = LanguageString.NewInstance(attributes.get("Comment"), Language.ENGLISH());
+                            media.addDescription(description);
+                        }
+                        if (attributes.containsKey("Creators")){
+                            String creators = attributes.get("Creators");
+                            Person artist;
+                            Team artistTeam;
+                            String[] artists;
+                            if (creators != null){
+                                if (creators.contains("&")){
+                                    artists = creators.split("&");
+                                    artistTeam = new Team();
+                                    for (String creator:artists){
+                                        artist = Person.NewTitledInstance(creator);
+                                        artistTeam.addTeamMember(artist);
+                                    }
+                                    media.setArtist(artistTeam);
+                                } else{
+
+                                    artist = Person.NewTitledInstance(creators);
+                                    media.setArtist(artist);
+                                }
+                            }
+
+
+
+                        }
+
+                        derivedUnitFacade.addFieldObjectMedia(media);
+
+
+                    } catch (MalformedURLException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+
+                }
+            }
 
             //                 /*
             //                  * merge AND STORE DATA
@@ -410,7 +521,7 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
             //                 for (NamedArea area : otherAreas) {
             //                         getTermService().saveOrUpdate(area);// merge it sooner (foreach area)
             //                 }
-
+           save(derivedUnitFacade.getFieldUnit(false), state);
             save(unitsGatheringEvent.getLocality(), state);
 
             // handle collection data
@@ -769,8 +880,8 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
                 break;
             }
         }
-        state.getDataHolder().gatheringAgentList = new ArrayList<String>();
-        state.getDataHolder().gatheringTeamList = new ArrayList<String>();
+        //state.getDataHolder().gatheringAgents = "";
+
         abcdFieldGetter.getType(root);
         abcdFieldGetter.getGatheringPeople(root);
     }
@@ -798,7 +909,8 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
             state.getDataHolder().setStatusList(new ArrayList<SpecimenTypeDesignationStatus>());
             state.getDataHolder().setAtomisedIdentificationList(new ArrayList<HashMap<String, String>>());
             state.getDataHolder().setReferenceList(new ArrayList<String[]>());
-            state.getDataHolder().setMultimediaObjects(new ArrayList<String>());
+            state.getDataHolder().setMultimediaObjects(new HashMap<String,Map<String, String>>());
+            state.getDataHolder().setGatheringMultimediaObjects(new HashMap<String,Map<String, String>>());
 
             abcdFieldGetter.getScientificNames(group);
             abcdFieldGetter.getType(root);
@@ -816,6 +928,7 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
             abcdFieldGetter.getGatheringDate(root);
             abcdFieldGetter.getGatheringElevation(root);
             abcdFieldGetter.getGatheringNotes(root);
+            abcdFieldGetter.getGatheringImages(root);
             abcdFieldGetter.getAssociatedUnitIds(root);
             abcdFieldGetter.getUnitNotes(root);
             boolean referencefound = abcdFieldGetter.getReferences(root);
@@ -870,123 +983,126 @@ public class Abcd206Import extends SpecimenImportBase<Abcd206ImportConfigurator,
      * @param abcdFieldGetter : the ABCD parser
      */
     private void prepareCollectors(Abcd206ImportState state, NodeList unitsList, Abcd206XMLFieldGetter abcdFieldGetter) {
-        List<String> collectors = new ArrayList<String>();
-        List<String> teams = new ArrayList<String>();
-        List<List<String>> collectorinteams = new ArrayList<List<String>>();
 
+        TeamOrPersonBase teamOrPerson = null;
+
+        //ImportHelper.setOriginalSource(teamOrPerson, state.getConfig().getSourceReference(), collector, "Collector");
         for (int i = 0; i < unitsList.getLength(); i++) {
             this.getCollectorsFromXML((Element) unitsList.item(i), abcdFieldGetter, state);
-            for (String agent : state.getDataHolder().gatheringAgentList) {
-                collectors.add(agent);
-            }
-            List<String> tmpTeam = new ArrayList<String>(new HashSet<String>(state.getDataHolder().gatheringTeamList));
-            if(!tmpTeam.isEmpty()) {
-                teams.add(StringUtils.join(tmpTeam.toArray()," & "));
-            }
-            for (String agent:tmpTeam) {
-                collectors.add(agent);
-            }
-        }
-
-        List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
-        List<String> teamsU = new ArrayList<String>(new HashSet<String>(teams));
-
-
-        //existing teams in DB
-        Map<String,Team> titleCacheTeam = new HashMap<String, Team>();
-        List<UuidAndTitleCache<Team>> hiberTeam = new ArrayList<UuidAndTitleCache<Team>>();//getAgentService().getTeamUuidAndTitleCache();
-
-        Set<UUID> uuids = new HashSet<UUID>();
-        for (UuidAndTitleCache<Team> hibernateT:hiberTeam){
-            uuids.add(hibernateT.getUuid());
-        }
-        if (!uuids.isEmpty()){
-            List<AgentBase> existingTeams = getAgentService().find(uuids);
-            for (AgentBase<?> existingP:existingTeams){
-                titleCacheTeam.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Team.class));
+            if (!StringUtils.isBlank(state.getDataHolder().gatheringAgents)){
+                teamOrPerson = parseAuthorString(state.getDataHolder().gatheringAgents);
+                if (!state.getPersonStore().containsId(state.getDataHolder().gatheringAgents)) {
+                    state.getPersonStore().put(state.getDataHolder().gatheringAgents, teamOrPerson);
+                    if (logger.isDebugEnabled()) { logger.debug("Stored author " + state.getDataHolder().gatheringAgents  ); }
+                } else {
+                    logger.warn("Not imported author with duplicated aut_id " + state.getDataHolder().gatheringAgents  );
+                }
             }
-        }
-
 
-        Map<String,UUID> teamMap = new HashMap<String, UUID>();
-        for (UuidAndTitleCache<Team> uuidt:hiberTeam){
-            teamMap.put(uuidt.getTitleCache(), uuidt.getUuid());
         }
 
-        //existing persons in DB
-        List<UuidAndTitleCache<Person>> hiberPersons = new ArrayList<UuidAndTitleCache<Person>>();//getAgentService().getPersonUuidAndTitleCache();
-        Map<String,Person> titleCachePerson = new HashMap<String, Person>();
-        uuids = new HashSet<UUID>();
-        for (UuidAndTitleCache<Person> hibernateP:hiberPersons){
-            uuids.add(hibernateP.getUuid());
-        }
 
-        if (!uuids.isEmpty()){
-            List<AgentBase> existingPersons = getAgentService().find(uuids);
-            for (AgentBase<?> existingP:existingPersons){
-                titleCachePerson.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Person.class));
-            }
-        }
 
-        Map<String,UUID> personMap = new HashMap<String, UUID>();
-        for (UuidAndTitleCache<Person> person:hiberPersons){
-            personMap.put(person.getTitleCache(), person.getUuid());
-        }
 
-        java.util.Collection<Person> personToadd = new ArrayList<Person>();
-        java.util.Collection<Team> teamToAdd = new ArrayList<Team>();
+//        List<String> collectorsU = new ArrayList<String>(new HashSet<String>(collectors));
+//        List<String> teamsU = new ArrayList<String>(new HashSet<String>(teams));
+//
+//
+//        //existing teams in DB
+//        Map<String,Team> titleCacheTeam = new HashMap<String, Team>();
+       // List<UuidAndTitleCache<Team>> hiberTeam = new ArrayList<UuidAndTitleCache<Team>>();//getAgentService().getTeamUuidAndTitleCache();
+
+//        Set<UUID> uuids = new HashSet<UUID>();
+//        for (UuidAndTitleCache<Team> hibernateT:hiberTeam){
+//            uuids.add(hibernateT.getUuid());
+//        }
+//        if (!uuids.isEmpty()){
+//            List<AgentBase> existingTeams = getAgentService().find(uuids);
+//            for (AgentBase<?> existingP:existingTeams){
+//                titleCacheTeam.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Team.class));
+//            }
+//        }
 
-        for (String collector:collectorsU){
-            Person p = Person.NewInstance();
-            p.setTitleCache(collector,true);
-            if (!personMap.containsKey(p.getTitleCache())){
-                personToadd.add(p);
-            }
-        }
-        for (String team:teamsU){
-            Team p = Team.NewInstance();
-            p.setTitleCache(team,true);
-            if (!teamMap.containsKey(p.getTitleCache())){
-                teamToAdd.add(p);
-            }
-        }
 
-        if(!personToadd.isEmpty()){
-            for (Person agent: personToadd){
-                save(agent, state);
-                titleCachePerson.put(agent.getTitleCache(),CdmBase.deproxy(agent, Person.class) );
-            }
-        }
+//        Map<String,UUID> teamMap = new HashMap<String, UUID>();
+//        for (UuidAndTitleCache<Team> uuidt:hiberTeam){
+//            teamMap.put(uuidt.getTitleCache(), uuidt.getUuid());
+//        }
 
-        Person ptmp ;
-        Map <String,Integer>teamdone = new HashMap<String, Integer>();
-        for (List<String> collteam: collectorinteams){
-            if (!teamdone.containsKey(StringUtils.join(collteam.toArray(),"-"))){
-                Team team = new Team();
-                boolean em =true;
-                for (String collector:collteam){
-                    ptmp = Person.NewInstance();
-                    ptmp.setTitleCache(collector,true);
-                    Person p2 = titleCachePerson.get(ptmp.getTitleCache());
-                    team.addTeamMember(p2);
-                    em=false;
-                }
-                if (!em) {
-                    teamToAdd.add(team);
-                }
-                teamdone.put(StringUtils.join(collteam.toArray(),"-"),0);
-            }
-        }
-
-        if(!teamToAdd.isEmpty()){
-            for (Team agent: teamToAdd){
-                save(agent, state);
-                titleCacheTeam.put(agent.getTitleCache(), CdmBase.deproxy( agent,Team.class) );
-            }
-        }
+        //existing persons in DB
+//        List<UuidAndTitleCache<Person>> hiberPersons = new ArrayList<UuidAndTitleCache<Person>>();//getAgentService().getPersonUuidAndTitleCache();
+//        Map<String,Person> titleCachePerson = new HashMap<String, Person>();
+//        uuids = new HashSet<UUID>();
+//        for (UuidAndTitleCache<Person> hibernateP:hiberPersons){
+//            uuids.add(hibernateP.getUuid());
+//        }
+//
+//        if (!uuids.isEmpty()){
+//            List<AgentBase> existingPersons = getAgentService().find(uuids);
+//            for (AgentBase<?> existingP:existingPersons){
+//                titleCachePerson.put(existingP.getTitleCache(),CdmBase.deproxy(existingP,Person.class));
+//            }
+//        }
+//
+//        Map<String,UUID> personMap = new HashMap<String, UUID>();
+//        for (UuidAndTitleCache<Person> person:hiberPersons){
+//            personMap.put(person.getTitleCache(), person.getUuid());
+//        }
+//
+//        java.util.Collection<Person> personToadd = new ArrayList<Person>();
+//        java.util.Collection<Team> teamToAdd = new ArrayList<Team>();
+//
+//        for (String collector:collectorsU){
+//            Person p = Person.NewInstance();
+//            p.setTitleCache(collector,true);
+//            if (!personMap.containsKey(p.getTitleCache())){
+//                personToadd.add(p);
+//            }
+//        }
+//        for (String team:teamsU){
+//            Team p = Team.NewInstance();
+//            p.setTitleCache(team,true);
+//            if (!teamMap.containsKey(p.getTitleCache())){
+//                teamToAdd.add(p);
+//            }
+//        }
+//
+//        if(!personToadd.isEmpty()){
+//            for (Person agent: personToadd){
+//                save(agent, state);
+//                titleCachePerson.put(agent.getTitleCache(),CdmBase.deproxy(agent, Person.class) );
+//            }
+//        }
+//
+//        Person ptmp ;
+//        Map <String,Integer>teamdone = new HashMap<String, Integer>();
+//        for (List<String> collteam: collectorinteams){
+//            if (!teamdone.containsKey(StringUtils.join(collteam.toArray(),"-"))){
+//                Team team = new Team();
+//                boolean em =true;
+//                for (String collector:collteam){
+//                    ptmp = Person.NewInstance();
+//                    ptmp.setTitleCache(collector,true);
+//                    Person p2 = titleCachePerson.get(ptmp.getTitleCache());
+//                    team.addTeamMember(p2);
+//                    em=false;
+//                }
+//                if (!em) {
+//                    teamToAdd.add(team);
+//                }
+//                teamdone.put(StringUtils.join(collteam.toArray(),"-"),0);
+//            }
+//        }
+//
+//        if(!teamToAdd.isEmpty()){
+//            for (Team agent: teamToAdd){
+//                save(agent, state);
+//                titleCacheTeam.put(agent.getTitleCache(), CdmBase.deproxy( agent,Team.class) );
+//            }
+//        }
 
-        ((Abcd206ImportConfigurator) state.getConfig()).setTeams(titleCacheTeam);
-        ((Abcd206ImportConfigurator) state.getConfig()).setPersons(titleCachePerson);
+//        ((Abcd206ImportConfigurator) state.getConfig()).setTeams(titleCacheTeam);
+//        ((Abcd206ImportConfigurator) state.getConfig()).setPersons(titleCachePerson);
     }
 
     @Override
index c03cdac8d6d116a4d62da0c5b70b44c4295ed786..72bf3c63c12bb83df075618d138dfc86ecf0471b 100644 (file)
@@ -16,7 +16,9 @@ import java.io.PrintStream;
 
 import org.apache.log4j.Logger;
 
+import eu.etaxonomy.cdm.io.common.MapWrapper;
 import eu.etaxonomy.cdm.io.specimen.SpecimenImportStateBase;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 
 /**
  * @author a.mueller
@@ -29,7 +31,7 @@ public class Abcd206ImportState extends SpecimenImportStateBase<Abcd206ImportCon
 
 
        private String prefix;
-
+       MapWrapper<TeamOrPersonBase<?>> personStore;
 
 
 
@@ -42,7 +44,21 @@ public class Abcd206ImportState extends SpecimenImportStateBase<Abcd206ImportCon
 
 //****************** CONSTRUCTOR ***************************************************/
 
-       public Abcd206ImportState(Abcd206ImportConfigurator config) {
+       /**
+     * @return the personStore
+     */
+    public MapWrapper<TeamOrPersonBase<?>> getPersonStore() {
+        return personStore;
+    }
+
+    /**
+     * @param personStore the personStore to set
+     */
+    public void setPersonStore(MapWrapper<TeamOrPersonBase<?>> personStore) {
+        this.personStore = personStore;
+    }
+
+    public Abcd206ImportState(Abcd206ImportConfigurator config) {
                super(config);
         setReport(new SpecimenImportReport());
         setTransformer(new AbcdTransformer());
index 601446e59a355f2dd83024ed4ffacc1cafc35746..962d7133bc63661f75762523c9d9f53dcdb3fbe4 100644 (file)
@@ -2,6 +2,7 @@ package eu.etaxonomy.cdm.io.specimen.abcd206.in;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.w3c.dom.Element;
@@ -84,7 +85,25 @@ public class Abcd206XMLFieldGetter {
     protected void getScientificNames(NodeList group) {
         NodeList identifications, results;
         String tmpName = null;
-
+        //TODO: add the identifier!!
+//        abcd:Identification>
+//        <abcd:Result>
+//        <abcd:TaxonIdentified>
+//        <abcd:ScientificName>
+//        <abcd:FullScientificNameString>Melosira varians C. Agardh</abcd:FullScientificNameString>
+//        <abcd:NameAtomised><abcd:Botanical><abcd:GenusOrMonomial>Melosira</abcd:GenusOrMonomial><abcd:FirstEpithet>varians</abcd:FirstEpithet><abcd:Rank>sp.</abcd:Rank><abcd:AuthorTeam>C.Agardh</abcd:AuthorTeam></abcd:Botanical></abcd:NameAtomised>
+//        </abcd:ScientificName>
+//        </abcd:TaxonIdentified>
+//        </abcd:Result>
+//        <abcd:PreferredFlag>true</abcd:PreferredFlag>
+//        <abcd:Identifiers>
+//        <abcd:Identifier>
+//        <abcd:PersonName><abcd:FullName>W.-H. Kusber</abcd:FullName></abcd:PersonName>
+//        </abcd:Identifier>
+//        </abcd:Identifiers>
+//        <abcd:Date>
+//        <abcd:DateText>2014-07-11T00:00:00</abcd:DateText></abcd:Date>
+//        </abcd:Identification>
         for (int j = 0; j < group.getLength(); j++) {
             if (group.item(j).getNodeName().equals(prefix + "Identification")) {
                 identifications = group.item(j).getChildNodes();
@@ -551,16 +570,7 @@ public class Abcd206XMLFieldGetter {
             dataHolder.altitude = -9999;
         }
 
-        try {
-            group = root.getElementsByTagName(prefix + "Depth");
-            path = group.item(0).getNodeName();
-            getHierarchie(group.item(0));
-            dataHolder.knownABCDelements.add(path);
-            path = "";
-            dataHolder.depth = Integer.valueOf(group.item(0).getTextContent());
-        } catch (NullPointerException e) {
-            dataHolder.depth = -9999;
-        }
+        getGatheringDepth(root);
 
         try {
             group = root.getElementsByTagName(prefix + "NamedArea");
@@ -606,12 +616,95 @@ public class Abcd206XMLFieldGetter {
         }
     }
 
+
+    /**
+     * @param root
+     */
+    private void getGatheringDepth(Element root) {
+        NodeList group;
+        try {
+            group = root.getElementsByTagName(prefix + "Gathering");
+            for (int i = 0; i < group.getLength(); i++) {
+                NodeList children = group.item(i).getChildNodes();
+                for (int j = 0; j < children.getLength(); j++) {
+                    if (children.item(j).getNodeName().equals(prefix + "Depth")) {
+                        NodeList altitudes = children.item(j).getChildNodes();
+                        for (int k = 0; k < altitudes.getLength(); k++) {
+                            if (altitudes.item(k).getNodeName().equals(prefix + "MeasurementOrFactText")) {
+                                path = altitudes.item(k).getNodeName();
+                                getHierarchie(altitudes.item(k));
+                                dataHolder.knownABCDelements.add(path);
+                                path = "";
+                                try{
+                                    dataHolder.setGatheringDepthText(altitudes.item(k).getTextContent());
+                                }catch(NumberFormatException e){
+                                    logger.debug("Gathering depth value is not parsable to double: " + altitudes.item(k).getTextContent());
+                                }
+                            }
+                        }
+                    }
+                }
+                }
+            } catch (NullPointerException e) {
+                dataHolder.setDepth( -9999.0);
+            }
+        if(dataHolder.getDepth()==null){
+            group = root.getElementsByTagName(prefix + "Gathering");
+            for (int i = 0; i < group.getLength(); i++) {
+                NodeList children = group.item(i).getChildNodes();
+                for (int j = 0; j < children.getLength(); j++) {
+                    if (children.item(j).getNodeName().equals(prefix + "Depth")) {
+                        NodeList altitudes = children.item(j).getChildNodes();
+                        for (int k = 0; k < altitudes.getLength(); k++) {
+                            if (altitudes.item(k).getNodeName().equals(prefix + "MeasurementOrFactAtomised")) {
+                                NodeList facts = altitudes.item(k).getChildNodes();
+                                for (int l = 0; l < facts.getLength(); l++) {
+                                    if (facts.item(l).getNodeName().equalsIgnoreCase(prefix + "LowerValue")) {
+                                        path = facts.item(l).getNodeName();
+                                        getHierarchie(facts.item(l));
+                                        dataHolder.knownABCDelements.add(path);
+                                        path = "";
+                                        try{
+                                            dataHolder.setGatheringDepthMin(Double.parseDouble(facts.item(l).getTextContent()));
+                                        } catch(NumberFormatException e){
+                                            logger.debug("Gathering depth min is not numeric. " + facts.item(l).getTextContent());
+                                        }
+                                    }
+                                    else if (facts.item(l).getNodeName().equalsIgnoreCase(prefix + "UpperValue")) {
+                                        path = facts.item(l).getNodeName();
+                                        getHierarchie(facts.item(l));
+                                        dataHolder.knownABCDelements.add(path);
+                                        path = "";
+                                        try{
+                                            dataHolder.setGatheringDepthMax(Double.parseDouble(facts.item(l).getTextContent()));
+                                        }catch(NumberFormatException e){
+                                            logger.debug("Gathering depth max is not numeric. " + facts.item(l).getTextContent());
+                                        }
+                                    }
+                                    else if (facts.item(l).getNodeName().equals(prefix + "UnitOfMeasurement")) {
+                                        path = facts.item(l).getNodeName();
+                                        getHierarchie(facts.item(l));
+                                        dataHolder.knownABCDelements.add(path);
+                                        path = "";
+                                        dataHolder.setGatheringDepthUnit(facts.item(l).getTextContent());
+                                    } else{
+                                        System.out.println(facts.item(l).getNodeName() + " " + facts.item(l).getTextContent());
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * getMultimedia: get the FileURI objects
      * @param root
      */
     protected void getMultimedia(Element root) {
-        NodeList group, multimedias, multimedia;
+        NodeList group, multimedias, multimedia, creators, creator, copyRightNodes, iprNodes, textNodes, licences, copyrights;
         try {
             group = root.getElementsByTagName(prefix + "MultiMediaObjects");
             for (int i = 0; i < group.getLength(); i++) {
@@ -619,14 +712,66 @@ public class Abcd206XMLFieldGetter {
                 for (int j = 0; j < multimedias.getLength(); j++) {
                     if (multimedias.item(j).getNodeName().equals(prefix + "MultiMediaObject")) {
                         multimedia = multimedias.item(j).getChildNodes();
+                        Map<String,String> mediaObjectMap = new HashMap<String, String>();
+                        String fileUri = "";
                         for (int k = 0; k < multimedia.getLength(); k++) {
-                            if (multimedia.item(k).getNodeName().equals(prefix + "FileURI")) {
-                                dataHolder.getMultimediaObjects().add(multimedia.item(k).getTextContent());
+                            if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "fileURI")) {
+                                fileUri = multimedia.item(k).getTextContent();
+                                mediaObjectMap.put("fileUri", fileUri);
                                 path = multimedia.item(k).getNodeName();
                                 getHierarchie(multimedia.item(k));
                                 dataHolder.knownABCDelements.add(path);
                                 path = "";
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "context")) {
+                                mediaObjectMap.put("Context", multimedia.item(k).getTextContent());
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creators")){
+                                String creatorString = "";
+                                creators = multimedia.item(k).getChildNodes();
+                                for (int l = 0; l < creators.getLength(); l++) {
+
+                                    if (creators.item(l).getNodeName().equalsIgnoreCase(prefix + "Creator")){
+                                        if (creatorString != ""){
+                                            creatorString += ", ";
+                                        }
+                                       creatorString += creators.item(l).getTextContent();
+                                    }
+                                }
+                                mediaObjectMap.put("Creators",creatorString);
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creator")){
+                                mediaObjectMap.put("Creators",multimedia.item(k).getTextContent());
+                            } else if (multimedia.item(k).getNodeName().equals("CreatedDate")){
+                                mediaObjectMap.put("CreatedDate",multimedia.item(k).getTextContent());
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "comment")){
+                                mediaObjectMap.put("Comment",multimedia.item(k).getTextContent());
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "IPR")){
+                                String copyRightString = "";
+                                iprNodes = multimedia.item(k).getChildNodes();
+                                for (int l = 0; l < iprNodes.getLength(); l++) {
+                                    if (iprNodes.item(l).getNodeName().equalsIgnoreCase(prefix + "Copyrights")){
+                                        copyRightNodes = iprNodes.item(l).getChildNodes();
+                                        for (int m = 0; m < copyRightNodes.getLength(); m++) {
+                                            if (copyRightNodes.item(l).getNodeName().equalsIgnoreCase(prefix + "Copyright")){
+                                                copyrights = copyRightNodes.item(l).getChildNodes();
+                                                for (int n = 0; n < copyrights.getLength(); n++){
+                                                    if (copyrights.item(n).getNodeName().equalsIgnoreCase(prefix + "text")){
+                                                           //TODO: decide whether this is the copyright owner or a description text
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+
+
+
+                              // TODO: mediaObjectMap.put("IPR",multimedia.item(k).getTextContent());
+                            } else{
+                                System.out.println(multimedia.item(k).getNodeName() + " " + multimedia.item(k).getTextContent());
                             }
+
+                        }
+                        if (fileUri != ""){
+                            dataHolder.putMultiMediaObject(fileUri,mediaObjectMap);
                         }
                     }
                 }
@@ -817,7 +962,7 @@ public class Abcd206XMLFieldGetter {
      */
     protected void getGatheringPeople(Element root) {
         try {
-            dataHolder.gatheringAgentList = new ArrayList<String>();
+            dataHolder.gatheringAgents = "";
 
             NodeList group = root.getElementsByTagName(prefix + "GatheringAgent");
             for (int i = 0; i < group.getLength(); i++) {
@@ -832,7 +977,8 @@ public class Abcd206XMLFieldGetter {
                                 dataHolder.knownABCDelements.add(path);
                                 path = "";
                                 if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
-                                    dataHolder.gatheringAgentList.add(persons.item(k).getTextContent());
+
+                                    dataHolder.gatheringAgents += persons.item(k).getTextContent();
                                 }
                             }
                         }
@@ -854,7 +1000,7 @@ public class Abcd206XMLFieldGetter {
                                 dataHolder.knownABCDelements.add(path);
                                 path = "";
                                 if (!persons.item(k).getTextContent().trim().equalsIgnoreCase("none")) {
-                                    dataHolder.gatheringAgentList.add(persons.item(k).getTextContent());
+                                    dataHolder.gatheringAgents+=persons.item(k).getTextContent();
                                 }
                             }
                         }
@@ -864,12 +1010,9 @@ public class Abcd206XMLFieldGetter {
             }
 
         } catch (NullPointerException e) {
-            dataHolder.gatheringAgentList = new ArrayList<String>();
-        }
-        if (dataHolder.gatheringAgentList.size() > 1){
-            dataHolder.gatheringTeamList.addAll(dataHolder.gatheringAgentList);
-            dataHolder.gatheringAgentList = new ArrayList<String>();
+            dataHolder.gatheringAgents = "";
         }
+
     }
 
     /*PARSING METHODS*/
@@ -1137,4 +1280,62 @@ public class Abcd206XMLFieldGetter {
         return atomisedMap;
     }
 
+
+    /**
+     * @param root
+     */
+    public void getGatheringImages(Element root) {
+        NodeList group, multimedias, multimedia, creators, creator;
+        try {
+            group = root.getElementsByTagName(prefix + "SiteImages");
+            for (int i = 0; i < group.getLength(); i++) {
+                multimedias = group.item(i).getChildNodes();
+                for (int j = 0; j < multimedias.getLength(); j++) {
+                    if (multimedias.item(j).getNodeName().equals(prefix + "SiteImage")) {
+                        multimedia = multimedias.item(j).getChildNodes();
+                        Map<String,String> mediaObjectMap = new HashMap<String, String>();
+                        String fileUri = "";
+                        for (int k = 0; k < multimedia.getLength(); k++) {
+
+
+                            if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "fileURI")) {
+                                fileUri = multimedia.item(k).getTextContent();
+                                mediaObjectMap.put("fileUri", fileUri);
+                                path = multimedia.item(k).getNodeName();
+                                getHierarchie(multimedia.item(k));
+                                dataHolder.knownABCDelements.add(path);
+                                path = "";
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Context")) {
+                                mediaObjectMap.put("Context", multimedia.item(k).getTextContent());
+                            }else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Comment")) {
+                                mediaObjectMap.put("Comment", multimedia.item(k).getTextContent());
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creators")){
+                                String creatorString = "";
+                                creators = multimedia.item(k).getChildNodes();
+                                for (int l = 0; l < creators.getLength(); l++) {
+
+                                    if (creators.item(l).getNodeName().equalsIgnoreCase(prefix + "Creator")){
+                                        if (creatorString != ""){
+                                            creatorString += ", ";
+                                        }
+                                       creatorString += creators.item(l).getTextContent();
+                                    }
+                                }
+                                mediaObjectMap.put("Creators",creatorString);
+                            } else if (multimedia.item(k).getNodeName().equalsIgnoreCase(prefix + "Creator")){
+                                mediaObjectMap.put("Creators",multimedia.item(k).getTextContent());
+                            }
+                        }
+                        if (fileUri != ""){
+                            dataHolder.putGatheringMultiMediaObject(fileUri,mediaObjectMap);
+                        }
+                    }
+                }
+            }
+        } catch (NullPointerException e) {
+            logger.info(e);
+        }
+
+    }
+
 }
old mode 100755 (executable)
new mode 100644 (file)
index cf6e19c..ee830b4
-// $Id$
-/**
-* Copyright (C) 2015 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.specimen.abcd206.in;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-
-/**
- * Gathers information about the ABCD import and presents them in a suitable way.
- * @author pplitzner
- * @date Jan 23, 2015
- *
- */
-public class SpecimenImportReport {
-
-    static private final Logger logger = Logger.getLogger(SpecimenImportReport.class);
-
-
-    private final List<Taxon> createdTaxa = new ArrayList<Taxon>();
-    private final Map<Taxon, List<UnitIdSpecimen>> taxonToAssociatedSpecimens =  new HashMap<Taxon, List<UnitIdSpecimen>>();
-    private final Map<UnitIdSpecimen, List<UnitIdSpecimen>> derivateMap = new HashMap<UnitIdSpecimen, List<UnitIdSpecimen>>();
-    private final List<UnitIdSpecimen> alreadyExistingSpecimens = new ArrayList<UnitIdSpecimen>();
-    private final List<TaxonNameBase<?, ?>> createdNames = new ArrayList<TaxonNameBase<?,?>>();
-    private final List<TaxonNode> createdTaxonNodes = new ArrayList<TaxonNode>();
-    private final List<String> infoMessages = new ArrayList<String>();
-
-    public void addTaxon(Taxon taxon){
-        createdTaxa.add(taxon);
-    }
-
-    public void addName(TaxonNameBase<?, ?> taxonName){
-        createdNames.add(taxonName);
-    }
-
-    public void addTaxonNode(TaxonNode taxonNode){
-        createdTaxonNodes.add(taxonNode);
-    }
-
-    public void addDerivate(DerivedUnit parent, SpecimenImportConfiguratorBase config){
-        addDerivate(parent, null, config);
-    }
-
-    public void addDerivate(DerivedUnit parent, DerivedUnit child, SpecimenImportConfiguratorBase config){
-        UnitIdSpecimen parentUnitIdSpecimen = new UnitIdSpecimen(SpecimenImportUtility.getUnitID(parent, config), parent);
-        List<UnitIdSpecimen> children = derivateMap.get(parentUnitIdSpecimen);
-        if(children==null){
-            children = new ArrayList<UnitIdSpecimen>();
-        }
-        if(child!=null){
-            children.add(new UnitIdSpecimen(SpecimenImportUtility.getUnitID(child, config), child));
-        }
-        derivateMap.put(parentUnitIdSpecimen, children);
-    }
-
-    public void addIndividualAssociation(Taxon taxon, String derivedUnitId, DerivedUnit derivedUnitBase) {
-        UnitIdSpecimen derivedUnitIdSpecimen = new UnitIdSpecimen(derivedUnitId, derivedUnitBase);
-        List<UnitIdSpecimen> associatedSpecimens = taxonToAssociatedSpecimens.get(taxon);
-        if(associatedSpecimens==null){
-            associatedSpecimens = new ArrayList<UnitIdSpecimen>();
-        }
-        associatedSpecimens.add(derivedUnitIdSpecimen);
-        taxonToAssociatedSpecimens.put(taxon, associatedSpecimens);
-    }
-
-    public void addAlreadyExistingSpecimen(String unitId, DerivedUnit derivedUnit){
-        alreadyExistingSpecimens.add(new UnitIdSpecimen(unitId, derivedUnit));
-    }
-
-    public void addException(String message, Exception e) {
-        StringWriter errors = new StringWriter();
-        e.printStackTrace(new PrintWriter(errors));
-        infoMessages.add(message+"\n"+e.getMessage()+"\n"+errors.toString());
-    }
-
-    public void addInfoMessage(String message) {
-        infoMessages.add(message);
-    }
-
-    public void printReport(URI reportUri) {
-        PrintStream out;
-        if(reportUri != null){
-            try {
-                out = new PrintStream(new File(reportUri));
-            } catch (FileNotFoundException e) {
-                logger.warn("Report file could not be found.");
-                out = System.out;
-            }
-        }
-        else{
-            out = System.out;
-        }
-        printReport(out);
-    }
-
-
-    public void printReport(PrintStream out) {
-
-        out.println("++++++++Import Report+++++++++");
-      //all specimens
-        Set<UnitIdSpecimen> allSpecimens = new HashSet<UnitIdSpecimen>();
-        for (Entry<UnitIdSpecimen, List<UnitIdSpecimen>> entry : derivateMap.entrySet()) {
-            UnitIdSpecimen parentSpecimen = entry.getKey();
-            allSpecimens.add(parentSpecimen);
-            for (UnitIdSpecimen childSpecimen : entry.getValue()) {
-                allSpecimens.add(childSpecimen);
-            }
-        }
-        out.println("Specimens created: "+allSpecimens.size());
-        Map<SpecimenOrObservationType, Integer> specimenTypeToCount = new HashMap<SpecimenOrObservationType, Integer>();
-        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {
-            incrementSpecimenTypeCount(specimenTypeToCount, unitIdSpecimen);
-        }
-        for(Entry<SpecimenOrObservationType, Integer> entry:specimenTypeToCount.entrySet()){
-            SpecimenOrObservationType type = entry.getKey();
-            out.println(type+": "+entry.getValue());
-        }
-        //not imported
-        out.println("Skipped/not imported: "+alreadyExistingSpecimens.size());
-        out.println("\n");
-
-        out.println("Imported unit ids");
-        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {
-                       out.print(unitIdSpecimen.unitId+", ");
-               }
-        out.println("\n");
-
-        out.println("Ignored unit ids");
-        for (UnitIdSpecimen unitIdSpecimen : alreadyExistingSpecimens) {
-               out.print(unitIdSpecimen.unitId+", ");
-        }
-        out.println("\n");
-
-        //taxon name
-        out.println("---Created Taxon Names ("+createdNames.size()+")---");
-        for (TaxonNameBase<?, ?> taxonName : createdNames) {
-            out.println(taxonName.getTitleCache());
-        }
-        out.println("\n");
-
-        //taxa
-        out.println("---Created Taxa ("+createdTaxa.size()+")---");
-        for (Taxon taxon : createdTaxa) {
-            out.println(taxon.getTitleCache());
-        }
-        out.println("\n");
-
-        //taxon nodes
-        out.println("---Created Taxon Nodes ("+createdTaxonNodes.size()+")---");
-        for (TaxonNode taxonNode : createdTaxonNodes) {
-            String nodeString = taxonNode.toString();
-            if(taxonNode.getTaxon()!=null){
-                nodeString += " ("+taxonNode.getTaxon().getTitleCache()+")";
-            }
-            if(taxonNode.getParent()!=null){
-                nodeString += " with parent "+taxonNode.getParent();
-                if(taxonNode.getParent().getTaxon()!=null){
-                    nodeString += " ("+taxonNode.getParent().getTaxon().getTitleCache()+")";
-                }
-            }
-            out.println(nodeString);
-        }
-        out.println("\n");
-
-        //not imported
-        out.println("---Already existing specimen/not imported ("+alreadyExistingSpecimens.size()+")---");
-        for(UnitIdSpecimen specimen:alreadyExistingSpecimens){
-            out.println(formatSpecimen(specimen));
-        }
-        out.println("\n");
-
-        //taxa with associated specimens
-        out.println("---Taxa with associated specimens ("+taxonToAssociatedSpecimens.size()+")---");
-        for(Entry<Taxon, List<UnitIdSpecimen>> entry:taxonToAssociatedSpecimens.entrySet()){
-            Taxon taxon = entry.getKey();
-            List<UnitIdSpecimen> specimens = entry.getValue();
-            out.println(taxon.getTitleCache() + " ("+specimens.size()+")");
-            for (UnitIdSpecimen derivedUnit : specimens) {
-                out.println("\t- "+formatSpecimen(derivedUnit));
-                //check for derivatives
-                List<UnitIdSpecimen> list = derivateMap.get(derivedUnit);
-                for (UnitIdSpecimen derivate : list) {
-                    out.println("\t\t- "+formatSpecimen(derivate));
-                }
-            }
-        }
-        out.println("\n");
-        out.println("\n");
-        //info messages
-        out.println("---Info messages---");
-        for(String message:infoMessages){
-            out.println(message);
-            out.println("---");
-        }
-        if(out!=System.out){
-            out.close();
-        }
-    }
-
-    private void incrementSpecimenTypeCount(Map<SpecimenOrObservationType, Integer> specimenTypeToCount,
-            UnitIdSpecimen specimen) {
-        SpecimenOrObservationType specimenType = specimen.getSpecimen().getRecordBasis();
-        Integer count = specimenTypeToCount.get(specimenType);
-        if(count==null){
-            count = 1;
-        }
-        else{
-            count++;
-        }
-        specimenTypeToCount.put(specimenType, count);
-    }
-
-    private String formatSpecimen(UnitIdSpecimen specimen){
-        return "("+specimen.getUnitId()+") ["+specimen.getSpecimen().getRecordBasis()+"] "+specimen.getSpecimen().getTitleCache();
-    }
-
-    private class UnitIdSpecimen{
-        private final String unitId;
-        private final SpecimenOrObservationBase<?> specimen;
-
-
-        public UnitIdSpecimen(String unitId, SpecimenOrObservationBase<?> specimen) {
-            super();
-            this.unitId = unitId;
-            this.specimen = specimen;
-        }
-        public String getUnitId() {
-            return unitId;
-        }
-        public SpecimenOrObservationBase<?> getSpecimen() {
-            return specimen;
-        }
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((specimen == null) ? 0 : specimen.hashCode());
-            result = prime * result + ((unitId == null) ? 0 : unitId.hashCode());
-            return result;
-        }
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            UnitIdSpecimen other = (UnitIdSpecimen) obj;
-            if (specimen == null) {
-                if (other.specimen != null) {
-                    return false;
-                }
-            } else if (!specimen.equals(other.specimen)) {
-                return false;
-            }
-            if (unitId == null) {
-                if (other.unitId != null) {
-                    return false;
-                }
-            } else if (!unitId.equals(other.unitId)) {
-                return false;
-            }
-            return true;
-        }
-
-    }
-
-}
+// $Id$\r
+/**\r
+* Copyright (C) 2015 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.cdm.io.specimen.abcd206.in;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.PrintStream;\r
+import java.io.PrintWriter;\r
+import java.io.StringWriter;\r
+import java.net.URI;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+import java.util.Set;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+\r
+/**\r
+ * Gathers information about the ABCD import and presents them in a suitable way.\r
+ * @author pplitzner\r
+ * @date Jan 23, 2015\r
+ *\r
+ */\r
+public class SpecimenImportReport {\r
+\r
+    static private final Logger logger = Logger.getLogger(SpecimenImportReport.class);\r
+\r
+\r
+    private final List<Taxon> createdTaxa = new ArrayList<Taxon>();\r
+    private final Map<Taxon, List<UnitIdSpecimen>> taxonToAssociatedSpecimens =  new HashMap<Taxon, List<UnitIdSpecimen>>();\r
+    private final Map<UnitIdSpecimen, List<UnitIdSpecimen>> derivateMap = new HashMap<UnitIdSpecimen, List<UnitIdSpecimen>>();\r
+    private final List<UnitIdSpecimen> alreadyExistingSpecimens = new ArrayList<UnitIdSpecimen>();\r
+    private final List<TaxonNameBase<?, ?>> createdNames = new ArrayList<TaxonNameBase<?,?>>();\r
+    private final List<TaxonNode> createdTaxonNodes = new ArrayList<TaxonNode>();\r
+    private final List<String> infoMessages = new ArrayList<String>();\r
+\r
+    public void addTaxon(Taxon taxon){\r
+        createdTaxa.add(taxon);\r
+    }\r
+\r
+    public void addName(TaxonNameBase<?, ?> taxonName){\r
+        createdNames.add(taxonName);\r
+    }\r
+\r
+    public void addTaxonNode(TaxonNode taxonNode){\r
+        createdTaxonNodes.add(taxonNode);\r
+    }\r
+\r
+    public void addDerivate(DerivedUnit parent, SpecimenImportConfiguratorBase config){\r
+        addDerivate(parent, null, config);\r
+    }\r
+\r
+    public void addDerivate(DerivedUnit parent, DerivedUnit child, SpecimenImportConfiguratorBase config){\r
+        UnitIdSpecimen parentUnitIdSpecimen = new UnitIdSpecimen(SpecimenImportUtility.getUnitID(parent, config), parent);\r
+        List<UnitIdSpecimen> children = derivateMap.get(parentUnitIdSpecimen);\r
+        if(children==null){\r
+            children = new ArrayList<UnitIdSpecimen>();\r
+        }\r
+        if(child!=null){\r
+            children.add(new UnitIdSpecimen(SpecimenImportUtility.getUnitID(child, config), child));\r
+        }\r
+        derivateMap.put(parentUnitIdSpecimen, children);\r
+    }\r
+\r
+    public void addIndividualAssociation(Taxon taxon, String derivedUnitId, DerivedUnit derivedUnitBase) {\r
+        UnitIdSpecimen derivedUnitIdSpecimen = new UnitIdSpecimen(derivedUnitId, derivedUnitBase);\r
+        List<UnitIdSpecimen> associatedSpecimens = taxonToAssociatedSpecimens.get(taxon);\r
+        if(associatedSpecimens==null){\r
+            associatedSpecimens = new ArrayList<UnitIdSpecimen>();\r
+        }\r
+        associatedSpecimens.add(derivedUnitIdSpecimen);\r
+        taxonToAssociatedSpecimens.put(taxon, associatedSpecimens);\r
+    }\r
+\r
+    public void addAlreadyExistingSpecimen(String unitId, DerivedUnit derivedUnit){\r
+        alreadyExistingSpecimens.add(new UnitIdSpecimen(unitId, derivedUnit));\r
+    }\r
+\r
+    public void addException(String message, Exception e) {\r
+        StringWriter errors = new StringWriter();\r
+        e.printStackTrace(new PrintWriter(errors));\r
+        infoMessages.add(message+"\n"+e.getMessage()+"\n"+errors.toString());\r
+    }\r
+\r
+    public void addInfoMessage(String message) {\r
+        infoMessages.add(message);\r
+    }\r
+\r
+    public void printReport(URI reportUri) {\r
+        PrintStream out;\r
+        if(reportUri != null){\r
+            try {\r
+                out = new PrintStream(new File(reportUri));\r
+            } catch (FileNotFoundException e) {\r
+                logger.warn("Report file could not be found.");\r
+                out = System.out;\r
+            }\r
+        }\r
+        else{\r
+            out = System.out;\r
+        }\r
+        printReport(out);\r
+    }\r
+\r
+\r
+    public void printReport(PrintStream out) {\r
+\r
+        out.println("++++++++Import Report+++++++++");\r
+      //all specimens\r
+        Set<UnitIdSpecimen> allSpecimens = new HashSet<UnitIdSpecimen>();\r
+        for (Entry<UnitIdSpecimen, List<UnitIdSpecimen>> entry : derivateMap.entrySet()) {\r
+            UnitIdSpecimen parentSpecimen = entry.getKey();\r
+            allSpecimens.add(parentSpecimen);\r
+            for (UnitIdSpecimen childSpecimen : entry.getValue()) {\r
+                allSpecimens.add(childSpecimen);\r
+            }\r
+        }\r
+        out.println("Specimens created: "+allSpecimens.size());\r
+        Map<SpecimenOrObservationType, Integer> specimenTypeToCount = new HashMap<SpecimenOrObservationType, Integer>();\r
+        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {\r
+            incrementSpecimenTypeCount(specimenTypeToCount, unitIdSpecimen);\r
+        }\r
+        for(Entry<SpecimenOrObservationType, Integer> entry:specimenTypeToCount.entrySet()){\r
+            SpecimenOrObservationType type = entry.getKey();\r
+            out.println(type+": "+entry.getValue());\r
+        }\r
+        //not imported\r
+        out.println("Skipped/not imported: "+alreadyExistingSpecimens.size());\r
+        out.println("\n");\r
+\r
+        out.println("Imported unit ids");\r
+        for (UnitIdSpecimen unitIdSpecimen : allSpecimens) {\r
+                       out.print(unitIdSpecimen.unitId+", ");\r
+               }\r
+        out.println("\n");\r
+\r
+        out.println("Ignored unit ids");\r
+        for (UnitIdSpecimen unitIdSpecimen : alreadyExistingSpecimens) {\r
+               out.print(unitIdSpecimen.unitId+", ");\r
+        }\r
+        out.println("\n");\r
+\r
+        //taxon name\r
+        out.println("---Created Taxon Names ("+createdNames.size()+")---");\r
+        for (TaxonNameBase<?, ?> taxonName : createdNames) {\r
+            out.println(taxonName.getTitleCache());\r
+        }\r
+        out.println("\n");\r
+\r
+        //taxa\r
+        out.println("---Created Taxa ("+createdTaxa.size()+")---");\r
+        for (Taxon taxon : createdTaxa) {\r
+            out.println(taxon.getTitleCache());\r
+        }\r
+        out.println("\n");\r
+\r
+        //taxon nodes\r
+        out.println("---Created Taxon Nodes ("+createdTaxonNodes.size()+")---");\r
+        for (TaxonNode taxonNode : createdTaxonNodes) {\r
+            String nodeString = taxonNode.toString();\r
+            if(taxonNode.getTaxon()!=null){\r
+                nodeString += " ("+taxonNode.getTaxon().getTitleCache()+")";\r
+            }\r
+            if(taxonNode.getParent()!=null){\r
+                nodeString += " with parent "+taxonNode.getParent();\r
+                if(taxonNode.getParent().getTaxon()!=null){\r
+                    nodeString += " ("+taxonNode.getParent().getTaxon().getTitleCache()+")";\r
+                }\r
+            }\r
+            out.println(nodeString);\r
+        }\r
+        out.println("\n");\r
+\r
+        //not imported\r
+        out.println("---Already existing specimen/not imported ("+alreadyExistingSpecimens.size()+")---");\r
+        for(UnitIdSpecimen specimen:alreadyExistingSpecimens){\r
+            out.println(formatSpecimen(specimen));\r
+        }\r
+        out.println("\n");\r
+\r
+        //taxa with associated specimens\r
+        out.println("---Taxa with associated specimens ("+taxonToAssociatedSpecimens.size()+")---");\r
+        for(Entry<Taxon, List<UnitIdSpecimen>> entry:taxonToAssociatedSpecimens.entrySet()){\r
+            Taxon taxon = entry.getKey();\r
+            List<UnitIdSpecimen> specimens = entry.getValue();\r
+            out.println(taxon.getTitleCache() + " ("+specimens.size()+")");\r
+            for (UnitIdSpecimen derivedUnit : specimens) {\r
+                out.println("\t- "+formatSpecimen(derivedUnit));\r
+                //check for derivatives\r
+                List<UnitIdSpecimen> list = derivateMap.get(derivedUnit);\r
+                for (UnitIdSpecimen derivate : list) {\r
+                    out.println("\t\t- "+formatSpecimen(derivate));\r
+                }\r
+            }\r
+        }\r
+        out.println("\n");\r
+        out.println("\n");\r
+        //info messages\r
+        out.println("---Info messages---");\r
+        for(String message:infoMessages){\r
+            out.println(message);\r
+            out.println("---");\r
+        }\r
+        if(out!=System.out){\r
+            out.close();\r
+        }\r
+    }\r
+\r
+    private void incrementSpecimenTypeCount(Map<SpecimenOrObservationType, Integer> specimenTypeToCount,\r
+            UnitIdSpecimen specimen) {\r
+        SpecimenOrObservationType specimenType = specimen.getSpecimen().getRecordBasis();\r
+        Integer count = specimenTypeToCount.get(specimenType);\r
+        if(count==null){\r
+            count = 1;\r
+        }\r
+        else{\r
+            count++;\r
+        }\r
+        specimenTypeToCount.put(specimenType, count);\r
+    }\r
+\r
+    private String formatSpecimen(UnitIdSpecimen specimen){\r
+        return "("+specimen.getUnitId()+") ["+specimen.getSpecimen().getRecordBasis()+"] "+specimen.getSpecimen().getTitleCache();\r
+    }\r
+\r
+    private class UnitIdSpecimen{\r
+        private final String unitId;\r
+        private final SpecimenOrObservationBase<?> specimen;\r
+\r
+\r
+        public UnitIdSpecimen(String unitId, SpecimenOrObservationBase<?> specimen) {\r
+            super();\r
+            this.unitId = unitId;\r
+            this.specimen = specimen;\r
+        }\r
+        public String getUnitId() {\r
+            return unitId;\r
+        }\r
+        public SpecimenOrObservationBase<?> getSpecimen() {\r
+            return specimen;\r
+        }\r
+        @Override\r
+        public int hashCode() {\r
+            final int prime = 31;\r
+            int result = 1;\r
+            result = prime * result + ((specimen == null) ? 0 : specimen.hashCode());\r
+            result = prime * result + ((unitId == null) ? 0 : unitId.hashCode());\r
+            return result;\r
+        }\r
+        @Override\r
+        public boolean equals(Object obj) {\r
+            if (this == obj) {\r
+                return true;\r
+            }\r
+            if (obj == null) {\r
+                return false;\r
+            }\r
+            if (getClass() != obj.getClass()) {\r
+                return false;\r
+            }\r
+            UnitIdSpecimen other = (UnitIdSpecimen) obj;\r
+            if (specimen == null) {\r
+                if (other.specimen != null) {\r
+                    return false;\r
+                }\r
+            } else if (!specimen.equals(other.specimen)) {\r
+                return false;\r
+            }\r
+            if (unitId == null) {\r
+                if (other.unitId != null) {\r
+                    return false;\r
+                }\r
+            } else if (!unitId.equals(other.unitId)) {\r
+                return false;\r
+            }\r
+            return true;\r
+        }\r
+\r
+    }\r
+\r
+}\r
index cab9acf5eb7aa3b38b42cb6ce4d197696bbdf34a..b88d3926a8a353b8365fe16c421395bb7ef9ce5c 100644 (file)
@@ -524,8 +524,12 @@ public class AbcdGgbnImportTest extends CdmTransactionalIntegrationTest {
 
            boolean result = defaultImport.invoke(importConfigurator).isSuccess();
            assertTrue("Return value for import.invoke should be true", result);
-           assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
            List<DerivedUnit> derivedUnits = occurrenceService.list(DerivedUnit.class, null, null, null, null);
+           for (DerivedUnit derivedUnit:derivedUnits){
+               System.out.println(derivedUnit.getTitleCache());
+           }
+           assertEquals("Number of derived units is incorrect", 2, occurrenceService.count(DerivedUnit.class));
+          // List<DerivedUnit> derivedUnits = occurrenceService.list(DerivedUnit.class, null, null, null, null);
 
            List<FieldUnit> fieldUnitsTemp = occurrenceService.list(FieldUnit.class, null, null, null, null);
            assertEquals("Number of derived units is incorrect", 2, derivedUnits.size());
index 4177ac7066cbc19b22b62e7f4e1b42a2ece2ae7e..1a02e8870cf69640b536faebc7f4207f386d2c57 100644 (file)
@@ -1,51 +1,54 @@
-// $Id$
-/**
-* Copyright (C) 2016 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.hibernate;
-
-import java.util.Collection;
-
-import org.apache.log4j.Logger;
-import org.hibernate.LazyInitializationException;
-
-
-/**
- * Helper class to remove null values from collections which are left over artifacts due to
- * https://hibernate.atlassian.net/browse/HHH-9751
- *
- * @author a.kohlbecker
- * @date Jun 13, 2016
- *
- */
-public class HHH_9751_Util {
-
-    private static final Logger logger = Logger.getLogger(HHH_9751_Util.class);
-
-    /**
-     *
-     * @param collection
-     * @return the number of null values removed from the collection
-     */
-    static public int removeAllNull(Collection collection) {
-
-        int cnt = 0;
-        try {
-           if (collection.contains(null)){
-                while(collection.contains(null)){
-                    cnt++;
-                    collection.remove(null);
-                }
-            }
-        } catch (LazyInitializationException e) {
-            logger.info("Cannot clean up uninitialized children without a session, skipping.");
-        }
-        return cnt;
-    }
-
-}
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.cdm.hibernate;\r
+\r
+import java.util.Collection;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.hibernate.Hibernate;\r
+import org.hibernate.LazyInitializationException;\r
+\r
+\r
+/**\r
+ * Helper class to remove null values from collections which are left over artifacts due to\r
+ * https://hibernate.atlassian.net/browse/HHH-9751\r
+ *\r
+ * @author a.kohlbecker\r
+ * @date Jun 13, 2016\r
+ *\r
+ */\r
+public class HHH_9751_Util {\r
+\r
+    private static final Logger logger = Logger.getLogger(HHH_9751_Util.class);\r
+\r
+    /**\r
+     *\r
+     * @param collection\r
+     * @return the number of null values removed from the collection\r
+     */\r
+    static public int removeAllNull(Collection collection) {\r
+\r
+        int cnt = 0;\r
+        try {\r
+           if (Hibernate.isInitialized(collection)){\r
+               if (collection.contains(null)){\r
+                    while(collection.contains(null)){\r
+                        cnt++;\r
+                        collection.remove(null);\r
+                    }\r
+                }\r
+           }\r
+        } catch (LazyInitializationException e) {\r
+            logger.info("Cannot clean up uninitialized children without a session, skipping.");\r
+        }\r
+        return cnt;\r
+    }\r
+\r
+}\r
index b493ef566f2410166a2ac41b3261ae4da2721e5e..a71452a1151d1f0e713fd04bb97fcfc31cb2181b 100644 (file)
     </property>\r
   </bean>\r
   \r
-  <bean id="httpPreferenceService"\r
-    class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">\r
-    <property name="service">\r
-      <ref bean="preferenceServiceImpl" />\r
-    </property>\r
-    <property name="serviceInterface">\r
-      <value>eu.etaxonomy.cdm.api.service.IPreferenceService</value>\r
-    </property>\r
-  </bean>\r
-\r
+  \r
   <bean id="httpDescriptionService"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">\r
     <property name="service">\r
     </property>\r
   </bean>\r
   \r
+  <bean id="httpPreferenceService"\r
+    class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">\r
+    <property name="service">\r
+      <ref bean="preferenceServiceImpl" />\r
+    </property>\r
+    <property name="serviceInterface">\r
+      <value>eu.etaxonomy.cdm.api.service.IPreferenceService</value>\r
+    </property>\r
+  </bean>\r
+  \r
   <bean id="httpProgressMonitorService"\r
     class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">\r
     <property name="service">\r
index d47146fd16d2d1ea497edc0e0b7bc71e6b279ce2..6c17d70f43f23f0924cf95fd283b4d0c94f23820 100644 (file)
@@ -52,7 +52,7 @@
         <prop key="/remoting/primer.service">httpPrimerService</prop>
         <prop key="/remoting/progressmonitor.service">httpProgressMonitorService</prop>
         <prop key="/remoting/reference.service">httpReferenceService</prop>   
-         <prop key="/remoting/preference.service">httpPreferenceService</prop>         
+        <prop key="/remoting/preference.service">httpPreferenceService</prop>         
         <prop key="/remoting/sequence.service">httpSequenceService</prop> 
         <prop key="/remoting/eventbase.service">httpEventBaseService</prop> 
         <prop key="/remoting/taxonnode.service">httpTaxonNodeService</prop>