extend excel import for tropicos
authorKatja Luther <k.luther@bgbm.org>
Tue, 13 Dec 2016 10:46:00 +0000 (11:46 +0100)
committerKatja Luther <k.luther@bgbm.org>
Tue, 13 Dec 2016 10:46:00 +0000 (11:46 +0100)
14 files changed:
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/ExcelUtils.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelImporterBase.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/stream/ExcelStreamImportConfigurator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportConfigurator.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitRow.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/TaxonExcelImportState.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/TaxonExcelImporterBase.java
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/stream/ExcelStreamImport-TestInput.xls
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalExplicit.xls
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalImplied.xls
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/ExcelTropicosImportExampleTest-input.xlsx [changed mode: 0755->0644]
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest-input.xls
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest.testUuid-input.xls

index 5a783a3fee318804e481a7d89adfe18e7ccc3519..491ccf609924b6909d83eb93f25d163a76ab1d13 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -11,6 +11,7 @@
 package eu.etaxonomy.cdm.common;
 
 import java.io.FileNotFoundException;
+import java.io.InputStream;
 import java.net.URI;
 import java.text.DateFormat;
 import java.text.Format;
@@ -35,31 +36,49 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
  */
 public class ExcelUtils {
        private static final Logger logger = Logger.getLogger(ExcelUtils.class);
-       
+
     /** Reads all rows of an Excel worksheet */
     public static ArrayList<HashMap<String, String>> parseXLS(URI uri) throws FileNotFoundException {
        return parseXLS(uri, null);
     }
 
-    
+
        /** Reads all rows of an Excel worksheet */
     public static ArrayList<HashMap<String, String>> parseXLS(URI uri, String worksheetName) throws FileNotFoundException {
-       
+        InputStream stream;
+        try {
+            stream = UriUtils.getInputStream(uri);
+            return parseXLS(stream, worksheetName);
+        } catch(FileNotFoundException fne) {
+            throw new FileNotFoundException(uri.toString());
+        } catch(Exception ioe) {
+            logger.error("Error reading the Excel file." + uri.toString());
+            ioe.printStackTrace();
+        }
+        return null;
+
+    }
+        /** Reads all rows of an Excel worksheet */
+        public static ArrayList<HashMap<String, String>> parseXLS(InputStream stream, String worksheetName) throws FileNotFoundException {
+
+
        ArrayList<HashMap<String, String>> recordList = new ArrayList<HashMap<String, String>>();
 
        try {
 //             POIFSFileSystem fs = new POIFSFileSystem(UriUtils.getInputStream(uri));
 //             HSSFWorkbook wb = new HSSFWorkbook(fs);
 
-               Workbook wb = WorkbookFactory.create(UriUtils.getInputStream(uri));
+
+               Workbook wb = WorkbookFactory.create(stream);
+
 
                Sheet sheet;
                if (worksheetName == null){
-                       sheet = wb.getSheetAt(0);       
+                       sheet = wb.getSheetAt(0);
                }else{
                        sheet = wb.getSheet(worksheetName);
                }
-               
+
                if (sheet== null){
                        if (worksheetName != null){
                                logger.debug(worksheetName + " not provided!");
@@ -67,14 +86,14 @@ public class ExcelUtils {
                }else{
                        Row row;
                        Cell cell;
-       
+
                        int rows; // Number of rows
                        rows = sheet.getPhysicalNumberOfRows();
                                if(logger.isDebugEnabled()) { logger.debug("Number of rows: " + rows); }
-       
+
                        int cols = 0; // Number of columns
                        int tmp = 0;
-       
+
                        // This trick ensures that we get the data properly even if it doesn't start from first few rows
                        for(int i = 0; i < 10 || i < rows; i++) {
                                row = sheet.getRow(i);
@@ -85,8 +104,8 @@ public class ExcelUtils {
                                        }
                                }
                        }
-               
-               
+
+
                        //first row
                        ArrayList<String> columns = new ArrayList<String>();
                        row = sheet.getRow(0);
@@ -99,7 +118,7 @@ public class ExcelUtils {
                                                if(logger.isDebugEnabled()) { logger.debug("Cell #" + c + " is null"); }
                                        }
                        }
-                       
+
                        //value rows
                        for(int r = 1; r < rows; r++) {
                                row = sheet.getRow(r);
@@ -115,7 +134,7 @@ public class ExcelUtils {
                                                                logger.warn(message);
                                                        }else{
                                                                if(logger.isDebugEnabled()) { logger.debug(String.format("Cell #%d: %s", c, cell.toString())); }
-                                                               headers.put(columns.get(c), getCellValue(cell));        
+                                                               headers.put(columns.get(c), getCellValue(cell));
                                                        }
                                                } else {
                                                        if(logger.isDebugEnabled()) { logger.debug("Cell #" + c + " is null"); }
@@ -125,8 +144,7 @@ public class ExcelUtils {
                                recordList.add(headers);
                        }
                }
-       } catch(FileNotFoundException fne) {
-               throw new FileNotFoundException(uri.toString());
+
        } catch(Exception ioe) {
                logger.error("Error reading the Excel file.");
                ioe.printStackTrace();
@@ -177,7 +195,7 @@ public class ExcelUtils {
                result = String.format(result, getExcelColString(cell.getColumnIndex()), cell.getRowIndex());
                return result;
        }
-       
+
        private static String getExcelColString(int colNr){
                int first = colNr / 26;
                int second = colNr % 26;
@@ -186,7 +204,7 @@ public class ExcelUtils {
                String secondStr = String.valueOf((char)(second + 64));
                return firstStr +  secondStr;
        }
-       
+
 
        /**
         * Returns the numeric cell value. In case the cell is formatted as
@@ -211,7 +229,7 @@ public class ExcelUtils {
                        DateFormat df = DateFormat.getDateInstance(2,locale);
                        String result = df.format(date); //result of type dd.mm.yyyy
 //                     String result = date.toString();
-                       
+
                        return result;
                }
 //             System.out.println(d);
@@ -242,5 +260,5 @@ public class ExcelUtils {
                }
                return notEmpty;
        }
-       
+
 }
index 1b53848940742092b7490128d486486f59bd0b41..6f62d30e15e7d3a42519bc4769c91fb58941d5a9 100644 (file)
@@ -9,6 +9,7 @@
 
 package eu.etaxonomy.cdm.io.excel.common;
 
+import java.io.ByteArrayInputStream;
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.util.ArrayList;
@@ -21,6 +22,7 @@ import eu.etaxonomy.cdm.api.application.CdmApplicationController;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.common.ExcelUtils;
 import eu.etaxonomy.cdm.io.common.CdmImportBase;
+import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
@@ -62,8 +64,18 @@ public abstract class ExcelImporterBase<STATE extends ExcelImportState<? extends
                        state.setUnsuccessfull();
                        return;
                }
+               URI source = null;
+
+               ByteArrayInputStream data = null;
                // read and save all rows of the excel worksheet
-               URI source = state.getConfig().getSource();
+               if (state.getConfig().getSource() != null){
+                   source = state.getConfig().getSource();
+               }else{
+                   data = (ByteArrayInputStream) ((NormalExplicitImportConfigurator)state.getConfig()).getStream();
+               }
+
+
+
                String sheetName = getWorksheetName();
                try {
                        recordList = ExcelUtils.parseXLS(source, sheetName);
index e37b64ff097bc8d1023443e77832f075f8cf6a1a..81f40054a3eb4393e9cc5f0468245c445e889c50 100644 (file)
@@ -1,5 +1,6 @@
 package eu.etaxonomy.cdm.io.excel.stream;
 
+import java.io.InputStream;
 import java.net.URI;
 
 import org.apache.log4j.Logger;
@@ -11,7 +12,7 @@ import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
 import eu.etaxonomy.cdm.io.dwca.in.DwcaDataImportConfiguratorBase;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 /**
- * 
+ *
  * @author a.oppermann
  * @date 08.05.2013
  *
@@ -22,10 +23,12 @@ public class ExcelStreamImportConfigurator extends DwcaDataImportConfiguratorBas
 
        private static final String DEFAULT_REF_TITLE = "Excel Stream Import";
 
-       
+
        private static IInputTransformer defaultTransformer = null;
 
-       
+       private InputStream stream = null;
+
+
        /**
         * Factory method.
         * @param uri
@@ -35,7 +38,7 @@ public class ExcelStreamImportConfigurator extends DwcaDataImportConfiguratorBas
        public static ExcelStreamImportConfigurator NewInstance(URI uri, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation){
                return new ExcelStreamImportConfigurator(uri, destination, nomenclaturalCode, dbSchemaValidation);
        }
-       
+
 //     /**
 //      * @param transformer
 //      */
@@ -51,9 +54,21 @@ public class ExcelStreamImportConfigurator extends DwcaDataImportConfiguratorBas
        private ExcelStreamImportConfigurator(URI uri, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation) {
                super(uri, destination, defaultTransformer);
                setDbSchemaValidation(dbSchemaValidation);
-               setNomenclaturalCode(nomenclaturalCode);        
+               setNomenclaturalCode(nomenclaturalCode);
        }
-       
+
+       /**
+     * Constructor.
+     * @param uri
+     * @param destination
+     */
+    private ExcelStreamImportConfigurator(InputStream stream, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation) {
+        super(null, destination, defaultTransformer);
+        setDbSchemaValidation(dbSchemaValidation);
+        setNomenclaturalCode(nomenclaturalCode);
+        this.stream = stream;
+    }
+
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
         */
@@ -73,7 +88,7 @@ public class ExcelStreamImportConfigurator extends DwcaDataImportConfiguratorBas
                };
        }
 
-       
+
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.io.dwca.in.StreamImportConfiguratorBase#getDefaultSourceReferenceTitle()
         */
index 9535e7d9ebb202392c716bf806d10d0175aabea0..1fe2702ce556c4e5481bacfe46ed193ef11d5ea4 100644 (file)
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.io.common.TdwgAreaProvider;
 import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase.SourceDataHolder;
+import eu.etaxonomy.cdm.io.tcsrdf.TcsRdfTransformer;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.CdmBase;
@@ -45,11 +46,14 @@ import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
 import eu.etaxonomy.cdm.model.description.TextData;
 import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.name.BotanicalName;
+import eu.etaxonomy.cdm.model.name.NameRelationshipType;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.ZoologicalName;
 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
@@ -97,31 +101,42 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                String value = keyValue.value;
                Integer index = keyValue.index;
                if (((NormalExplicitImportConfigurator)state.getConfig()).getParentUUID() != null){
-            normalExplicitRow.setParentId(0);
+            normalExplicitRow.setParentId("0");
                }
 
                key = key.replace(" ","");
                if (key.equalsIgnoreCase(ID_COLUMN)) {
-                       int ivalue = floatString2IntValue(value);
-                       normalExplicitRow.setId(ivalue);
+                       //String ivalue = floatString2IntValue(value);
+                       normalExplicitRow.setId(value);
 
                } else if(key.equalsIgnoreCase(PARENT_ID_COLUMN) ) {
-                       int ivalue = floatString2IntValue(value);
-                       normalExplicitRow.setParentId(ivalue);
+                       //int ivalue = floatString2IntValue(value);
+                       normalExplicitRow.setParentId(value);
 
                } else if(key.equalsIgnoreCase(RANK_COLUMN)) {
                        normalExplicitRow.setRank(value);
 
-               } else if(key.trim().equalsIgnoreCase(SCIENTIFIC_NAME_COLUMN)) {
+               } else if(key.trim().equalsIgnoreCase(SCIENTIFIC_NAME_COLUMN) || key.trim().equalsIgnoreCase(FULLNAME_COLUMN)) {
                        normalExplicitRow.setScientificName(value);
 
-               } else if(key.equalsIgnoreCase(AUTHOR_COLUMN)) {
+               } else if(key.equalsIgnoreCase(AUTHOR_COLUMN)|| key.equalsIgnoreCase(AUTHORS_COLUMN)) {
                        normalExplicitRow.setAuthor(value);
-
-               } else if(key.equalsIgnoreCase(REFERENCE_COLUMN)) {
+               }else if(key.equalsIgnoreCase(PUBLISHING_AUTHOR_COLUMN)) {
+            normalExplicitRow.setPublishingAuthor(value);
+               }else if(key.equalsIgnoreCase(BASIONYM_AUTHOR_COLUMN)) {
+            normalExplicitRow.setBasionymAuthor(value);
+
+               }else if(key.equalsIgnoreCase(BASIONYM_COLUMN)) {
+            normalExplicitRow.setBasionym(value);
+               }else if(key.trim().equalsIgnoreCase(NOMENCLATURAL_SYNONYM_COLUMN)) {
+            normalExplicitRow.setSynonym(value);
+               } else if(key.equalsIgnoreCase(REFERENCE_COLUMN) || key.equalsIgnoreCase(PUBLICATION_COLUMN)) {
                        normalExplicitRow.setReference(value);
 
-               } else if(key.equalsIgnoreCase(NAME_STATUS_COLUMN) ) {
+               } else if(key.equalsIgnoreCase(COLLATION_COLUMN)) {
+            normalExplicitRow.setCollation(value);
+
+        }else if(key.equalsIgnoreCase(NAMESTATUS_COLUMN)) {
                        normalExplicitRow.setNameStatus(value);
 
                } else if(key.equalsIgnoreCase(VERNACULAR_NAME_COLUMN)) {
@@ -130,7 +145,7 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                } else if(key.equalsIgnoreCase(LANGUAGE_COLUMN)) {
                        normalExplicitRow.setLanguage(value);
 
-               } else if(key.equalsIgnoreCase(TDWG_COLUMN)) {
+               } else if(key.equalsIgnoreCase(TDWG_COLUMN) ) {
                        //TODO replace still necessary?
                        value = value.replace(".0", "");
                        normalExplicitRow.putDistribution(index, value);
@@ -141,12 +156,29 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                } else if(key.equalsIgnoreCase(IMAGE_COLUMN)) {
                        normalExplicitRow.putImage(index, value);
 
-               } else if(key.equalsIgnoreCase(DATE_COLUMN) || key.equalsIgnoreCase(YEAR_COLUMN)) {
+               } else if(key.equalsIgnoreCase(DATE_COLUMN) || key.equalsIgnoreCase(YEAR_COLUMN)|| key.equalsIgnoreCase(PUBLICATION_YEAR_COLUMN)) {
             normalExplicitRow.setDate(value);
 
         } else if(key.equalsIgnoreCase(FAMILY_COLUMN)) {
             normalExplicitRow.setFamily(value);
-        }else if(key.equalsIgnoreCase("!")) {
+        } else if(key.equalsIgnoreCase(INFRA_FAMILY_COLUMN)) {
+            normalExplicitRow.setInfraFamily(value);
+        }else if(key.equalsIgnoreCase(GENUS_COLUMN)) {
+            normalExplicitRow.setGenus(value);
+        }else if(key.trim().equalsIgnoreCase(INFRA_GENUS_COLUMN.trim())) {
+            normalExplicitRow.setInfraGenus(value);
+        }else if(key.equalsIgnoreCase(SPECIES_COLUMN)) {
+            normalExplicitRow.setSpecies(value);
+        }else if(key.equalsIgnoreCase(INFRA_SPECIES_COLUMN)) {
+            normalExplicitRow.setInfraSpecies(value);
+        } else if (key.equalsIgnoreCase(VERSION_COLUMN)){
+            normalExplicitRow.setVersion(value);
+        }
+
+
+
+
+        else if(key.equalsIgnoreCase("!")) {
             //! = Legitimate, * = Illegitimate, ** = Invalid, *** = nom. rej., !! = nom. cons.
             if (value.equals("!")){
                 normalExplicitRow.setNameStatus("accepted");
@@ -163,12 +195,12 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
             }
         }else {
                        if (analyzeFeatures(state, keyValue)){
-                               //ok
+
                        }else{
                                String message = "Unexpected column header " + key;
                                fireWarningEvent(message, state, 10);
                                state.setUnsuccessfull();
-                               logger.error(message);
+                               //logger.error(message);
                        }
                }
                return;
@@ -191,11 +223,25 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                String rankStr = taxonDataHolder.getRank();
                String taxonNameStr = taxonDataHolder.getScientificName();
                String authorStr = taxonDataHolder.getAuthor();
+               String publishingAuthor= taxonDataHolder.getPublishingAuthor();
+               String basionymAuthor = taxonDataHolder.getBasionymAuthor();
+
                String referenceStr = taxonDataHolder.getReference();
                String nameStatus = taxonDataHolder.getNameStatus();
                String familyNameStr = taxonDataHolder.getFamily();
+               String infraFamilyNameStr = taxonDataHolder.getInfraFamily();
+               String genusNameStr = taxonDataHolder.getGenus();
+               String infraGenusNameStr = taxonDataHolder.getInfraGenus();
+               String speciesNameStr = taxonDataHolder.getSpecies();
+               String infraSpeciesNameStr = taxonDataHolder.getInfraSpecies();
+
+               String version = taxonDataHolder.getVersion();
+
+
+
+
                String dateStr = taxonDataHolder.getDate();
-               Integer id = taxonDataHolder.getId();
+               String id = taxonDataHolder.getId();
                UUID cdmUuid = taxonDataHolder.getCdmUuid();
 
                TaxonBase<?> taxonBase = null;
@@ -213,13 +259,18 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                                        try {
                                                rank = Rank.getRankByEnglishName(rankStr, state.getConfig().getNomenclaturalCode(), false);
                                        } catch (UnknownCdmTypeException e) {
-                                               //state.setUnsuccessfull();
-                                               logger.error(rankStr + " is not a valid rank.");
+                                           try {
+                                  rank = TcsRdfTransformer.rankString2Rank(rankStr);
+                              } catch (UnknownCdmTypeException e1) {
+                                   // TODO Auto-generated catch block
+                                   e1.printStackTrace();
+                              }
+                                          
                                        }
                                }
 
                    //taxon
-                               taxonBase = createTaxon(state, rank, taxonNameStr, authorStr, referenceStr, dateStr, nameStatus);
+                               taxonBase = createTaxon(state, rank, taxonNameStr, authorStr, publishingAuthor, basionymAuthor, referenceStr, dateStr, nameStatus);
                        }else{
                                return;
                        }
@@ -248,8 +299,8 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                }
 
                state.putTaxon(id, taxonBase);
