import eu.etaxonomy.cdm.model.reference.Publisher;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
+import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;\r
private static final Logger logger = Logger.getLogger(FaunaEuropaeaTaxonImport.class);\r
\r
/* Max number of taxa to retrieve (for test purposes) */\r
- private int maxTaxa = 0;\r
+ private int maxTaxa = 5000;\r
/* Max number of taxa to be saved with one service call */\r
private int limit = 10000; // TODO: Make configurable\r
/* Interval for progress info message when retrieving taxa */\r
for (int id : taxonStore.keySet())\r
{\r
TaxonBase<?> taxonBase = taxonStore.get(id);\r
+ TaxonNameBase<?,?> taxonName = taxonBase.getName();\r
FaunaEuropaeaTaxon fauEuTaxon = fauEuTaxonMap.get(id);\r
\r
if (logger.isDebugEnabled()) { logger.debug("Taxon # " + id); }\r
- String nameString = calculateTaxonName(fauEuTaxon, taxonBase, taxonStore, fauEuTaxonMap);\r
-// String nameString = calculateTaxonName(fauEuTaxon, taxonBase, taxonStore);\r
+ String nameString = calculateTaxonName(fauEuTaxon, taxonBase, taxonName, taxonStore, fauEuTaxonMap);\r
+ createRelationships(fauEuTaxon, taxonBase, taxonName, fauEuTaxonMap);\r
setTaxonName(nameString, fauEuTaxon, taxonBase, fauEuConfig);\r
- \r
}\r
return success; \r
}\r
}\r
return result;\r
}\r
- \r
+\r
+ private boolean createRelationships(FaunaEuropaeaTaxon fauEuTaxon,\r
+ TaxonBase<?> taxonBase, TaxonNameBase<?,?> taxonName,\r
+ Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap) {\r
+ \r
+ boolean success = true;\r
+ \r
+ if (!fauEuTaxon.isValid()) {\r
+\r
+ try {\r
+\r
+ Taxon taxon = taxonBase.deproxy(taxonBase, Taxon.class);\r
+ Synonym synonym = Synonym.NewInstance(taxonName, null); // TODO: sec\r
+ taxon.addSynonym(synonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());\r
+\r
+ } catch (Exception e) {\r
+\r
+ }\r
+ }\r
+ \r
+ return success;\r
+ \r
+ }\r
\r
/* Build parent's taxon name */\r
private String buildParentName(int originalTaxonRank, String concatString, FaunaEuropaeaTaxon fauEuTaxon,\r
// if(parentName != null) {\r
// parentString = ((ZoologicalName)parentName).getNameCache();\r
\r
-\r
parentString = parent.getLocalName();\r
-\r
+ \r
+ \r
// if (fauEuTaxon.isValid()) {\r
// parentString = parent.getLocalName();\r
// } else {\r
\r
/* Build taxon's concatenated name string */\r
private String calculateTaxonName(FaunaEuropaeaTaxon fauEuTaxon,\r
- TaxonBase<?> taxonBase, MapWrapper<TaxonBase> taxonStore,\r
+ TaxonBase<?> taxonBase, TaxonNameBase<?,?>taxonName, MapWrapper<TaxonBase> taxonStore,\r
Map<Integer, FaunaEuropaeaTaxon> fauEuTaxonMap) {\r
\r
/* Local name string */\r
/* Concatenated parent's name string */\r
String parentString = "";\r
\r
- TaxonNameBase<?,?> taxonName = taxonBase.getName();\r
+// TaxonNameBase<?,?> taxonName = taxonBase.getName();\r
ZoologicalName zooName = (ZoologicalName)taxonName;\r
\r
if (zooName != null) {\r