ref #6286 FloraHellenica import continued
authorunknown <a.mueller@BGBM-PESIHPC.bgbm.fu-berlin.de>
Sun, 19 Mar 2017 21:28:29 +0000 (22:28 +0100)
committerunknown <a.mueller@BGBM-PESIHPC.bgbm.fu-berlin.de>
Sun, 19 Mar 2017 21:28:29 +0000 (22:28 +0100)
app-import/src/main/java/eu/etaxonomy/cdm/app/greece/FloraHellenicaActivator.java [moved from app-import/src/main/java/eu/etaxonomy/cdm/app/greece/ChecklistHellenicaActivator.java with 56% similarity]
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaCommentsImport.java [new file with mode: 0644]
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaExcludedTaxonImport.java [new file with mode: 0644]
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportBase.java [new file with mode: 0644]
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportConfigurator.java
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaSynonymImport.java [new file with mode: 0644]
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaTaxonImport.java
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaTransformer.java
app-import/src/main/java/eu/etaxonomy/cdm/io/mexico/SimpleExcelTaxonImportState.java

similarity index 56%
rename from app-import/src/main/java/eu/etaxonomy/cdm/app/greece/ChecklistHellenicaActivator.java
rename to app-import/src/main/java/eu/etaxonomy/cdm/app/greece/FloraHellenicaActivator.java
index 73b4d7635b94196e28c3fdb39ce11f7ddcfbf2bd..a93de0f81930bb63e910b30d4275ca415913df24 100644 (file)
@@ -13,21 +13,30 @@ import java.util.UUID;
 
 import org.apache.log4j.Logger;
 
 
 import org.apache.log4j.Logger;
 
+import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.app.common.CdmDestinations;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
 import eu.etaxonomy.cdm.io.greece.FloraHellenicaImportConfigurator;
 import eu.etaxonomy.cdm.app.common.CdmDestinations;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
 import eu.etaxonomy.cdm.io.greece.FloraHellenicaImportConfigurator;
+import eu.etaxonomy.cdm.io.greece.FloraHellenicaTransformer;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.description.FeatureTree;
 
 /**
 
 /**
+ *
+ * Import for Checklist of Greece.
+ *
+ * https://dev.e-taxonomy.eu/redmine/issues/6286
+ *
  * @author a.mueller
  * @date 13.12.2016
  * @author a.mueller
  * @date 13.12.2016
- *
  */
  */