-               getTaxonService().save(taxonBase);
-
+               taxonBase = getTaxonService().save(taxonBase);
+               taxonDataHolder.setCdmUuid(taxonBase.getUuid());
                return;
     }
 
@@ -268,93 +319,124 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                        String taxonNameStr = taxonDataHolder.getScientificName();
                        String nameStatus = taxonDataHolder.getNameStatus();
                        String commonNameStr = taxonDataHolder.getCommonName();
-                       Integer parentId = taxonDataHolder.getParentId();
-                       Integer childId = taxonDataHolder.getId();
+
+                       String synonymNameStr = taxonDataHolder.getSynonym();
+                       String basionymNameStr = taxonDataHolder.getBasionym();
+
+                       String parentId = taxonDataHolder.getParentId();
+                       String childId = taxonDataHolder.getId();
                        UUID cdmUuid = taxonDataHolder.getCdmUuid();
                        Taxon acceptedTaxon = null;
                        TaxonNameBase<?,?> nameUsedInSource = null;
                        TaxonBase<?> taxonBase = null;
+                       Taxon parentTaxon = null;
 
                        if (cdmUuid != null){
                                taxonBase = getTaxonService().find(cdmUuid);
-                               acceptedTaxon = getAcceptedTaxon(taxonBase);
-                               nameUsedInSource = taxonBase.getName();
-                       }else{
-                           //TODO error handling for class cast
-                           Taxon parentTaxon = null;
-                           if (parentId == 0 && state.getParent() == null){
-                               parentTaxon =(Taxon) getTaxonService().load(((NormalExplicitImportConfigurator)state.getConfig()).getParentUUID());
-                               state.setParent(parentTaxon);
-                           }else if (parentId != 0){
-                              parentTaxon = CdmBase.deproxy(state.getTaxonBase(parentId), Taxon.class);
-                           } else if (state.getParent() != null){
-                               parentTaxon = state.getParent();
-                           }
-                               if (StringUtils.isNotBlank(taxonNameStr)) {
-                                       taxonBase = state.getTaxonBase(childId);
-                                       if (taxonBase != null){
-
-                                       nameUsedInSource = taxonBase.getName();
-                                       nameStatus = CdmUtils.Nz(nameStatus).trim().toLowerCase();
-                                       if (validMarkers.contains(nameStatus)){
-                                               Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
-                                               acceptedTaxon = taxon;
-                                               // Add the parent relationship
-                                               //if (state.getCurrentRow().getParentId() != 0) {
-                                               MergeResult result = null;
-                                                       if (parentTaxon != null) {
-                                                               //Taxon taxon = (Taxon)state.getTaxonBase(childId);
-
-                                                               Reference sourceRef = state.getConfig().getSourceReference();
-                                                               String microCitation = null;
-                                                               Taxon childTaxon = taxon;
-                                                               makeParent(state, parentTaxon, childTaxon, sourceRef, microCitation);
-                                                               getTaxonService().saveOrUpdate(parentTaxon);
-                                                               state.putTaxon(parentId, parentTaxon);
-                                                       } else {
-                                                               String message = "Taxonomic parent not found for " + taxonNameStr;
-                                                               logger.warn(message);
-                                                               fireWarningEvent(message, state, 6);
-                                                               //state.setUnsuccessfull();
-                                                       }
-//                                             }else{
-//                                                     //do nothing (parent == 0) no parent exists
-//                                             }
-                                       }else if (synonymMarkers.contains(nameStatus)){
-                                               //add synonym relationship
-                                               acceptedTaxon = parentTaxon;
-                                               try {
-                                                       Synonym synonym = CdmBase.deproxy(taxonBase,Synonym.class);
-                                                       if (acceptedTaxon == null){
-                                                               String message = "Accepted/valid taxon could not be found. Please check referential integrity.";
-                                                               fireWarningEvent(message, state, 8);
-                                                       }else{
-                                                           if (parentId != 0){
-                                                               //if no relation was defined in file skip relationship creation
-                                                               acceptedTaxon.addSynonym(synonym, SynonymType.SYNONYM_OF());
-                                                               getTaxonService().saveOrUpdate(acceptedTaxon);
-                                                           }
-                                                       }
-                                               } catch (Exception e) {
-                                                       String message = "Unhandled exception (%s) occurred during synonym import/update";
-                                                       message = String.format(message, e.getMessage());
-                                                       fireWarningEvent(message, state, 10);
-                                                       state.setUnsuccessfull();
-                                               }
-                                       }
-                                       }else{
-                                               acceptedTaxon = null;
-                                               String message = "Unhandled name status (%s)";
-                                               message = String.format(message, nameStatus);
-                                               fireWarningEvent(message, state, 8);
-                                       }
-                               }else{//taxonNameStr is empty
-                                       //vernacular name case
-                                       acceptedTaxon = parentTaxon;
-                                       nameUsedInSource = null;
+                               if (taxonBase != null ){
+                    acceptedTaxon = getAcceptedTaxon(taxonBase);
+                    nameUsedInSource = taxonBase.getName();
                                }
+                       } else{
+                           taxonBase = state.getTaxonBase(childId);
+
+                        if (parentId == "0" && state.getParent() == null){
+                     parentTaxon =(Taxon) getTaxonService().load(((NormalExplicitImportConfigurator)state.getConfig()).getParentUUID());
+                     state.setParent(parentTaxon);
+                 }else if (parentId != "0"){
+                    parentTaxon = CdmBase.deproxy(state.getTaxonBase(parentId), Taxon.class);
+                 } else if (state.getParent() != null){
+                     parentTaxon = state.getParent();
+                 }
+                       if (taxonBase != null ){
+                               acceptedTaxon = getAcceptedTaxon(taxonBase);
+                               if (synonymNameStr != null){
+                                   Synonym syn = createSynonym(state,taxonBase,synonymNameStr);
+                                   acceptedTaxon.addSynonym(syn, SynonymType.HETEROTYPIC_SYNONYM_OF());
+                               }
+                               if (basionymNameStr != null){
+                                   Synonym syn = createSynonym(state,taxonBase,basionymNameStr);
+                        acceptedTaxon.addSynonym(syn, SynonymType.HOMOTYPIC_SYNONYM_OF());
+                        syn.getName().addRelationshipToName(acceptedTaxon.getName(), NameRelationshipType.BASIONYM(), null);
+                               }
+                               nameUsedInSource = taxonBase.getName();
+
+                           //TODO error handling for class cast
+
+
+                               nameUsedInSource = taxonBase.getName();
+                               nameStatus = CdmUtils.Nz(nameStatus).trim().toLowerCase();
+                               if (validMarkers.contains(nameStatus)){
+                                               Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
+                                               acceptedTaxon = taxon;
+                                               // Add the parent relationship
+                                               //if (state.getCurrentRow().getParentId() != 0) {
+                                               MergeResult result = null;
+                                                       if (parentTaxon != null) {
+                                                               //Taxon taxon = (Taxon)state.getTaxonBase(childId);
+
+                                                               Reference sourceRef = state.getConfig().getSourceReference();
+                                                               String microCitation = null;
+                                                               Taxon childTaxon = taxon;
+                                                               makeParent(state, parentTaxon, childTaxon, sourceRef, microCitation);
+                                                               getTaxonService().saveOrUpdate(childTaxon);
+                                                               state.putTaxon(parentId, parentTaxon);
+                                                       } else {
+                                                               String message = "Taxonomic parent not found for " + taxonNameStr;
+                                                               logger.warn(message);
+                                                               fireWarningEvent(message, state, 6);
+                                                               //state.setUnsuccessfull();
+                                                       }
+    //                                         }else{
+    //                                                 //do nothing (parent == 0) no parent exists
+    //                                         }
+                                       }else if (synonymMarkers.contains(nameStatus)){
+                                               //add synonym relationship
+                                               acceptedTaxon = parentTaxon;
+                                               try {
+                                                       Synonym synonym = CdmBase.deproxy(taxonBase,Synonym.class);
+                                                       if (acceptedTaxon == null){
+                                                               String message = "Accepted/valid taxon could not be found. Please check referential integrity.";
+                                                               fireWarningEvent(message, state, 8);
+                                                       }else{
+                                                           if (parentId != "0"){
+                                                               //if no relation was defined in file skip relationship creation
+                                                               acceptedTaxon.addSynonym(synonym, SynonymType.SYNONYM_OF());
+                                                               getTaxonService().saveOrUpdate(acceptedTaxon);
+                                                           }
+                                                       }
+                                               } catch (Exception e) {
+                                                       String message = "Unhandled exception (%s) occurred during synonym import/update";
+                                                       message = String.format(message, e.getMessage());
+                                                       fireWarningEvent(message, state, 10);
+                                                       state.setUnsuccessfull();
+                                               }
+
+                                       }else{
+                                           if (parentTaxon != null) {
+                                Taxon taxon = (Taxon)state.getTaxonBase(childId);
+
+                                Reference sourceRef = state.getConfig().getSourceReference();
+                                String microCitation = null;
+                                Taxon childTaxon = taxon;
+                                makeParent(state, parentTaxon, childTaxon, sourceRef, microCitation);
+                                getTaxonService().saveOrUpdate(parentTaxon);
+                                state.putTaxon(parentId, parentTaxon);
+                            } else {
+                                String message = "Taxonomic parent not found for " + taxonNameStr;
+                                logger.warn(message);
+                                fireWarningEvent(message, state, 6);
+                                //state.setUnsuccessfull();
+                            }
+                                       }
+
+
+                       }
+                       if (StringUtils.isBlank(taxonNameStr) && acceptedTaxon == null) {
+                    acceptedTaxon = parentTaxon;
+                    nameUsedInSource = null;
+                }
                        }
-
                        if (acceptedTaxon == null && (StringUtils.isNotBlank(commonNameStr) ||taxonDataHolder.getFeatures().size() > 0 )){
                                String message = "Accepted taxon could not be found. Can't add additional data (common names, descriptive data, ...) to taxon";
                                fireWarningEvent(message, state, 6);
@@ -412,6 +494,30 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
 
 
        /**
+     * @param state
+     * @param taxonBase
+     * @param synonymNameStr
+     */
+    private Synonym createSynonym(TaxonExcelImportState state, TaxonBase<?> taxonBase, String synonymNameStr) {
+        NomenclaturalCode nc = state.getConfig().getNomenclaturalCode();
+        TaxonNameBase name = null;
+        if (nc.isKindOf(NomenclaturalCode.ICZN)){
+            name = ZoologicalName.NewInstance(taxonBase.getName().getRank());
+        }else if (nc.isKindOf(NomenclaturalCode.ICNAFP)){
+            name = BotanicalName.NewInstance(taxonBase.getName().getRank());
+        } else{
+            name = NonViralName.NewInstance(taxonBase.getName().getRank());
+        }
+        name.setTitleCache(synonymNameStr, true);
+        if (name != null){
+            return Synonym.NewInstance(name, null);
+        }
+        logger.debug("The nomenclatural code is not supported.");
+        return null;
+    }
+
+
+    /**
         * @param state
         * @param taxonDataHolder
         * @param acceptedTaxon
@@ -563,35 +669,82 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
         * @return
         */
        private TaxonBase createTaxon(TaxonExcelImportState state, Rank rank,
-                       String taxonNameStr, String authorStr, String reference, String date, String nameStatus) {
+               String familyNameStr, String infraFamilyNameStr, String genusNameStr, String infraGenusNameStr, String speciesNameStr, String infraSpeciesNameStr, String authorStr, String publishingAuthorStr, String basionymAuthorStr,String reference, String date, String nameStatus) {
                // Create the taxon name object depending on the setting of the nomenclatural code
                // in the configurator (botanical code, zoological code, etc.)
-               if (StringUtils.isBlank(taxonNameStr)){
-                       return null;
-               }
+
                NomenclaturalCode nc = getConfigurator().getNomenclaturalCode();
 
                TaxonBase taxonBase;
-
-               String titleCache = CdmUtils.concat(" ", taxonNameStr, authorStr);
+               String nameCache = null;
+               if (rank == null){
+                   System.err.println("bla");
+               }
+               if (rank.isGenus()){
+                   nameCache =genusNameStr;
+               } else if (rank.isInfraGeneric()){
+                   nameCache =CdmUtils.concat(" " +rank.getIdInVocabulary() + " ",genusNameStr,infraGenusNameStr);
+
+        } else if (rank.isSpecies()){
+            nameCache = CdmUtils.concat(" ", genusNameStr,speciesNameStr);
+        } else if (rank.isInfraSpecific()){
+            nameCache = CdmUtils.concat(" " +rank.getIdInVocabulary() + " ",genusNameStr,infraGenusNameStr);
+        }
                if (! synonymMarkers.contains(nameStatus)  && state.getConfig().isReuseExistingTaxaWhenPossible()){
-                       titleCache = CdmUtils.concat(" ", taxonNameStr, authorStr);
-                       taxonBase = getTaxonService().findBestMatchingTaxon(titleCache);
+                       taxonBase = getTaxonService().findBestMatchingTaxon(nameCache);
                }else{
-                       taxonBase = getTaxonService().findBestMatchingSynonym(titleCache);
+                       taxonBase = getTaxonService().findBestMatchingSynonym(nameCache);
                        if (taxonBase != null){
-                               logger.info("Matching taxon/synonym found for " + titleCache);
+                               logger.info("Matching taxon/synonym found for " + nameCache);
                        }
                }
                if (taxonBase != null){
-                       logger.info("Matching taxon/synonym found for " + titleCache);
+                       logger.info("Matching taxon/synonym found for " + nameCache);
                        return null;
                }else {
-                       taxonBase = createTaxon(state, rank, taxonNameStr, authorStr, reference, date, nameStatus, nc);
+                       taxonBase = createTaxon(state, rank, nameCache, authorStr, publishingAuthorStr, basionymAuthorStr, reference, date, nameStatus, nc);
                }
                return taxonBase;
        }
 
+       /**
+     * @param state
+     * @param rank
+     * @param taxonNameStr
+     * @param authorStr
+     * @param nameStatus
+     * @param nameStatus2
+     * @return
+     */
+    private TaxonBase createTaxon(TaxonExcelImportState state, Rank rank,
+            String taxonNameStr, String authorStr, String publishingAuthorStr, String basionymAuthorStr,String reference, String date, String nameStatus) {
+        // Create the taxon name object depending on the setting of the nomenclatural code
+        // in the configurator (botanical code, zoological code, etc.)
+        if (StringUtils.isBlank(taxonNameStr)){
+            return null;
+        }
+        NomenclaturalCode nc = getConfigurator().getNomenclaturalCode();
+
+        TaxonBase taxonBase = null;
+
+        String titleCache = CdmUtils.concat(" ", taxonNameStr, authorStr);
+        if (! synonymMarkers.contains(nameStatus)  && state.getConfig().isReuseExistingTaxaWhenPossible()){
+            titleCache = CdmUtils.concat(" ", taxonNameStr, authorStr);
+            taxonBase = getTaxonService().findBestMatchingTaxon(titleCache);
+        }else if ( state.getConfig().isReuseExistingTaxaWhenPossible()){
+            taxonBase = getTaxonService().findBestMatchingSynonym(titleCache);
+            if (taxonBase != null){
+                logger.info("Matching taxon/synonym found for " + titleCache);
+            }
+        }
+        if (taxonBase != null){
+            logger.info("Matching taxon/synonym found for " + titleCache);
+            return null;
+        }else {
+            taxonBase = createTaxon(state, rank, taxonNameStr, authorStr, publishingAuthorStr, basionymAuthorStr, reference, date, nameStatus, nc);
+        }
+        return taxonBase;
+    }
 
 
 
@@ -606,13 +759,14 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
         * @return
         */
        private TaxonBase<?> createTaxon(TaxonExcelImportState state, Rank rank, String taxonNameStr,
-                       String authorStr, String reference, String date, String nameStatus, NomenclaturalCode nc) {
+                       String authorStr, String publishingAutorStr, String basionymAuthor, String reference, String date, String nameStatus, NomenclaturalCode nc) {
                TaxonBase<?> taxonBase;
                NonViralName<?> taxonNameBase = null;
                if (nc == NomenclaturalCode.ICVCN){
                        logger.warn("ICVCN not yet supported");
 
                }else{
+                   //String taxonNameStr = titleCache.substring(0, titleCache.indexOf(authorStr));
                        taxonNameBase =(NonViralName<?>) nc.getNewTaxonNameInstance(rank);
                        //NonViralName nonViralName = (NonViralName)taxonNameBase;
                        NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
@@ -645,6 +799,7 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                 ref.setProtectedTitleCache(false);
 
                            taxonNameBase.setNomenclaturalReference(ref);
+                           taxonNameBase.setNomenclaturalMicroReference(state.getCurrentRow().getCollation());
                        }
                }
 
@@ -671,6 +826,9 @@ public class NormalExplicitImport extends TaxonExcelImporterBase {
                        }
                        taxonBase = taxon;
                }
+               taxonBase.getName().addSource(OriginalSourceType.Import, "urn:lsid:ipni.org:names:"+ state.getCurrentRow().getId()+":"+state.getCurrentRow().getVersion(),"TaxonName" ,null, null);
+               taxonBase.addSource(OriginalSourceType.Import, "urn:lsid:ipni.org:names:"+ state.getCurrentRow().getId()+":"+state.getCurrentRow().getVersion(),"TaxonName" ,null, null);
+
                return taxonBase;
        }
 
