commit e5920e9976d4062acce82626f5939b27a3518250
Author: Katja Luther <k.luther@bgbm.org>
Date:   Wed Aug 20 13:24:33 2014 +0000

diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportConfigurator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportConfigurator.java
index 87041704..5d0f844c 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportConfigurator.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportConfigurator.java
@@ -50,6 +50,7 @@ public class IndexFungorumImportConfigurator extends DbImportConfiguratorBase<In
 				, IndexFungorumHigherClassificationImport.class
 				, IndexFungorumGeneraImport.class
 				, IndexFungorumSpeciesImport.class
+				, IndexFungorumSubSpeciesImport.class
 				, IndexFungorumDistributionImport.class
 		};	
 	}
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportState.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportState.java
index 060ca9c8..bb4ecb77 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportState.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumImportState.java
@@ -10,8 +10,13 @@
 
 package eu.etaxonomy.cdm.io.pesi.indexFungorum;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 
 import org.apache.log4j.Logger;
 
@@ -37,11 +42,23 @@ public class IndexFungorumImportState extends DbImportStateBase<IndexFungorumImp
 	private Map<Integer, Map<Integer,Rank>> rankMap;
 
 	private Map<String, TaxonBase> speciesMap;
+	
+	private List<UUID> infraspecificTaxaUUIDs = new ArrayList<UUID>();
 
 
 
 
-    public IndexFungorumImportState(IndexFungorumImportConfigurator config) {
+    public List<UUID> getInfraspecificTaxaUUIDs() {
+		return infraspecificTaxaUUIDs;
+	}
+
+
+	public void setInfraspecificTaxaUUIDs(List<UUID> infraspecificTaxaUUIDs) {
+		this.infraspecificTaxaUUIDs = infraspecificTaxaUUIDs;
+	}
+
+
+	public IndexFungorumImportState(IndexFungorumImportConfigurator config) {
 		super(config);
 	}
 
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumSpeciesImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumSpeciesImport.java
index de96c39e..43b750cf 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumSpeciesImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumSpeciesImport.java
@@ -40,6 +40,7 @@ import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
 
 
@@ -53,7 +54,7 @@ public class IndexFungorumSpeciesImport  extends IndexFungorumImportBase {
 
 	private static final String pluralString = "species";
 	private static final String dbTableName = "[tblPESIfungi-IFdata]";
-	private final Set<UUID> infraspecificTaxaUUIDs = new HashSet<UUID>();
+	
 
 	public IndexFungorumSpeciesImport(){
 		super(pluralString, dbTableName, null);
@@ -89,52 +90,9 @@ public class IndexFungorumSpeciesImport  extends IndexFungorumImportBase {
 	@Override
     protected void doInvoke(IndexFungorumImportState state){
         System.out.println("start make " + getPluralString() + " ...");
-        IndexFungorumImportConfigurator config = state.getConfig();
-        Source source = config.getSource();
-
         super.doInvoke(state);
-        Classification classification = getClassification(state);
-        List<TaxonBase> infraspecificTaxa = new ArrayList<TaxonBase>();
-        for (UUID uuid: infraspecificTaxaUUIDs){
-            infraspecificTaxa.add(getTaxonService().load(uuid));
-        }
-
-        System.out.println("create infraspecific - specific relationship: " + infraspecificTaxa.size() + " taxa");
-        for (TaxonBase infraspecificTaxon: infraspecificTaxa){
-            HibernateProxyHelper.deproxy(infraspecificTaxon);
-            TaxonNameBase name = infraspecificTaxon.getName();
-
-            UUID uuid = getNameService().saveOrUpdate(name);
-            String parentNameString = getParentNameInfraSpecific(name);
-            System.out.println("Parent name string: " + parentNameString);
-            MatchingTaxonConfigurator matchingConfig = new MatchingTaxonConfigurator();
-            matchingConfig.setTaxonNameTitle(parentNameString);
-            List<String> propertyPaths = new ArrayList<String>();
-            propertyPaths.add("taxonNodes.*");
-            propertyPaths.add("taxonNodes.classification");
-            propertyPaths.add("taxonNodes.childNodes.*");
-            propertyPaths.add("taxonNodes.childNodes.taxon.*");
-            propertyPaths.add("taxonNodes.parent.*");
-            propertyPaths.add("taxonNodes.parent.taxon.*");
-            matchingConfig.setPropertyPath(propertyPaths);
-            List<TaxonBase> potentialParents = getTaxonService().findTaxaByName(matchingConfig);
-                    //Taxon.class, parentNameString + "sec. ", MatchMode.BEGINNING, , pageSize, pageNumber, orderHints, propertyPaths)
-                    //.searchNames(String uninomial,String infraGenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
-            if (potentialParents.size()>1){
-                for (TaxonBase potentialParent:potentialParents){
-                    if (potentialParent.getTitleCache().equals(parentNameString + " sec*")){
-                        classification.addParentChild((Taxon)potentialParent, (Taxon)infraspecificTaxon, null, null);
-                    }
-                }
-            }else if (!potentialParents.isEmpty()){
-                Taxon parent = HibernateProxyHelper.deproxy(potentialParents.get(0), Taxon.class);
-                Taxon child = (Taxon)getTaxonService().load(infraspecificTaxon.getUuid(), propertyPaths);
-                classification.addParentChild(parent, child, null, null);
-            } else{
-                System.out.println("No parent for: " + name.getTitleCache());
-            }
-            getTaxonService().saveOrUpdate(infraspecificTaxon);
-        }
+        
+       
 
 
 	}
@@ -188,9 +146,9 @@ public class IndexFungorumSpeciesImport  extends IndexFungorumImportBase {
 				//save
 
 				UUID uuidTaxon = getTaxonService().saveOrUpdate(taxon);
-				getNameService().saveOrUpdate(name);
+				//getNameService().saveOrUpdate(name);
 				if (name.isInfraSpecific()){
-                    infraspecificTaxaUUIDs.add(uuidTaxon);
+                    state.getInfraspecificTaxaUUIDs().add(uuidTaxon);
                 }
 
 			}
@@ -206,16 +164,7 @@ public class IndexFungorumSpeciesImport  extends IndexFungorumImportBase {
 	}
 
 
-	/**
-     * @param taxon
-     * @return
-     */
-    private String getParentNameInfraSpecific(TaxonNameBase taxonName){
-       NonViralName<NonViralName> name =  HibernateProxyHelper.deproxy(taxonName, NonViralName.class);
-       String parentName = name.getGenusOrUninomial() + " " + name.getSpecificEpithet();
-
-       return parentName;
-    }
+	
 
 
 