-public class ChecklistHellenicaActivator {
+public class FloraHellenicaActivator {
     @SuppressWarnings("unused")
     @SuppressWarnings("unused")
-    private static final Logger logger = Logger.getLogger(ChecklistHellenicaActivator.class);
+    private static final Logger logger = Logger.getLogger(FloraHellenicaActivator.class);
 
     //database validation status (create, update, validate ...)
     static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
 
     //database validation status (create, update, validate ...)
     static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
@@ -38,11 +47,13 @@ public class ChecklistHellenicaActivator {
 
     //feature tree uuid
     public static final UUID featureTreeUuid = UUID.fromString("9e1e0e81-7475-4b28-8619-b7f42cd760b6");
 
     //feature tree uuid
     public static final UUID featureTreeUuid = UUID.fromString("9e1e0e81-7475-4b28-8619-b7f42cd760b6");
+    private static final String featureTreeTitle = "Flora Hellenica dataportal feature tree";
 
     //classification
     static final UUID classificationUuid = UUID.fromString("e537d69a-c2d9-4ac6-8f79-5b5e3dd5c154");
     private static final String classificationName = "Greek Checklist";
 
 
     //classification
     static final UUID classificationUuid = UUID.fromString("e537d69a-c2d9-4ac6-8f79-5b5e3dd5c154");
     private static final String classificationName = "Greek Checklist";
 
+
     //check - import
     static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
 
     //check - import
     static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
 
@@ -64,18 +75,56 @@ public class ChecklistHellenicaActivator {
 //        config.setDoVocabularies(doVocabularies);
 
         CdmDefaultImport<FloraHellenicaImportConfigurator> myImport = new CdmDefaultImport<FloraHellenicaImportConfigurator>();
 //        config.setDoVocabularies(doVocabularies);
 
         CdmDefaultImport<FloraHellenicaImportConfigurator> myImport = new CdmDefaultImport<FloraHellenicaImportConfigurator>();
-
         myImport.invoke(config);
         myImport.invoke(config);
+
+        FeatureTree tree = makeFeatureNodes(myImport.getCdmAppController().getTermService());
+        myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
     }
 
     }
 
-    private URI greekChecklist(){
+    private FeatureTree makeFeatureNodes(ITermService service){
+
+        FeatureTree result = FeatureTree.NewInstance(featureTreeUuid);
+        result.setTitleCache(featureTreeTitle, true);
+        FeatureNode root = result.getRoot();
+        FeatureNode newNode;
+
+        Feature newFeature = (Feature)service.find(Feature.DISTRIBUTION().getUuid());
+        newNode = FeatureNode.NewInstance(newFeature);
+        root.addChild(newNode);
+
+        newFeature = (Feature)service.find(FloraHellenicaTransformer.uuidFloraHellenicaChorologyFeature);
+        newNode = FeatureNode.NewInstance(newFeature);
+        root.addChild(newNode);
+
+        newFeature = (Feature)service.find(Feature.LIFEFORM().getUuid());
+        newNode = FeatureNode.NewInstance(newFeature);
+        root.addChild(newNode);
+
+        newFeature = (Feature)service.find(Feature.HABITAT().getUuid());
+        newNode = FeatureNode.NewInstance(newFeature);
+        root.addChild(newNode);
+
+
+        newFeature = (Feature)service.find(Feature.NOTES().getUuid());
+        newNode = FeatureNode.NewInstance(newFeature);
+        root.addChild(newNode);
+
+        return result;
+    }
+
+    private URI greekChecklist_OldVersion(){
         return URI.create("file:////BGBM-PESIHPC/Greece/VPG_FINAL_June_2016.xlsx");
     }
         return URI.create("file:////BGBM-PESIHPC/Greece/VPG_FINAL_June_2016.xlsx");
     }
+
+    private URI greekChecklist(){
+        return URI.create("file:////BGBM-PESIHPC/Greece/VPG_FINAL_WITH_SYNONYMS_21.01.2017.xlsx");
+    }
+
     /**
      * @param args
      */
     public static void main(String[] args) {
     /**
      * @param args
      */
     public static void main(String[] args) {
-        ChecklistHellenicaActivator me = new ChecklistHellenicaActivator();
+        FloraHellenicaActivator me = new FloraHellenicaActivator();
         me.doImport(cdmDestination);
         System.exit(0);
     }
         me.doImport(cdmDestination);
         System.exit(0);
     }
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaCommentsImport.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaCommentsImport.java
new file mode 100644 (file)
index 0000000..7f499c4
--- /dev/null
@@ -0,0 +1,104 @@
+/**
+* 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.greece;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
+import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TextData;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ * @author a.mueller
+ * @date 14.12.2016
+ *
+ */
+
+@Component
+public class FloraHellenicaCommentsImport<CONFIG extends FloraHellenicaImportConfigurator>
+        extends FloraHellenicaImportBase<CONFIG>{
+
+    private static final long serialVersionUID = -3565782012921316901L;
+    private static final Logger logger = Logger.getLogger(FloraHellenicaCommentsImport.class);
+
+    private static final String TAXON = "Taxon";
+    private static final String UNIQUE_ID_ACCEPTED = "Unique ID of taxon name (Includes valid and excluded taxa IDs)";
+    private static final String COMMENT = "Comment";
+
+
+   private  static List<String> expectedKeys= Arrays.asList(new String[]{
+            UNIQUE_ID_ACCEPTED,
+            TAXON,
+            COMMENT
+    });
+
+    @Override
+    protected String getWorksheetName() {
+        return "comments";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
+
+        String line = state.getCurrentLine() + ": ";
+        HashMap<String, String> record = state.getOriginalRecord();
+
+        Set<String> keys = record.keySet();
+        for (String key: keys) {
+            if (! expectedKeys.contains(key)){
+                logger.warn(line + "Unexpected Key: " + key);
+            }
+        }
+
+        String noStr = getValue(record, "Unique ID");
+        makeComment(state, line, record, noStr);
+    }
+
+
+    /**
+     * @param state
+     * @param line
+     * @param record
+     * @param noStr
+     * @return
+     */
+    private void makeComment(SimpleExcelTaxonImportState<CONFIG> state, String line,
+            HashMap<String, String> record,
+            String noStr) {
+
+        Taxon acceptedTaxon = getAcceptedTaxon(record, state, UNIQUE_ID_ACCEPTED);
+        if (acceptedTaxon == null){
+            logger.warn(line + "Accepted not found: " + record.get(UNIQUE_ID_ACCEPTED));
+            return;
+        }
+
+        String commentStr = getValue(record, COMMENT);
+
+        TaxonDescription desc = getTaxonDescription(acceptedTaxon);
+        TextData comment = TextData.NewInstance(Feature.NOTES(), commentStr, Language.ENGLISH(), null);
+        desc.addElement(comment);
+        comment.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null);
+        getTaxonService().saveOrUpdate(acceptedTaxon);
+        return ;
+    }
+
+
+}
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaExcludedTaxonImport.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaExcludedTaxonImport.java
new file mode 100644 (file)
index 0000000..dd9d14d
--- /dev/null
@@ -0,0 +1,170 @@
+/**
+* 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.greece;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
+import eu.etaxonomy.cdm.model.name.BotanicalName;
+import eu.etaxonomy.cdm.model.name.INonViralName;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
+
+/**
+ * @author a.mueller
+ * @date 14.12.2016
+ *
+ */
+
+@Component
+public class FloraHellenicaExcludedTaxonImport<CONFIG extends FloraHellenicaImportConfigurator>
+            extends FloraHellenicaImportBase<CONFIG>{
+
+
+    private static final long serialVersionUID = 2629253144140992196L;
+    private static final Logger logger = Logger.getLogger(FloraHellenicaExcludedTaxonImport.class);
+
+    private static final String TAXON = "Taxon";
+    private static final String UNIQUE_ID = "Unique ID";
+    private static final String FAMILY = "Family";
+
+    private  static List<String> expectedKeys= Arrays.asList(new String[]{
+            UNIQUE_ID,FAMILY,TAXON
+    });
+
+    private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
+    private TaxonNode excludedFamilyNode;
+
+    @Override
+    protected String getWorksheetName() {
+        return "excluded taxa";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
+
+        String line = state.getCurrentLine() + ": ";
+        HashMap<String, String> record = state.getOriginalRecord();
+
+        Set<String> keys = record.keySet();
+        for (String key: keys) {
+            if (! expectedKeys.contains(key)){
+                logger.warn(line + "Unexpected Key: " + key);
+            }
+        }
+
+        String noStr = getValue(record, UNIQUE_ID);
+        TaxonNode taxonNode = makeTaxon(state, line, record, noStr);
+        if (taxonNode != null){
+            state.putTaxon(noStr, taxonNode.getTaxon());
+        }
+    }
+
+
+    /**
+     * @param state
+     * @param line
+     * @param record
+     * @param noStr
+     * @return
+     */
+    private TaxonNode makeTaxon(SimpleExcelTaxonImportState<CONFIG> state, String line,
+            HashMap<String, String> record,
+            String noStr) {
+
+        TaxonNode familyTaxon = getFamilyTaxon(record, state);
+        if (familyTaxon == null){
+            logger.warn(line + "Family not created, can't add excluded taxon: " + record.get(FAMILY));
+            return null;
+        }
+
+        String taxonStr = getValue(record, TAXON);
+        INonViralName name = parser.parseFullName(taxonStr, NomenclaturalCode.ICNAFP, null);
+        if (name.isProtectedTitleCache()){
+            logger.warn(line + "Name could not be parsed: " + taxonStr);
+        }
+
+        Taxon taxon = Taxon.NewInstance(name, getSecReference(state));
+        taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null);
+        TaxonNode excludedNode = familyTaxon.addChildTaxon(taxon, getSecReference(state), null);
+        excludedNode.setExcluded(true);
+        getTaxonNodeService().save(excludedNode);
+        return excludedNode;
+    }
+
+
+   /**
+     * @param record
+     * @param state
+     * @return
+     */
+    private TaxonNode getFamilyTaxon(HashMap<String, String> record,
+            SimpleExcelTaxonImportState<CONFIG> state) {
+
+        String familyStr = getValue(record, FAMILY);
+        if (familyStr == null){
+            return null;
+        }
+        familyStr = familyStr.trim();
+
+        Taxon family = state.getHigherTaxon(familyStr);
+        TaxonNode familyNode;
+        if (family != null){
+            familyNode = family.getTaxonNodes().iterator().next();
+        }else{
+            BotanicalName name = makeFamilyName(state, familyStr);
+            Reference sec = getSecReference(state);
+            family = Taxon.NewInstance(name, sec);
+
+            ITaxonTreeNode groupNode = getExcludedFamilyTaxon(state);
+            familyNode = groupNode.addChildTaxon(family, sec, null);
+            state.putHigherTaxon(familyStr, family);
+            getTaxonNodeService().save(familyNode);
+//            logger.warn(state.getCurrentLine() +": " + "Family not found for excluded taxon");
+        }
+        return familyNode;
+    }
+
+
+    private ITaxonTreeNode getExcludedFamilyTaxon(
+            SimpleExcelTaxonImportState<CONFIG> state) {
+
+        if (excludedFamilyNode != null){
+            return this.excludedFamilyNode;
+        }
+        Classification classification = getClassificationService().load(state.getConfig().getClassificationUuid());
+        TaxonNode plantae = classification.getChildNodes().iterator().next();
+
+        TaxonNameBase<?,?> name = TaxonNameFactory.NewBotanicalInstance(Rank.SUPERFAMILY());
+        name.setTitleCache("Excluded", true);
+        Taxon taxon = Taxon.NewInstance(name, getSecReference(state));
+        excludedFamilyNode = plantae.addChildTaxon(taxon, getSourceCitation(state), null);
+        excludedFamilyNode.setExcluded(true);
+        getTaxonNodeService().save(excludedFamilyNode);
+        return excludedFamilyNode;
+    }
+
+}
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportBase.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImportBase.java
new file mode 100644 (file)
index 0000000..20772d3
--- /dev/null
@@ -0,0 +1,99 @@
+/**
+* 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.greece;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+
+import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
+import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.name.BotanicalName;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ * @author a.mueller
+ * @date 14.12.2016
+ */
+
+public abstract class FloraHellenicaImportBase<CONFIG extends FloraHellenicaImportConfigurator>
+            extends SimpleExcelTaxonImport<CONFIG>{
+
+    private static final long serialVersionUID = 2593130403213346396L;
+    private static final Logger logger = Logger.getLogger(FloraHellenicaImportBase.class);
+
+
+
+
+    /**
+     * @param taxon
+     * @return
+     */
+    protected TaxonDescription getTaxonDescription(Taxon taxon) {
+        if (!taxon.getDescriptions().isEmpty()){
+            return taxon.getDescriptions().iterator().next();
+        }else{
+            TaxonDescription desc = TaxonDescription.NewInstance(taxon);
+            desc.setDefault(true);
+            return desc;
+        }
+    }
+
+
+    /**
+     * @param state
+     * @return
+     */
+    protected Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) {
+        return state.getConfig().getSourceReference();
+    }
+
+
+    protected Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    /**
+     * @param record
+     * @param state
+     * @return
+     */
+    protected Taxon getAcceptedTaxon(HashMap<String, String> record,
+            SimpleExcelTaxonImportState<CONFIG> state, String key) {
+        String accStr = getValue(record, key);
+        if (accStr == null){
+            return null;
+        }
+        accStr = accStr.trim();
+
+        Taxon accTaxon = state.getTaxon(accStr);
+        if (accTaxon == null){
+            String message = state.getCurrentLine()+  ": Accepted taxon could not be found: " + accStr;
+            logger.warn(message);
+            return null;
+        }
+        return accTaxon;
+    }
+
+
+
+    protected BotanicalName makeFamilyName(SimpleExcelTaxonImportState<CONFIG> state, String famStr) {
+        BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY());
+        name.setGenusOrUninomial(famStr);
+        name.addSource(makeOriginalSource(state));
+        return name;
+    }
+
+}
index b8d13169d514f53fdbad9d0cf98b57e244b333d7..6e41b2031d89def2612e88556fb417b61e126da4 100644 (file)
@@ -54,7 +54,10 @@ public class FloraHellenicaImportConfigurator extends ExcelImportConfiguratorBas
     @Override
     protected void makeIoClassList() {
         ioClassList = new Class[]{
     @Override
     protected void makeIoClassList() {
         ioClassList = new Class[]{
-                FloraHellenicaTaxonImport.class
+                FloraHellenicaTaxonImport.class,
+                FloraHellenicaExcludedTaxonImport.class,
+                FloraHellenicaSynonymImport.class,
+                FloraHellenicaCommentsImport.class,
         };
     }
 }
         };
     }
 }
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaSynonymImport.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaSynonymImport.java
new file mode 100644 (file)
index 0000000..a573d17
--- /dev/null
@@ -0,0 +1,257 @@
+/**
+* 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.greece;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
+import eu.etaxonomy.cdm.model.name.INonViralName;
+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.TaxonNameBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+import eu.etaxonomy.cdm.model.taxon.SynonymType;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
+
+/**
+ * @author a.mueller
+ * @date 14.12.2016
+ */
+
+@Component
+public class FloraHellenicaSynonymImport<CONFIG extends FloraHellenicaImportConfigurator>
+            extends FloraHellenicaImportBase<CONFIG>{
+
+    private static final long serialVersionUID = -3565782012921316901L;
+    private static final Logger logger = Logger.getLogger(FloraHellenicaSynonymImport.class);
+
+    private static final String ACCEPTED_NAME = "Accepted name";
+    private static final String SYNONYM = "synonym";
+    private static final String UNIQUE_ID_OF_ACCEPTED_NAME = "Unique ID of accepted name";
+
+   private  static List<String> expectedKeys= Arrays.asList(new String[]{
+            SYNONYM, UNIQUE_ID_OF_ACCEPTED_NAME, ACCEPTED_NAME
+    });
+
+    private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
+
+    @Override
+    protected String getWorksheetName() {
+        return "synonyms";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
+
+        String line = state.getCurrentLine() + ": ";
+        HashMap<String, String> record = state.getOriginalRecord();
+
+        Set<String> keys = record.keySet();
+        for (String key: keys) {
+            if (! expectedKeys.contains(key)){
+                logger.warn(line + "Unexpected Key: " + key);
+            }
+        }
+
+        String row = "row" + state.getCurrentLine();
+        TaxonBase<?> relatedTaxon = makeSynonym(state, line, record, row);
+        getTaxonService().saveOrUpdate(relatedTaxon);
+    }
+
+
+    /**
+     * @param state
+     * @param line
+     * @param record
+     * @param noStr
+     * @return
+     */
+    private TaxonBase<?> makeSynonym(SimpleExcelTaxonImportState<CONFIG> state, String line,
+            HashMap<String, String> record,
+            String lineId) {
+
+        Taxon acceptedTaxon = getAcceptedTaxon(record, state, UNIQUE_ID_OF_ACCEPTED_NAME);
+        if (acceptedTaxon == null){
+            logger.warn(line + "Accepted not found: " + record.get(UNIQUE_ID_OF_ACCEPTED_NAME));
+            return null;
+//            acceptedTaxon = Taxon.NewInstance(null, null);
+        }
+
+        String synonymStr = getValue(record, SYNONYM);
+
+        String[] parsedSynStr = parseAuct(synonymStr, line);
+
+        boolean isMisapplied = parsedSynStr[1] != null;
+        boolean hasNonAuthor = parsedSynStr[2] != null;
+        boolean hasStatus = parsedSynStr[3] != null;
+        boolean isNec = hasNonAuthor && parsedSynStr[2].contains(" nec ");
+
+
+        if (isMisapplied && hasNonAuthor && !isNec){
+            parsedSynStr[0] = parsedSynStr[0] + " " + parsedSynStr[2];
+        }
+
+        INonViralName nvn = parser.parseFullName(parsedSynStr[0], NomenclaturalCode.ICNAFP, null);
+        if (nvn.isProtectedTitleCache()){
+            logger.warn(line + "Name could not be parsed: " + synonymStr);
+        }
+        TaxonNameBase<?,?> name = TaxonNameBase.castAndDeproxy(nvn);
+        if (hasStatus){
+            try {
+                NomenclaturalStatusType status = NomenclaturalStatusType.getNomenclaturalStatusTypeByAbbreviation(parsedSynStr[3], name);
+                name.addStatus(status, null, null);
+            } catch (UnknownCdmTypeException e) {
+                logger.warn(line + "Nom. status not recognized: " + parsedSynStr[3]);
+            }
+        }
+
+        TaxonBase<?> result;
+        if (isMisapplied){
+            result = Taxon.NewInstance(name, getMisappliedRef(state, parsedSynStr[1]));
+            acceptedTaxon.addMisappliedName((Taxon)result, getSecReference(state), null);
+            if (isNec){
+                logger.warn(line + "nec not yet handled for misapplied names: " + synonymStr);
+            }
+        }else{
+            SynonymType synType = null;
+            result = acceptedTaxon.addSynonymName(name, getSecReference(state), null, synType);
+            if (hasNonAuthor){
+                handleSynonymNon(state, name, parsedSynStr[2], line);
+            }
+        }
+        result.addImportSource(lineId, getWorksheetName(), getSourceCitation(state), null);
+
+        return result;
+
+    }
+
+
+
+    /**
+     * @param state
+     * @param name
+     * @param parsedSynStr
+     */
+    private void handleSynonymNon(SimpleExcelTaxonImportState<CONFIG> state,
+            TaxonNameBase<?, ?> name, String nonPart, String line) {
+        String[] splits = nonPart.split(" nec ");
+        for (String split : splits){
+            split = split.trim();
+//            Saponaria illyrica Ard.
+//            Crepis nemausensis Gouan
+//            S. columnae Aurnier
+//            S. columnae Aurnier nec (Rchb. f.) H. Fleischm.
+//            T. glaucescens Rchb.
+            TaxonNameBase<?,?> nonName;
+            if (split.matches("(Saponaria illyrica Ard.|Crepis nemausensis Gouan|S. columnae Aurnier|T. glaucescens Rchb.)"
+                    + "")){
+                if (split.startsWith("S.")){
+                    split = split.replace("S.", "Serapias");
+                }else if (split.startsWith("T.")){
+                    split = split.replace("T.", "Taraxacum");
+                }
+                nonName = TaxonNameBase.castAndDeproxy(this.parser.parseFullName(split));
+                name.addRelationshipFromName(nonName, NameRelationshipType.BLOCKING_NAME_FOR(), null);
+            }else{
+                String nameStr = name.getNameCache() + " " + split;
+                nonName = TaxonNameBase.castAndDeproxy(this.parser.parseFullName(nameStr));
+                name.addRelationshipToName(nonName, NameRelationshipType.LATER_HOMONYM(), null);
+            }
+            getNameService().saveOrUpdate(nonName);
+            if (nonName.isProtectedTitleCache()){
+                logger.warn(line + "Non-Name could not be parsed: " + nonName.getTitleCache());
+            }
+        }
+        if (splits.length>1){
+            logger.warn(line + "nec synonyms maybe not yet correctly implemented: " + name.getTitleCache() + "; " + nonPart);
+        }
+    }
+
+    private Reference flGraecReference;
+    private Reference balkanReference;
+    {
+        flGraecReference = ReferenceFactory.newBook();
+        flGraecReference.setTitle("fl. graec.");
+        balkanReference = ReferenceFactory.newBook();
+        balkanReference.setTitle("balc.");
+    }
+    /**
+     * @param state
+     * @param string
+     * @return
+     */
+    private Reference getMisappliedRef(SimpleExcelTaxonImportState<CONFIG> state, String refString) {
+        if ("fl. graec.".equals(refString)){
+            return flGraecReference;
+        }else if ("balc.".equals(refString)){
+            return balkanReference;
+        }else{
+            logger.warn("Auct. reference not recognized: " + refString);
+            return null;
+        }
+    }
+
+    private String regExMisapplied = "(.+) auct\\. (fl\\. graec\\.|balc\\.), non (.+)";
+    private Pattern patternMisapplied = Pattern.compile(regExMisapplied);
+
+    private String regExNon = "(.+), non (.+)";
+    private Pattern patternNon = Pattern.compile(regExNon);
+
+    private String regExStatus = "(.+),\\s+((?:nom.|comb.|orth.)\\s+(.+))";
+    private Pattern patternStat = Pattern.compile(regExStatus);
+
+    /**
+     * @param synonymStr
+     */
+    private String[] parseAuct(String synonymStr, String line) {
+        String[] result = new String[4];
+        if (synonymStr != null){
+            result[0] = synonymStr;
+            Matcher matcher = patternMisapplied.matcher(synonymStr);
+            if (matcher.matches()){
+                result[0] = matcher.group(1);
+                result[1] = matcher.group(2);
+                if (! result[1].equals("fl. graec.") && ! result[1].equals("balc.")){
+                    logger.warn(line + "Misapplied sensu not recognized: " +  result[1]);
+                }
+                result[2] = matcher.group(3);
+            }else{
+                matcher = patternNon.matcher(synonymStr);
+                if (matcher.matches()){
+                    result[0] = matcher.group(1);
+                    result[2] = matcher.group(2);
+                }else{
+                    matcher = patternStat.matcher(synonymStr);
+                    if (matcher.matches()){
+                        result[0] = matcher.group(1);
+                        result[3] = matcher.group(2);
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+}
index 8ebd03efceec401d179bd5d7c743dbfa7fdba4fd..936b95e64e600c7c0875b5b230689695f7d0672b 100644 (file)
@@ -8,9 +8,11 @@
 */
 package eu.etaxonomy.cdm.io.greece;
 
 */
 package eu.etaxonomy.cdm.io.greece;
 
+import java.net.URI;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
 import java.util.Set;
 import java.util.UUID;
 
@@ -18,9 +20,20 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
 import org.springframework.stereotype.Component;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
+import eu.etaxonomy.cdm.ext.geo.GeoServiceArea;
+import eu.etaxonomy.cdm.ext.geo.GeoServiceAreaAnnotatedMapping;
 import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.Distribution;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
+import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.cdm.model.location.NamedAreaType;
 import eu.etaxonomy.cdm.model.name.BotanicalName;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
 import eu.etaxonomy.cdm.model.name.BotanicalName;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
@@ -38,16 +51,33 @@ import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
  */
 
 @Component
  */
 
 @Component
-public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHellenicaImportConfigurator>{
+public class FloraHellenicaTaxonImport<CONFIG extends FloraHellenicaImportConfigurator>
+            extends FloraHellenicaImportBase<CONFIG>{
+
     private static final long serialVersionUID = -6291948918967763381L;
     private static final Logger logger = Logger.getLogger(FloraHellenicaTaxonImport.class);
 
     private static final long serialVersionUID = -6291948918967763381L;
     private static final Logger logger = Logger.getLogger(FloraHellenicaTaxonImport.class);
 
+    private static final String LIFE_FORM = "Life-form";
+    private static final String STATUS = "Status";
+    private static final String CHOROLOGICAL_CATEGOGY = "Chorological categogy";
+
 
     private static UUID rootUuid = UUID.fromString("aa667b0b-b417-470e-a9b0-ef9409a3431e");
     private static UUID plantaeUuid = UUID.fromString("4f151932-ab97-4d81-b88e-46fe82cd3e88");
 
 
     private static UUID rootUuid = UUID.fromString("aa667b0b-b417-470e-a9b0-ef9409a3431e");
     private static UUID plantaeUuid = UUID.fromString("4f151932-ab97-4d81-b88e-46fe82cd3e88");
 
-    private  static List<String> expectedKeys= Arrays.asList(new String[]{
-            "No","Family","Genus","Species","Species Author","Subspecies","Subspecies Author","IoI","NPi","SPi","Pe","StE","EC","NC","NE","NAe","WAe","Kik","KK","EAe","Stat","Ch","Lf","Hab A","Hab C","Hab G","Hab H","Hab M","Hab P","Hab R","Hab W","comment TR"
+    private OrderedTermVocabulary<NamedArea> areasVoc;
+    private NamedArea greece;
+    private OrderedTermVocabulary<State> lifeformVoc;
+    private OrderedTermVocabulary<State> habitatVoc;
+    private Map<String, State> lifeformMap = new HashMap<>();
+
+    private OrderedTermVocabulary<State> chorologicalVoc;
+
+
+   private  static List<String> expectedKeys= Arrays.asList(new String[]{
+            "Unique ID","Group","Family","Genus","Species","Species Author","Subspecies","Subspecies Author",
+            "IoI","NPi","SPi","Pe","StE","EC","NC","NE","NAe","WAe","Kik","KK","EAe",
+            STATUS,CHOROLOGICAL_CATEGOGY,LIFE_FORM,"A","C","G","H","M","P","R","W", "Taxon"
     });
 
     private String lastFamily;
     });
 
     private String lastFamily;
@@ -57,14 +87,19 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
 
     @Override
     protected String getWorksheetName() {
 
     @Override
     protected String getWorksheetName() {
-        return "6616 taxa";
+        return "valid taxa names";
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    protected void firstPass(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
+    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
+        initAreaVocabulary(state);
+        initLifeformVocabulary(state);
+        initHabitatVocabulary(state);
+        initChorologicalVocabulary(state);
+
         String line = state.getCurrentLine() + ": ";
         HashMap<String, String> record = state.getOriginalRecord();
 
         String line = state.getCurrentLine() + ": ";
         HashMap<String, String> record = state.getOriginalRecord();
 
@@ -75,7 +110,147 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
             }
         }
 
             }
         }
 
-        //Nicht unbedingt notwendig
+        String noStr = getValue(record, "Unique ID");
+        Integer id = noStr == null? null : Integer.valueOf(noStr);
+        Taxon taxon = makeTaxon(state, line, record, noStr);
+
+        //Distribution
+        TaxonDescription desc = getTaxonDescription(taxon);
+        makeDistribution(state, line, noStr, desc);
+
+        makeChorologicalCategory(state, line, noStr, desc);
+
+        //lifeform
+        makeLifeform(state, line, noStr, desc);
+
+        //habitat
+        makeHabitat(state, line, noStr, desc);
+
+        state.putTaxon(noStr, taxon);
+    }
+
+    /**
+     * @param state
+     * @param line
+     * @param noStr
+     * @param desc
+     */
+    private void makeChorologicalCategory(SimpleExcelTaxonImportState<CONFIG> state, String line, String noStr,
+            TaxonDescription desc) {
+
+        HashMap<String, String> record = state.getOriginalRecord();
+        String value = getValue(record, CHOROLOGICAL_CATEGOGY);
+        //TODO
+
+
+
+    }
+
+    /**
+     * @param state
+     * @param line
+     * @param noStr
+     * @param desc
+     */
+    private void makeLifeform(SimpleExcelTaxonImportState<CONFIG> state, String line, String noStr,
+            TaxonDescription desc) {
+        HashMap<String, String> record = state.getOriginalRecord();
+        String value = getValue(record, LIFE_FORM);
+        String[] splits = value.split("\\s+");
+        if (splits.length > 2){
+            logger.warn("Unexpected length of lifeform: " + value + " line: "  + line );
+        }
+        CategoricalData catData = CategoricalData.NewInstance(Feature.LIFEFORM());
+        for (String split : splits){
+            State lifeform = lifeformMap.get(split);
+            if (lifeform == null){
+                logger.warn(line + "Unexpected lifeform: " + value);
+            }else{
+                catData.addStateData(lifeform);
+            }
+        }
+        desc.addElement(catData);
+
+    }
+
+    /**
+     * @param state
+     * @param line
+     * @param noStr
+     * @param desc
+     */
+    private void makeHabitat(SimpleExcelTaxonImportState<CONFIG> state, String line, String noStr,
+            TaxonDescription desc) {
+        CategoricalData catData = CategoricalData.NewInstance(Feature.HABITAT());
+        handleHabitat(state, catData, "A", FloraHellenicaTransformer.uuidHabitatA, line, noStr);
+        handleHabitat(state, catData, "C", FloraHellenicaTransformer.uuidHabitatC, line, noStr);
+        handleHabitat(state, catData, "G", FloraHellenicaTransformer.uuidHabitatG, line, noStr);
+        handleHabitat(state, catData, "H", FloraHellenicaTransformer.uuidHabitatH, line, noStr);
+        handleHabitat(state, catData, "M", FloraHellenicaTransformer.uuidHabitatM, line, noStr);
+        handleHabitat(state, catData, "P", FloraHellenicaTransformer.uuidHabitatP, line, noStr);
+        handleHabitat(state, catData, "R", FloraHellenicaTransformer.uuidHabitatR, line, noStr);
+        handleHabitat(state, catData, "W", FloraHellenicaTransformer.uuidHabitatW, line, noStr);
+        desc.addElement(catData);
+    }
+
+    /**
+     * @param state
+     * @param catData
+     * @param string
+     * @param uuidhabitata
+     * @param line
+     * @param noStr
+     */
+    private void handleHabitat(SimpleExcelTaxonImportState<CONFIG> state, CategoricalData catData, String label,
+            UUID uuidHabitat, String line, String noStr) {
+        HashMap<String, String> record = state.getOriginalRecord();
+        String value = getValue(record, "" + label);
+        if (value == null){
+            //do nothing
+        }else if (value.matches("[ACGHMPRW]")){
+            State habitatState = this.getStateTerm(state, uuidHabitat, null, null, null, habitatVoc);
+            catData.addStateData(habitatState);
+        }else{
+            logger.warn(line + "Unrecognized habitat state '" + value + "' for " + label);
+        }
+    }
+
+    /**
+     * @param state
+     * @param line
+     * @param noStr
+     * @param desc
+     */
+    private void makeDistribution(SimpleExcelTaxonImportState<CONFIG> state, String line, String noStr,
+            TaxonDescription desc) {
+        //TODO status Greece
+        handleStatus(state, desc, STATUS, FloraHellenicaTransformer.uuidAreaGreece, line, noStr);
+
+        handleDistribution(state, desc, "IoI", FloraHellenicaTransformer.uuidAreaIoI, line, noStr);
+        handleDistribution(state, desc, "NPi", FloraHellenicaTransformer.uuidAreaNPi, line, noStr);
+        handleDistribution(state, desc, "SPi", FloraHellenicaTransformer.uuidAreaSPi, line, noStr);
+        handleDistribution(state, desc, "Pe", FloraHellenicaTransformer.uuidAreaPe, line, noStr);
+        handleDistribution(state, desc, "StE", FloraHellenicaTransformer.uuidAreaStE, line, noStr);
+        handleDistribution(state, desc, "EC", FloraHellenicaTransformer.uuidAreaEC, line, noStr);
+        handleDistribution(state, desc, "NC", FloraHellenicaTransformer.uuidAreaNC, line, noStr);
+        handleDistribution(state, desc, "NE", FloraHellenicaTransformer.uuidAreaNE, line, noStr);
+        handleDistribution(state, desc, "NAe", FloraHellenicaTransformer.uuidAreaNAe, line, noStr);
+        handleDistribution(state, desc, "WAe", FloraHellenicaTransformer.uuidAreaWAe, line, noStr);
+        handleDistribution(state, desc, "Kik", FloraHellenicaTransformer.uuidAreaKik, line, noStr);
+        handleDistribution(state, desc, "KK", FloraHellenicaTransformer.uuidAreaKK, line, noStr);
+        handleDistribution(state, desc, "EAe", FloraHellenicaTransformer.uuidAreaEAe, line, noStr);
+    }
+
+    /**
+     * @param state
+     * @param line
+     * @param record
+     * @param noStr
+     * @return
+     */
+    private Taxon makeTaxon(SimpleExcelTaxonImportState<CONFIG> state, String line, HashMap<String, String> record,
+            String noStr) {
+
         TaxonNode familyTaxon = getFamilyTaxon(record, state);
         if (familyTaxon == null){
             logger.warn(line + "Family not created: " + record.get("Family"));
         TaxonNode familyTaxon = getFamilyTaxon(record, state);
         if (familyTaxon == null){
             logger.warn(line + "Family not created: " + record.get("Family"));
@@ -107,9 +282,10 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
         Rank rank = isSubSpecies ? Rank.SUBSPECIES() : Rank.SPECIES();
         BotanicalName name = (BotanicalName)parser.parseFullName(nameStr, state.getConfig().getNomenclaturalCode(), rank);
         if (name.isProtectedTitleCache()){
         Rank rank = isSubSpecies ? Rank.SUBSPECIES() : Rank.SPECIES();
         BotanicalName name = (BotanicalName)parser.parseFullName(nameStr, state.getConfig().getNomenclaturalCode(), rank);
         if (name.isProtectedTitleCache()){
-            logger.warn("Name could not be parsed: " + nameStr);
+            logger.warn(line + "Name could not be parsed: " + nameStr);
         }
         Taxon taxon = Taxon.NewInstance(name, getSecReference(state));
         }
         Taxon taxon = Taxon.NewInstance(name, getSecReference(state));
+        taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null);
 //        String parentStr = isSubSpecies ? makeSpeciesKey(genusStr, speciesStr, speciesAuthorStr) : genusStr;
         String parentStr = genusStr;
         boolean genusAsBefore = genusStr.equals(lastGenus);
 //        String parentStr = isSubSpecies ? makeSpeciesKey(genusStr, speciesStr, speciesAuthorStr) : genusStr;
         String parentStr = genusStr;
         boolean genusAsBefore = genusStr.equals(lastGenus);
@@ -143,7 +319,7 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
 //        this.lastFamily = familyStr
         this.lastGenus = genusStr;
         this.lastSpecies = speciesStr;
 //        this.lastFamily = familyStr
         this.lastGenus = genusStr;
         this.lastSpecies = speciesStr;
-
+        return taxon;
     }
 
     /**
     }
 
     /**
@@ -162,7 +338,7 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
      * @param genusStr
      * @return
      */
      * @param genusStr
      * @return
      */
-    private TaxonNode makeGenusNode(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
+    private TaxonNode makeGenusNode(SimpleExcelTaxonImportState<CONFIG> state,
             HashMap<String, String> record, String genusStr) {
         BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
         name.setGenusOrUninomial(genusStr);
             HashMap<String, String> record, String genusStr) {
         BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
         name.setGenusOrUninomial(genusStr);
@@ -175,21 +351,12 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
         return genusNode;
     }
 
         return genusNode;
     }
 
-    /**
-     * @param state
-     * @return
-     */
-    private Reference getSecReference(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     /**
      * @param state
      * @param parentStr
      * @return
      */
     /**
      * @param state
      * @param parentStr
      * @return
      */
-    private TaxonNode getParent(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, String parentStr) {
+    private TaxonNode getParent(SimpleExcelTaxonImportState<CONFIG> state, String parentStr) {
         Taxon taxon = state.getHigherTaxon(parentStr);
 
         return taxon == null ? null : taxon.getTaxonNodes().iterator().next();
         Taxon taxon = state.getHigherTaxon(parentStr);
 
         return taxon == null ? null : taxon.getTaxonNodes().iterator().next();
@@ -200,7 +367,7 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
      * @param state
      * @return
      */
      * @param state
      * @return
      */
-    private TaxonNode getFamilyTaxon(HashMap<String, String> record, SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
+    private TaxonNode getFamilyTaxon(HashMap<String, String> record, SimpleExcelTaxonImportState<CONFIG> state) {
         String familyStr = getValue(record, "Family");
         if (familyStr == null){
             return null;
         String familyStr = getValue(record, "Family");
         if (familyStr == null){
             return null;
@@ -215,8 +382,9 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
             BotanicalName name = makeFamilyName(state, familyStr);
             Reference sec = getSecReference(state);
             family = Taxon.NewInstance(name, sec);
             BotanicalName name = makeFamilyName(state, familyStr);
             Reference sec = getSecReference(state);
             family = Taxon.NewInstance(name, sec);
-            ITaxonTreeNode rootNode = getClassification(state);
-            familyNode = rootNode.addChildTaxon(family, sec, null);
+
+            ITaxonTreeNode groupNode = getGroupTaxon(record, state);
+            familyNode = groupNode.addChildTaxon(family, sec, null);
             state.putHigherTaxon(familyStr, family);
             getTaxonNodeService().save(familyNode);
         }
             state.putHigherTaxon(familyStr, family);
             getTaxonNodeService().save(familyNode);
         }
@@ -225,21 +393,36 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
     }
 
     /**
     }
 
     /**
+     * @param record
      * @param state
      * @param state
-     * @param famStr
      * @return
      */
      * @return
      */
-    private BotanicalName makeFamilyName(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, String famStr) {
-        BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY());
-        name.setGenusOrUninomial(famStr);
-        name.addSource(makeOriginalSource(state));
-        return name;
-    }
+    private TaxonNode getGroupTaxon(HashMap<String, String> record, SimpleExcelTaxonImportState<CONFIG> state) {
+        String groupStr = getValue(record, "Group");
+        if (groupStr == null){
+            return null;
+        }
+        groupStr = groupStr.trim();
 
 
+        Taxon group = state.getHigherTaxon(groupStr);
+        TaxonNode groupNode;
+        if (group != null){
+            groupNode = group.getTaxonNodes().iterator().next();
+        }else{
+            BotanicalName name = makeFamilyName(state, groupStr);
+            Reference sec = getSecReference(state);
+            group = Taxon.NewInstance(name, sec);
+            ITaxonTreeNode rootNode = getClassification(state);
+            groupNode = rootNode.addChildTaxon(group, sec, null);
+            state.putHigherTaxon(groupStr, group);
+            getTaxonNodeService().save(groupNode);
+        }
 
 
+        return groupNode;
+    }
 
     private TaxonNode rootNode;
 
     private TaxonNode rootNode;
-    private TaxonNode getClassification(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
+    private TaxonNode getClassification(SimpleExcelTaxonImportState<CONFIG> state) {
         if (rootNode == null){
             Reference sec = getSecReference(state);
             String classificationName = state.getConfig().getClassificationName();
         if (rootNode == null){
             Reference sec = getSecReference(state);
             String classificationName = state.getConfig().getClassificationName();
@@ -260,5 +443,328 @@ public class FloraHellenicaTaxonImport extends SimpleExcelTaxonImport<FloraHelle
         return rootNode;
     }
 
         return rootNode;
     }
 
+    /**
+     * @param desc
+     * @param string
+     * @param uuidUserDefinedAnnotationTypeVocabulary
+     */
+    private void handleDistribution(SimpleExcelTaxonImportState<CONFIG> state,
+                TaxonDescription desc, String key, UUID uuid, String line, String id) {
+        HashMap<String, String> record = state.getOriginalRecord();
+        String value = getValue(record, key);
+        if (value == null || value.matches("[x\\.\\?]")){
+            NamedArea area = getNamedArea(state, uuid, null, null, null, null, null);
+            Distribution dist;
+            if (".".equals(value)){
+                logger.warn(line + "'.' Should not exist anmore as a distribution status: '" + value + "' for " + key);
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.ABSENT());
+            }else if (value == null){
+                //TODO is absent wanted
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.ABSENT());
+            }else if ("x".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.PRESENT());
+            }else if ("?".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.PRESENT_DOUBTFULLY());
+            }else {
+                logger.warn(line + "Not matching status. THis should not happpen '" + value + "' for " + key);
+                return;
+            }
+            desc.addElement(dist);
+            dist.addImportSource(id, getWorksheetName(), getSourceCitation(state), line);
+        }else {
+            logger.warn(line + "Unrecognized distribution status '" + value + "' for " + key);
+        }
+    }
+
+    private void handleStatus(SimpleExcelTaxonImportState<CONFIG> state,
+            TaxonDescription desc, String key, UUID uuid, String line, String id) {
+        HashMap<String, String> record = state.getOriginalRecord();
+        String value = getValue(record, key);
+        if (value != null){
+            NamedArea area = getNamedArea(state, uuid, null, null, null, null, null);
+            Distribution dist;
+            if (".".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.ABSENT());
+                logger.warn(line + "'.' Should not exist anmore as a distribution status: '" + value + "' for " + key);
+            }else if ("Range-restricted".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA());
+            }else if ("?Range-restricted".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA());
+            }else if ("Xenophyte".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED());
+            }else if ("?Xenophyte".equals(value)){
+                dist = Distribution.NewInstance(area, PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED());
+            }else {
+                logger.warn(line + "Not matching status. This should not happpen '" + value + "' for " + key);
+                return;
+            }
+            desc.addElement(dist);
+            dist.addImportSource(id, getWorksheetName(), getSourceCitation(state), line);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void initAreaVocabulary(SimpleExcelTaxonImportState<CONFIG> state) {
+        if (areasVoc == null){
+            areasVoc = (OrderedTermVocabulary<NamedArea>)this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc);
+            if (areasVoc == null){
+                createAreasVoc(state);
+            }
+        }
+    }
+
+
+    /**
+     * @param state
+     */
+    private void initChorologicalVocabulary(SimpleExcelTaxonImportState<CONFIG> state) {
+        if (chorologicalVoc == null){
+            UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaChorologicalVoc;
+            chorologicalVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
+            if (chorologicalVoc == null){
+                createChorologicalVoc(state, uuid);
+            }
+        }
+
+    }
+
+
+    @SuppressWarnings("unchecked")
+    private void initLifeformVocabulary(SimpleExcelTaxonImportState<CONFIG> state) {
+        if (lifeformVoc == null){
+            UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaLifeformVoc;
+            lifeformVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
+            if (lifeformVoc == null){
+                createLifeformVoc(state, uuid);
+            }
+        }
+    }
+
+    /**
+     * @param state
+     * @param vocUuid
+     */
+    private void createLifeformVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) {
+        //voc
+        URI termSourceUri = null;
+        String label = "Checklist of Greece Lifeforms";
+        String description = "Lifeforms as used in the Checklist of Greece";
+        lifeformVoc = OrderedTermVocabulary.NewInstance(TermType.State,
+                description, label, null, termSourceUri);
+        lifeformVoc.setUuid(vocUuid);
+
+        addLifeform(state, "A", "Aquatics", FloraHellenicaTransformer.uuidLifeformA);
+        addLifeform(state, "C", "Chamaephytes", FloraHellenicaTransformer.uuidLifeformC);
+        addLifeform(state, "G", "Geophytes (Cryptophytes)", FloraHellenicaTransformer.uuidLifeformG);
+        addLifeform(state, "H", "Hemicryptophytes", FloraHellenicaTransformer.uuidLifeformH);
+        addLifeform(state, "P", "Phanerophytes", FloraHellenicaTransformer.uuidLifeformP);
+        addLifeform(state, "T", "Therophytes", FloraHellenicaTransformer.uuidLifeformT);
+        this.getVocabularyService().save(lifeformVoc);
+        return;
+    }
+
+
+    /**
+     * @param state
+     * @param uuid
+     */
+    private void createChorologicalVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) {
+        //voc
+        URI termSourceUri = null;
+        String label = "Checklist of Greece Chorological Categories";
+        String description = "Chorological Categories as used in the Checklist of Greece";
+        chorologicalVoc = OrderedTermVocabulary.NewInstance(TermType.State,
+                description, label, null, termSourceUri);
+        chorologicalVoc.setUuid(vocUuid);
+
+        addChorological(state, "Bk", "Balkan", "", FloraHellenicaTransformer.uuidChorologicalBk);
+        addChorological(state, "BI", "Balkan-Italy", "", FloraHellenicaTransformer.uuidChorologicalBI);
+        addChorological(state, "BA", "Balkan-Anatolia", "", FloraHellenicaTransformer.uuidChorologicalBA);
+        addChorological(state, "BC", "Balkan-Central Europe", "", FloraHellenicaTransformer.uuidChorologicalBC);
+        addChorological(state, "EM", "East Mediterranean", "", FloraHellenicaTransformer.uuidChorologicalEM);
+        addChorological(state, "Me", "Mediterranean", "", FloraHellenicaTransformer.uuidChorologicalMe);
+        addChorological(state, "MA", "Mediterranean-Atlantic", "", FloraHellenicaTransformer.uuidChorologicalMA);
+        addChorological(state, "ME", "Mediterranean-European", "", FloraHellenicaTransformer.uuidChorologicalME);
+        addChorological(state, "MS", "Mediterranean-SW Asian", "", FloraHellenicaTransformer.uuidChorologicalMS);
+        addChorological(state, "EA", "European-SW Asian", "", FloraHellenicaTransformer.uuidChorologicalEA);
+        addChorological(state, "ES", "Euro-Siberian", "", FloraHellenicaTransformer.uuidChorologicalES);
+        addChorological(state, "Eu", "European", "", FloraHellenicaTransformer.uuidChorologicalEu);
+        addChorological(state, "Pt", "Paleotemperate", "", FloraHellenicaTransformer.uuidChorologicalPt);
+        addChorological(state, "Ct", "Circumtemperate", "", FloraHellenicaTransformer.uuidChorologicalCt);
+        addChorological(state, "IT", "Irano-Turanian", "", FloraHellenicaTransformer.uuidChorologicalIT);
+        addChorological(state, "SS", "Saharo-Sindian", "", FloraHellenicaTransformer.uuidChorologicalSS);
+        addChorological(state, "ST", "Subtropical-tropical", "", FloraHellenicaTransformer.uuidChorologicalST);
+        addChorological(state, "Bo", "(Circum-) Boreal", "", FloraHellenicaTransformer.uuidChorologicalBo);
+        addChorological(state, "AA", "Arctic-Alpine", "", FloraHellenicaTransformer.uuidChorologicalAA);
+        addChorological(state, "Co", "Cosmopolitan", "", FloraHellenicaTransformer.uuidChorologicalCo);
+        addChorological(state, "*", "Greek endemic", "Greek endemics (incl. single-island and single-mountain endemics)", FloraHellenicaTransformer.uuidChorologicalStar);
+
+        this.getVocabularyService().save(chorologicalVoc);
+        return;
+
+    }
+
+
+    /**
+     * @param state
+     * @param string
+     * @param string2
+     * @param string3
+     * @param uuidchorologicalstar
+     */
+    private void addChorological(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String label,
+            String string3, UUID uuidChorological) {
+        State chorological = addState(state, abbrevLabel, label, label, uuidChorological, chorologicalVoc);
+
+
+    }
+
+    /**
+     * @param state
+     * @param string
+     * @param uuidlifeformt
+     */
+    private void addLifeform(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String label, UUID uuidlifeform) {
+        State lifeForm = addState(state, abbrevLabel, label, label, uuidlifeform, lifeformVoc);
+        lifeformMap.put(abbrevLabel, lifeForm);
+    }
+
+    private State addState(SimpleExcelTaxonImportState<CONFIG> state,
+            String abbrev, String stateLabel, String description, UUID uuid, OrderedTermVocabulary<State> voc) {
+        State newState = State.NewInstance(
+                description, stateLabel, abbrev);
+        newState.setUuid(uuid);
+        newState.setIdInVocabulary(abbrev);
+        newState.setIdInVocabulary(abbrev);
+        voc.addTerm(newState);
+        return newState;
+    }
+
+    private void initHabitatVocabulary(SimpleExcelTaxonImportState<CONFIG> state) {
+        if (habitatVoc == null){
+            UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaHabitatVoc;
+            habitatVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
+            if (habitatVoc == null){
+                createHabitatVoc(state, uuid);
+            }
+        }
+    }
+
+
+    /**
+     * @param state
+     */
+    private void createHabitatVoc(SimpleExcelTaxonImportState<CONFIG> state, UUID vocUuid) {
+        //voc
+        URI termSourceUri = null;
+        String label = "Checklist of Greece Habitats";
+        String description = "Habitats as used in the Checklist of Greece";
+        habitatVoc = OrderedTermVocabulary.NewInstance(TermType.State,
+                description, label, null, termSourceUri);
+        habitatVoc.setUuid(vocUuid);
+
+        addHabitat(state, "A", "Freshwater habitats", "Freshwater habitats (Aquatic habitats, springs and fens, reedbeds and damp tall herb vegetation, seasonally flooded depressions, damp and seepage meadows, streambanks, river and lake shores)", FloraHellenicaTransformer.uuidHabitatA);
+        addHabitat(state, "C", "Cliffs, rocks, walls, ravines, boulders", "Cliffs, rocks, walls, ravines, boulders", FloraHellenicaTransformer.uuidHabitatC);
+        addHabitat(state, "G", "Temperate and submediterranean Grasslands", "Temperate and submediterranean Grasslands (lowland to montane dry and mesic meadows and pastures, rock outcrops and stony ground, grassy non-ruderal verges and forest edges)", FloraHellenicaTransformer.uuidHabitatG);
+        addHabitat(state, "H", "High mountain vegetation", "High mountain vegetation (subalpine and alpine grasslands, screes and rocks, scrub above the treeline)", FloraHellenicaTransformer.uuidHabitatH);
+        addHabitat(state, "M", "Coastal habitats", "Coastal habitats (Marine waters and mudflats, salt marshes, sand dunes, littoral rocks, halo-nitrophilous scrub)", FloraHellenicaTransformer.uuidHabitatM);
+        addHabitat(state, "P", "Xeric Mediterranean Phrygana and grasslands", "Xeric Mediterranean Phrygana and grasslands (Mediterranean dwarf shrub formations, annual-rich pastures and lowland screes)", FloraHellenicaTransformer.uuidHabitatP);
+        addHabitat(state, "R", "Agricultural and Ruderal habitats", "Agricultural and Ruderal habitats (fields, gardens and plantations, roadsides and trampled sites, frequently disturbed and pioneer habitats)", FloraHellenicaTransformer.uuidHabitatR);
+        addHabitat(state, "W", "Woodlands and scrub", "Woodlands and scrub (broadleaved and coniferous forest, riparian and mountain forest and scrub, hedges, shady woodland margins)", FloraHellenicaTransformer.uuidHabitatW);
+
+        this.getVocabularyService().save(habitatVoc);
+        return;
+    }
+
+    /**
+     * @param state
+     * @param string
+     * @param uuidlifeformt
+     */
+    private void addHabitat(SimpleExcelTaxonImportState<CONFIG> state, String abbrev, String label, String desc, UUID uuidHabitat) {
+        addState(state, abbrev, label, desc, uuidHabitat, habitatVoc);
+    }
+
+    /**
+     * @param state
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    private void createAreasVoc(SimpleExcelTaxonImportState<CONFIG> state) {
+        //voc
+        URI termSourceUri = null;
+        String label = "Checklist of Greece Areas";
+        String description = "Areas as used in the Checklist of Greece";
+        areasVoc = OrderedTermVocabulary.NewInstance(TermType.NamedArea,
+                description, label, null, termSourceUri);
+        areasVoc.setUuid(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc);
+//        Representation rep = Representation.NewInstance("Estados Méxicanos", "Estados Méxicanos", null, Language.SPANISH_CASTILIAN());
+//        areasVoc.addRepresentation(rep);
+
+        //greece country
+        String countryLabel = "Greece";
+        greece = NamedArea.NewInstance(
+                countryLabel, countryLabel, null);
+        greece.setUuid(FloraHellenicaTransformer.uuidAreaGreece);
+        areasVoc.addTerm(greece);
+        //FIXME
+//        addMapping(greece, xx "mex_adm0", "iso", "MEX");
+
+        addArea(state, "IoI", "Ionian Islands", FloraHellenicaTransformer.uuidAreaIoI);
+        addArea(state, "NPi", "North Pindos", FloraHellenicaTransformer.uuidAreaNPi);
+        addArea(state, "SPi", "South Pindos", FloraHellenicaTransformer.uuidAreaSPi);
+        addArea(state, "Pe", "Peloponnisos", FloraHellenicaTransformer.uuidAreaPe);
+        addArea(state, "StE", "Sterea Ellas", FloraHellenicaTransformer.uuidAreaStE);
+        addArea(state, "EC", "East Central Greece", FloraHellenicaTransformer.uuidAreaEC);
+        addArea(state, "NC", "North Central Greece", FloraHellenicaTransformer.uuidAreaNC);
+        addArea(state, "NE", "North-East Greece", FloraHellenicaTransformer.uuidAreaNE);
+        addArea(state, "NAe", "North Aegean islands", FloraHellenicaTransformer.uuidAreaNAe);
+        addArea(state, "WAe", "West Aegean islands", FloraHellenicaTransformer.uuidAreaWAe);
+        addArea(state, "Kik", "Kiklades", FloraHellenicaTransformer.uuidAreaKik);
+        addArea(state, "KK", "Kriti and Karpathos", FloraHellenicaTransformer.uuidAreaKK);
+        addArea(state, "EAe", "East Aegean islands", FloraHellenicaTransformer.uuidAreaEAe);
+
+        this.getVocabularyService().save(areasVoc);
+        return;
+    }
+
+    private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, UUID uuid) {
+        addArea(state, abbrevLabel, areaLabel, uuid, areaLabel);  //short cut if label and mapping label are equal
+    }
+
+    private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel,
+            UUID uuid, String mappingLabel) {
+        addArea(state, abbrevLabel, areaLabel, uuid, mappingLabel, null);  //short cut if label and mapping label are equal
+    }
+
+
+    /**
+     * @param state
+     * @param string
+     * @param uuidaguascalientes
+     */
+    private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, UUID uuid, String mappingLabel, Integer id1) {
+        NamedArea newArea = NamedArea.NewInstance(
+                areaLabel, areaLabel, abbrevLabel);
+        newArea.setIdInVocabulary(abbrevLabel);
+        newArea.setUuid(uuid);
+        newArea.setPartOf(greece);
+        newArea.setLevel(null);
+        newArea.setType(NamedAreaType.NATURAL_AREA());
+        areasVoc.addTerm(newArea);
+        //FIXME
+        if (id1 != null){
+            addMapping(newArea, "mex_adm1", "id_1", String.valueOf(id1));
+        }else if (mappingLabel != null){
+            addMapping(newArea, "mex_adm1", "name_1", mappingLabel);
+        }
+    }
+
+    private void addMapping(NamedArea area, String mapping_layer, String mapping_field, String abbrev) {
+        GeoServiceAreaAnnotatedMapping mapping = (GeoServiceAreaAnnotatedMapping)this.getBean("geoServiceAreaAnnotatedMapping");
+        GeoServiceArea geoServiceArea = new GeoServiceArea();
+        geoServiceArea.add(mapping_layer, mapping_field, abbrev);
+        mapping.set(area, geoServiceArea);
+    }
 
 }
 
 }