index 6716c6d7dc0064626acf65e1d22b56cfd9ac9070..0a48d85582773a085aa66920a5f785cd086cac7f 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.cdm.io.excel.taxa;\r
 \r
 \r
+import java.io.InputStream;\r
 import java.net.URI;\r
 import java.util.UUID;\r
 \r
@@ -32,6 +33,9 @@ public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBas
        private UUID parentUUID;\r
 \r
 \r
+       private InputStream stream;\r
+\r
+\r
        //      @SuppressWarnings("unchecked")\r
        @Override\r
     protected void makeIoClassList() {\r
@@ -46,6 +50,7 @@ public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBas
        }\r
 \r
 \r
+\r
        /**\r
         * @param url\r
         * @param destination\r
@@ -61,6 +66,21 @@ public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBas
                setNomenclaturalCode(nomenclaturalCode);\r
        }\r
 \r
+       /**\r
+     * @param stream\r
+     * @param destination\r
+     */\r
+    private NormalExplicitImportConfigurator(InputStream stream, ICdmDataSource destination, NomenclaturalCode nomenclaturalCode, DbSchemaValidation dbSchemaValidation) {\r
+        super(null, destination);\r
+        if (dbSchemaValidation == null){\r
+            dbSchemaValidation = DbSchemaValidation.CREATE;\r
+        }\r
+        setStream(stream);\r
+        setDestination(destination);\r
+        setDbSchemaValidation(dbSchemaValidation);\r
+        setNomenclaturalCode(nomenclaturalCode);\r
+    }\r
+\r
 \r
 \r
 \r