index 3d0245b55d5b0b2f5b44382df281a264b31f3c41..90a6fddd979420d8cc5e2cb4fd05efb5dd9b0ce3 100644 (file)
@@ -8,6 +8,8 @@
 */
 package eu.etaxonomy.cdm.io.greece;
 
 */
 package eu.etaxonomy.cdm.io.greece;
 
+import java.util.UUID;
+
 import org.apache.log4j.Logger;
 
 import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
 import org.apache.log4j.Logger;
 
 import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
@@ -23,4 +25,73 @@ public class FloraHellenicaTransformer extends InputTransformerBase{
     @SuppressWarnings("unused")
     private static final Logger logger = Logger.getLogger(FloraHellenicaTransformer.class);
 
     @SuppressWarnings("unused")
     private static final Logger logger = Logger.getLogger(FloraHellenicaTransformer.class);
 
+
+    //areas
+    protected static final UUID uuidFloraHellenicaAreasVoc = UUID.fromString("4516586a-d988-456f-afbe-ed8f969fd933");
+
+    protected static final UUID uuidAreaGreece = UUID.fromString("0429196a-7a72-4a11-baaf-21a56a6f8726");
+
+    protected static final UUID uuidAreaIoI = UUID.fromString("87ce6f55-b720-48e4-8dd0-4c8a471f0b3b");
+    protected static final UUID uuidAreaNPi = UUID.fromString("c701a567-3af8-4b67-918c-c96874ba230c");
+    protected static final UUID uuidAreaSPi = UUID.fromString("cba230b1-8053-4803-9218-55af5f70dcde");
+    protected static final UUID uuidAreaPe = UUID.fromString("a90daea5-4145-4a0c-964b-75d8c4be7f20");
+    protected static final UUID uuidAreaStE = UUID.fromString("e75997fd-f86c-4305-9856-ce6a29e11cd5");
+    protected static final UUID uuidAreaEC = UUID.fromString("06d14fb0-4d66-4abf-83f8-a2f84b6d700e");
+    protected static final UUID uuidAreaNC = UUID.fromString("6dda6631-f5e3-4e36-aafc-e0bf6880ee89");
+    protected static final UUID uuidAreaNE = UUID.fromString("c2877f57-69e5-4bb4-8094-f405f2b54b1b");
+    protected static final UUID uuidAreaNAe = UUID.fromString("afd706c1-6b48-4471-b01a-705d8905487d");
+    protected static final UUID uuidAreaWAe = UUID.fromString("d7d99e01-297a-400f-8839-a6c2ea478dab");
+    protected static final UUID uuidAreaKik = UUID.fromString("951288c4-fcc6-4fa5-a86f-313eb325aa70");
+    protected static final UUID uuidAreaKK = UUID.fromString("9ea69f67-710a-4db2-b46b-bb056afd0ed7");
+    protected static final UUID uuidAreaEAe = UUID.fromString("06af05de-8d08-42e2-9eec-e3bd9d1d690f");
+
+    //Lifeforms
+    protected static final UUID uuidFloraHellenicaLifeformVoc = UUID.fromString("e76daed0-0540-4635-ba9e-04c77e6f379f");
+
+    protected static final UUID uuidLifeformA = UUID.fromString("d27a36ac-25f0-4055-a7fd-93f0eb50782d");
+    protected static final UUID uuidLifeformC = UUID.fromString("5bf4a77f-bb56-486b-8be2-98a8edd55f96");
+    protected static final UUID uuidLifeformG = UUID.fromString("4c7c857f-ee70-4c22-baee-0b9d1d1f3b37");
+    protected static final UUID uuidLifeformH = UUID.fromString("c0ca9ff1-07fe-4601-843f-c29233dd30e1");
+    protected static final UUID uuidLifeformP = UUID.fromString("2302f4e8-d525-4e96-9a3f-736a724678c2");
+    protected static final UUID uuidLifeformT = UUID.fromString("73eb4a05-b818-4faf-8e35-95cb1759b353");
+
+    //Habitats
+    protected static final UUID uuidFloraHellenicaHabitatVoc = UUID.fromString("159ee95c-2d25-48b9-be00-391520d4dda8");
+    protected static final UUID uuidHabitatA = UUID.fromString("86938704-b3e7-43c3-838e-09a8e27aa70e");
+    protected static final UUID uuidHabitatC = UUID.fromString("c9e11750-a8b7-4b58-8cb4-23997306d27e");
+    protected static final UUID uuidHabitatG = UUID.fromString("910beaea-818d-4ef4-8b03-b0f67ca38579");
+    protected static final UUID uuidHabitatH = UUID.fromString("768b2e8c-11a8-46d6-aa02-9044d0dbd9aa");
+    protected static final UUID uuidHabitatM = UUID.fromString("89c188f8-53ef-44aa-bf09-c0d7fc8634dd");
+    protected static final UUID uuidHabitatP = UUID.fromString("10f44eb6-c566-44ed-862b-9952cc0b5fc1");
+    protected static final UUID uuidHabitatR = UUID.fromString("ebe8ffba-7155-4dbe-9b09-faa38a61276a");
+    protected static final UUID uuidHabitatW = UUID.fromString("b72dc722-d85b-4496-8828-1eeccb37849a");
+
+    //Chorological Category
+    protected static final UUID uuidFloraHellenicaChorologicalVoc = UUID.fromString("7c95ac7f-e3ea-46c2-863f-9ad663f5086c");
+    //Chorological Category
+    public static final UUID uuidFloraHellenicaChorologyFeature = UUID.fromString("fab27b99-c480-4873-bcfc-39235f6d0c5d");
+
+    protected static final UUID uuidChorologicalBk = UUID.fromString("53a75041-b8ab-4890-82a3-f29117db8609");
+    protected static final UUID uuidChorologicalBI = UUID.fromString("bc031c19-8f30-474d-b091-81795652920e");
+    protected static final UUID uuidChorologicalBA = UUID.fromString("4bc0cb8c-5d06-466d-9ace-7f1f4d54f8a3");
+    protected static final UUID uuidChorologicalBC = UUID.fromString("f9cfa10d-5d7c-4e5a-a3ca-602420e993fc");
+    protected static final UUID uuidChorologicalEM = UUID.fromString("0ba71db1-b1e3-4878-bc0b-b00dc0e020ed");
+    protected static final UUID uuidChorologicalMe = UUID.fromString("3120f73c-252a-4399-a691-7c042f0cf46a");
+    protected static final UUID uuidChorologicalMA = UUID.fromString("dafd0326-9c20-42cd-8e48-22c1ec2fb294");
+    protected static final UUID uuidChorologicalME = UUID.fromString("166b2e99-9638-4814-85e1-8d83a1b9c134");
+    protected static final UUID uuidChorologicalMS = UUID.fromString("54aa0d56-e76a-49fa-bde0-874aa5475e76");
+    protected static final UUID uuidChorologicalEA = UUID.fromString("8c7124a7-34f6-4c04-bae3-f5e356da8336");
+    protected static final UUID uuidChorologicalES = UUID.fromString("d953cd36-c58b-47ee-8347-8d812195ca41");
+    protected static final UUID uuidChorologicalEu = UUID.fromString("714e4572-4d31-4529-acb2-1f323c601b0d");
+    protected static final UUID uuidChorologicalPt = UUID.fromString("54bce677-c050-44c9-9ee2-8fc15b0cc4f3");
+    protected static final UUID uuidChorologicalCt = UUID.fromString("2fdbd40d-3ac4-4a84-a6ff-438c24f9ddd7");
+    protected static final UUID uuidChorologicalIT = UUID.fromString("22007c0f-85ec-46e3-b288-88c5e0b7a66a");
+    protected static final UUID uuidChorologicalSS = UUID.fromString("d5ccaabf-0f18-4521-979e-9d27c3b712ea");
+    protected static final UUID uuidChorologicalST = UUID.fromString("4f1415db-37ac-4f9b-ade8-1df9182350ec");
+    protected static final UUID uuidChorologicalBo = UUID.fromString("0760211d-a081-410d-a41d-4f3acfc69ed0");
+    protected static final UUID uuidChorologicalAA = UUID.fromString("ddb45c19-135f-49f3-8dc5-04125b546d8e");
+    protected static final UUID uuidChorologicalCo = UUID.fromString("9ec7e14c-43a7-4086-9840-9beb6689655d");
+    protected static final UUID uuidChorologicalStar = UUID.fromString("2fb30e13-4fa6-46e8-928e-4ddecec63d62");
+
+
 }
 }