@@ -99,7 +119,7 @@ public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBas
        }\r
 \r
 \r
-       public UUID getParentUUID(){\r
+    public UUID getParentUUID(){\r
         return parentUUID;\r
     }\r
 \r
@@ -108,6 +128,14 @@ public class NormalExplicitImportConfigurator extends ExcelImportConfiguratorBas
         this.parentUUID = parentUUID;\r
     }\r
 \r
+    public InputStream getStream(){\r
+        return stream;\r
+    }\r
+\r
+\r
+    public void setStream(InputStream stream) {\r
+        this.stream = stream;\r
+    }\r
 \r
 \r
 }\r
index ae559fd3f976c4627d7cc5c12de5e71de5133d11..00edf3a396d31d510f357f430ef67d6fb25b866a 100644 (file)
@@ -22,17 +22,35 @@ import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase;
  */\r
 public class NormalExplicitRow extends ExcelRowBase {\r
 \r
-       private int id;\r
-       private int parentId;\r
-       private String rank;\r
-       private String scientificName;\r
-       private String author;\r
-       private String nameStatus;\r
-       private String commonName;\r
-       private String language;\r
-       private String reference;\r
-       private String date;\r
-       private String family;\r
+
+    private String id;\r
+    private String parentId;\r
+    private String rank;\r
+    private String scientificName;\r
+    private String author;\r
+    private String basionymAuthor;\r
+    private String publishingAuthor;\r
+    private String nameStatus;\r
+    private String commonName;\r
+    private String language;\r
+    private String reference;\r
+    private String date;\r
+    private String family;\r
+    private String infraFamily;\r
+    private String genus;\r
+    private String infraGenus;\r
+    private String species;\r
+    private String infraSpecies;\r
+\r
+    private String collation;\r
+    private String publicationYear;\r
+    private String remarks;\r
+\r
+    private String synonym;\r
+    private String basionym;\r
+\r
+    private String version;\r
+
 \r
        //Sets\r
        private TreeMap<Integer, String> distributions = new TreeMap<Integer, String>();\r
@@ -42,8 +60,10 @@ public class NormalExplicitRow extends ExcelRowBase {
        private TreeMap<Integer, String> images = new TreeMap<Integer, String>();\r
 \r
        public NormalExplicitRow() {\r
-               this.id = 0;\r
-               this.parentId = 0;\r
+
+           this.id = "0";\r
+        this.parentId = "0";\r
+
                this.rank = "";\r
                this.scientificName = "";\r
                this.author =  "";\r
@@ -55,11 +75,11 @@ public class NormalExplicitRow extends ExcelRowBase {
                this.setFamily("");\r
        }\r
 \r
-       public NormalExplicitRow(String name, int parentId) {\r
+       public NormalExplicitRow(String name, String parentId) {\r
                this(name, parentId, null);\r
        }\r
 \r
-       public NormalExplicitRow(String scientificName, int parentId, String reference) {\r
+       public NormalExplicitRow(String scientificName, String parentId, String reference) {\r
                this.parentId = parentId;\r
                this.scientificName = scientificName;\r
                this.reference = reference;\r
@@ -70,13 +90,13 @@ public class NormalExplicitRow extends ExcelRowBase {
        /**\r
         * @return the parentId\r
         */\r
-       public int getParentId() {\r
+       public String getParentId() {\r
                return parentId;\r
        }\r
        /**\r
         * @param parentId the parentId to set\r
         */\r
-       public void setParentId(int parentId) {\r
+       public void setParentId(String parentId) {\r
                this.parentId = parentId;\r
        }\r
        /**\r
@@ -107,14 +127,14 @@ public class NormalExplicitRow extends ExcelRowBase {
        /**\r
         * @return the id\r
         */\r
-       public int getId() {\r
+       public String getId() {\r
                return id;\r
        }\r
 \r
        /**\r
         * @param id the id to set\r
         */\r
-       public void setId(int id) {\r
+       public void setId(String id) {\r
                this.id = id;\r
        }\r
 \r
@@ -249,6 +269,188 @@ public class NormalExplicitRow extends ExcelRowBase {
         this.family = family;\r
     }\r
 \r
+    /**\r
+     * @return the basionymAuthor\r
+     */\r
+    public String getBasionymAuthor() {\r
+        return basionymAuthor;\r
+    }\r
+\r
+    /**\r
+     * @param basionymAuthor the basionymAuthor to set\r
+     */\r
+    public void setBasionymAuthor(String basionymAuthor) {\r
+        this.basionymAuthor = basionymAuthor;\r
+    }\r
+\r
+    /**\r
+     * @return the infraFamily\r
+     */\r
+    public String getInfraFamily() {\r
+        return infraFamily;\r
+    }\r
+\r
+    /**\r
+     * @param infraFamily the infraFamily to set\r
+     */\r
+    public void setInfraFamily(String infraFamily) {\r
+        this.infraFamily = infraFamily;\r
+    }\r
+\r
+    /**\r
+     * @return the genus\r
+     */\r
+    public String getGenus() {\r
+        return genus;\r
+    }\r
+\r
+    /**\r
+     * @param genus the genus to set\r
+     */\r
+    public void setGenus(String genus) {\r
+        this.genus = genus;\r
+    }\r
+\r
+    /**\r
+     * @return the infraGenus\r
+     */\r
+    public String getInfraGenus() {\r
+        return infraGenus;\r
+    }\r
+\r
+    /**\r
+     * @param infraGenus the infraGenus to set\r
+     */\r
+    public void setInfraGenus(String infraGenus) {\r
+        this.infraGenus = infraGenus;\r
+    }\r
+\r
+    /**\r
+     * @return the species\r
+     */\r
+    public String getSpecies() {\r
+        return species;\r
+    }\r
+\r
+    /**\r
+     * @param species the species to set\r
+     */\r
+    public void setSpecies(String species) {\r
+        this.species = species;\r
+    }\r
+\r
+    /**\r
+     * @return the infraSpecies\r
+     */\r
+    public String getInfraSpecies() {\r
+        return infraSpecies;\r
+    }\r
+\r
+    /**\r
+     * @param infraSpecies the infraSpecies to set\r
+     */\r
+    public void setInfraSpecies(String infraSpecies) {\r
+        this.infraSpecies = infraSpecies;\r
+    }\r
+\r
+    /**\r
+     * @return the collation\r
+     */\r
+    public String getCollation() {\r
+        return collation;\r
+    }\r
+\r
+    /**\r
+     * @param collation the collation to set\r
+     */\r
+    public void setCollation(String collation) {\r
+        this.collation = collation;\r
+    }\r
+\r
+    /**\r
+     * @return the publicationYear\r
+     */\r
+    public String getPublicationYear() {\r
+        return publicationYear;\r
+    }\r
+\r
+    /**\r
+     * @param publicationYear the publicationYear to set\r
+     */\r
+    public void setPublicationYear(String publicationYear) {\r
+        this.publicationYear = publicationYear;\r
+    }\r
+\r
+    /**\r
+     * @return the remarks\r
+     */\r
+    public String getRemarks() {\r
+        return remarks;\r
+    }\r
+\r
+    /**\r
+     * @param remarks the remarks to set\r
+     */\r
+    public void setRemarks(String remarks) {\r
+        this.remarks = remarks;\r
+    }\r
+\r
+    /**\r
+     * @return the synonym\r
+     */\r
+    public String getSynonym() {\r
+        return synonym;\r
+    }\r
+\r
+    /**\r
+     * @param synonym the synonym to set\r
+     */\r
+    public void setSynonym(String synonym) {\r
+        this.synonym = synonym;\r
+    }\r
+\r
+    /**\r
+     * @return the basionym\r
+     */\r
+    public String getBasionym() {\r
+        return basionym;\r
+    }\r
+\r
+    /**\r
+     * @param basionym the basionym to set\r
+     */\r
+    public void setBasionym(String basionym) {\r
+        this.basionym = basionym;\r
+    }\r
+\r
+    /**\r
+     * @return the publishingAuthor\r
+     */\r
+    public String getPublishingAuthor() {\r
+        return publishingAuthor;\r
+    }\r
+\r
+    /**\r
+     * @param publishingAuthor the publishingAuthor to set\r
+     */\r
+    public void setPublishingAuthor(String publishingAuthor) {\r
+        this.publishingAuthor = publishingAuthor;\r
+    }\r
+\r
+    /**\r
+     * @return the version\r
+     */\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+\r
+    /**\r
+     * @param version the version to set\r
+     */\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+
 \r
 \r
 \r
index 97f04beb9bca4654ad1bc466de7625732a17f4e5..4fd8bee137c08e0976ece993a275d41f0257a96b 100644 (file)
@@ -36,7 +36,7 @@ public class TaxonExcelImportState extends ExcelImportState<ExcelImportConfigura
     /** Already processed authors */\r
        private Set<String> authors = new HashSet<String>();\r
 \r
-       private Map<Integer, TaxonBase> taxonMap= new HashMap<Integer, TaxonBase>();\r
+       private Map<String, TaxonBase> taxonMap= new HashMap<String, TaxonBase>();\r
        private Map<String, TeamOrPersonBase> authorMap= new HashMap<String, TeamOrPersonBase>();\r
        private Taxon parent;\r
        private Classification classification;\r
@@ -73,7 +73,7 @@ public class TaxonExcelImportState extends ExcelImportState<ExcelImportConfigura
         * @param parentId\r
         * @return\r
         */\r
-       public TaxonBase getTaxonBase(Integer taxonId) {\r
+       public TaxonBase getTaxonBase(String taxonId) {\r
                return taxonMap.get(taxonId);\r
        }\r
 \r
@@ -82,7 +82,7 @@ public class TaxonExcelImportState extends ExcelImportState<ExcelImportConfigura
         * @param parentId\r
         * @param taxon\r
         */\r
-       public void putTaxon(Integer taxonId, TaxonBase taxonBase) {\r
+       public void putTaxon(String taxonId, TaxonBase taxonBase) {\r
 \r
 \r
            taxonMap.put(taxonId, taxonBase);\r
index 308273a55bab5dab7f0db8eb80a038023e16fc2c..173e2e7f4471b32aa8698599ed28550267cbac24 100644 (file)
@@ -40,11 +40,18 @@ public abstract class TaxonExcelImporterBase extends ExcelTaxonOrSpecimenImportB
         * Reference\r
         */\r
 \r
+       protected static final String VERSION_COLUMN = "Version";\r
        protected static final String ID_COLUMN = "Id";\r
+\r
        protected static final String PARENT_ID_COLUMN = "ParentId";\r
        protected static final String RANK_COLUMN = "Rank";\r
        protected static final String AUTHOR_COLUMN = "Author";\r
-       protected static final String NAME_STATUS_COLUMN = "NameStatus";\r
+       protected static final String AUTHORS_COLUMN = "Authors";\r
+
+    protected static final String BASIONYM_AUTHOR_COLUMN = "Basionymauthor";\r
+    protected static final String PUBLISHING_AUTHOR_COLUMN = "Publishingauthor";\r
+    protected static final String NAMESTATUS_COLUMN = "NameStatus";\r
+
        protected static final String VERNACULAR_NAME_COLUMN = "VernacularName";\r
        protected static final String LANGUAGE_COLUMN = "Language";\r
        protected static final String REFERENCE_COLUMN = "Reference";\r
@@ -55,9 +62,32 @@ public abstract class TaxonExcelImporterBase extends ExcelTaxonOrSpecimenImportB
        protected static final String COUNTRY_COLUMN = "Country";\r
 \r
        protected static final String SYNONYM_COLUMN = "Synonym";\r
+\r
        protected static final String DATE_COLUMN = "Date";\r
        protected static final String YEAR_COLUMN = "Year";\r
        protected static final String FAMILY_COLUMN = "Family";\r
 \r
+\r
+\r
+       protected static final String BASIONYM_COLUMN = "Basionym";\r
+    protected static final String REPLACED_SYNONYM_COLUMN = "ReplacedSynonym";\r
+    protected static final String NOMENCLATURAL_SYNONYM_COLUMN = "NomenclaturalSynonym";\r
+\r
+    protected static final String INFRA_FAMILY_COLUMN = "InfraFamily";\r
+    protected static final String GENUS_COLUMN = "Genus";\r
+    protected static final String INFRA_GENUS_COLUMN = "Infragenus";\r
+    protected static final String SPECIES_COLUMN = "Species";\r
+    protected static final String INFRA_SPECIES_COLUMN = "InfraSpecies";\r
+    protected static final String FULLNAME_COLUMN = "Fullnamewithoutfamilyandauthors";\r
+    protected static final String HYBRID_GENUS_COLUMN = "HybridGenus";\r
+    protected static final String HYBRID_COLUMN = "Hybrid";\r
+\r
+    protected static final String PUBLICATION_COLUMN = "Publication";\r
+    protected static final String COLLATION_COLUMN = "Collation";\r
+    protected static final String PUBLICATION_YEAR_COLUMN = "PublicationYearFull";\r
+    protected static final String REMARKS_COLUMN = "Remarks";\r
+    protected static final String DISTRIBUTION_COLUMN = "Distribution";\r
+    protected static final String CITATION_TYPE_COLUMN = "Citationtype";\r
+\r
 }\r
 \r
index fd1e15844c0254f9d6d59524be27b162befa64d9..e2e6d869b9a0bd9f91a2bd9d458a93ed06161441 100644 (file)
Binary files a/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/stream/ExcelStreamImport-TestInput.xls and b/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/stream/ExcelStreamImport-TestInput.xls differ
index 920c2144097214a23b5fdf54c2411954654ed02b..ed50ad8f9e0040a8f7453458e0807f57341a0431 100644 (file)
Binary files a/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalExplicit.xls and b/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalExplicit.xls differ
index 3b741325b506105e5b123692e7ccac5caa80f8d7..9521e8e16d208d70810631be7ded6457c9211660 100644 (file)
Binary files a/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalImplied.xls and b/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/DenormalImplied.xls differ
index 8232f479549f1a705d0b69597119e3dff542a19d..5a2f805c81e3c0d002788d389af795f523b218a4 100644 (file)
Binary files a/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest-input.xls and b/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest-input.xls differ
index 37c7041bfbcb5578dafd77f4ef7bc055b33515f7..803e32dd915eb7601b91056f711b2f3286671e74 100644 (file)
Binary files a/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest.testUuid-input.xls and b/cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest.testUuid-input.xls differ