index 345db0fee0b4fac56fa032665321909f250c02f7..5f0e25afc7d108a3584c38c253bd9cf6cc410c74 100644 (file)
@@ -41,6 +41,7 @@ public class SimpleExcelTaxonImportState<CONFIG extends ExcelImportConfiguratorB
     //using titleCache
     private Map<String, INonViralName> nameMap = new HashMap<>();
 
     //using titleCache
     private Map<String, INonViralName> nameMap = new HashMap<>();
 
+    private final Map<String, Taxon> taxonMap = new HashMap<>();
 
 // ************************* CONSTRUCTUR *******************************/
     /**
 
 // ************************* CONSTRUCTUR *******************************/
     /**
@@ -88,4 +89,18 @@ public class SimpleExcelTaxonImportState<CONFIG extends ExcelImportConfiguratorB
         return nameMap.get(titleCache);
     }
 
         return nameMap.get(titleCache);
     }
 
+    //higher taxon
+    public Taxon getTaxon(String key) {
+        return taxonMap.get(key);
+    }
+    public Taxon putTaxon(String key, Taxon taxon) {
+        return taxonMap.put(key, taxon);
+    }
+    public Taxon removeTaxon(String key) {
+        return taxonMap.remove(key);
+    }
+    public boolean containsTaxon(String key) {
+        return taxonMap.containsKey(key);
+    }
+
 }
 }