2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.io
.tcsxml
.in
;
11 import java
.io
.InputStream
;
12 import java
.util
.ArrayList
;
13 import java
.util
.HashSet
;
14 import java
.util
.List
;
18 import org
.apache
.logging
.log4j
.LogManager
;
19 import org
.apache
.logging
.log4j
.Logger
;
20 import org
.jdom
.Element
;
21 import org
.jdom
.Namespace
;
22 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
23 import org
.springframework
.stereotype
.Component
;
25 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
26 import eu
.etaxonomy
.cdm
.common
.ResultWrapper
;
27 import eu
.etaxonomy
.cdm
.common
.XmlHelp
;
28 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
29 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
30 import eu
.etaxonomy
.cdm
.io
.common
.MapWrapper
;
31 import eu
.etaxonomy
.cdm
.io
.tcsrdf
.TcsRdfImportConfigurator
;
32 import eu
.etaxonomy
.cdm
.io
.tcsrdf
.TcsRdfTaxonNameImport
;
33 import eu
.etaxonomy
.cdm
.io
.tcsxml
.TcsXmlTransformer
;
34 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
35 import eu
.etaxonomy
.cdm
.model
.common
.IRelationshipType
;
36 import eu
.etaxonomy
.cdm
.model
.description
.CommonTaxonName
;
37 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
38 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
39 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameFactory
;
40 import eu
.etaxonomy
.cdm
.model
.reference
.OriginalSourceType
;
41 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
42 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
43 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
44 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
45 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
46 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
47 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
48 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
49 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
55 public class TcsXmlTaxonRelationsImport
extends TcsXmlImportBase
implements ICdmIO
<TcsXmlImportState
> {
56 private static final long serialVersionUID
= 6632990505515905663L;
58 private static final Logger logger
= LogManager
.getLogger();
60 private static int modCount
= 30000;
63 private TcsRdfTaxonNameImport rdfNameImport
;
64 private TcsRdfImportConfigurator rdfConfig
= TcsRdfImportConfigurator
.NewInstance(null, null);
66 public TcsXmlTaxonRelationsImport(){
71 public boolean doCheck(TcsXmlImportState state
){
72 boolean result
= true;
73 logger
.warn("Checking for TaxonRelations not yet implemented");
74 logger
.warn("Creation of homotypic relations is still problematic");
80 public void doInvoke(TcsXmlImportState state
){
83 logger
.info("start make taxon relations ...");
84 MapWrapper
<TaxonBase
> taxonMap
= (MapWrapper
<TaxonBase
>)state
.getStore(ICdmIO
.TAXON_STORE
);
85 MapWrapper
<TaxonName
> taxonNameMap
= (MapWrapper
<TaxonName
>)state
.getStore(ICdmIO
.TAXONNAME_STORE
);
86 MapWrapper
<Reference
> referenceMap
= (MapWrapper
<Reference
>)state
.getStore(ICdmIO
.REFERENCE_STORE
);
88 Set
<TaxonBase
> taxonStore
= new HashSet
<TaxonBase
>();
90 ResultWrapper
<Boolean
> success
= ResultWrapper
.NewInstance(true);
93 String idNamespace
= "TaxonRelationDTO";
95 TcsXmlImportConfigurator config
= state
.getConfig();
96 Element elDataSet
= super.getDataSetElement(config
);
97 Namespace tcsNamespace
= config
.getTcsXmlNamespace();
99 childName
= "TaxonConcepts";
101 Element elTaxonConcepts
= XmlHelp
.getSingleChildElement(success
, elDataSet
, childName
, tcsNamespace
, obligatory
);
103 childName
= "TaxonConcept";
104 List
<Element
> elTaxonConceptList
= elTaxonConcepts
== null ?
new ArrayList
<Element
>() : elTaxonConcepts
.getChildren(childName
, tcsNamespace
);
107 int taxonRelCount
= 0;
109 //for each taxonConcept
110 logger
.info("NUmber of taxon concepts: " + elTaxonConceptList
.size());
111 for (Element elTaxonConcept
: elTaxonConceptList
){
112 if ((i
++ % modCount
) == 0){ logger
.info("Taxa handled: " + (i
-1));}
113 taxonRelCount
+= makeTaxonConcept(state
, taxonMap
, taxonStore
, elTaxonConcept
, tcsNamespace
, success
);
115 logger
.info("Taxa handled: " + taxonStore
.size());
116 //TaxonRelationshipAssertions
117 taxonRelCount
+= makeTaxonRelationshipAssertion(state
, taxonMap
, referenceMap
, taxonStore
, elDataSet
, tcsNamespace
, success
);
119 logger
.info("Taxa to save: " + taxonStore
.size());
120 getTaxonService().save(taxonStore
);
122 //do basionym relationships
123 childName
= "TaxonNames";
125 Element elTaxonNames
= XmlHelp
.getSingleChildElement(success
, elDataSet
, childName
, tcsNamespace
, obligatory
);
127 childName
= "TaxonName";
128 List
<Element
> elTaxonNameList
= elTaxonNames
== null ?
new ArrayList
<Element
>() : elTaxonNames
.getChildren(childName
, tcsNamespace
);
130 logger
.info("NUmber of taxon concepts: " + elTaxonNameList
.size());
131 for (Element elTaxonName
: elTaxonNameList
){
132 if ((i
++ % modCount
) == 0){ logger
.info("Taxa handled: " + (i
-1));}
133 taxonRelCount
+= makeBasionymRelations(state
, taxonMap
, taxonNameMap
, taxonStore
, elTaxonName
, tcsNamespace
, success
);
135 logger
.info("Taxa handled: " + taxonStore
.size());
139 logger
.info("end make taxon relations ...");
140 if (!success
.getValue()){
141 state
.setUnsuccessfull();
146 private int makeBasionymRelations(TcsXmlImportState state
,
147 MapWrapper
<TaxonBase
> taxonMap
, MapWrapper
<TaxonName
> taxonNameMap
, Set
<TaxonBase
> taxonStore
,
148 Element elTaxonName
, Namespace tcsNamespace
,
149 ResultWrapper
<Boolean
> success
) {
153 <tcs:RelatedName ref="urn:lsid:ipni.org:names:50000063-1">Caryophyllaceae</tcs:RelatedName>
158 String childName
= "Basionym";
159 boolean obligatory
= false;
160 Element elBasionymRelationships
= XmlHelp
.getSingleChildElement(success
, elTaxonName
, childName
, tcsNamespace
, obligatory
);
161 if (elBasionymRelationships
!= null){
162 childName
= "RelatedName";
164 Element elBasionym
= XmlHelp
.getSingleChildElement(success
, elBasionymRelationships
, childName
, tcsNamespace
, obligatory
);
166 String id
= elTaxonName
.getAttributeValue("id");
167 TaxonName name
= taxonNameMap
.get(removeVersionOfRef(id
));
169 TaxonBase taxonBase
= name
.getTaxonBases().iterator().next();
171 String ref
= elBasionym
.getAttributeValue("ref");
172 TaxonName basionymName
= taxonNameMap
.get(removeVersionOfRef(ref
));
174 if (basionymName
!= null){
175 basionymName
= HibernateProxyHelper
.deproxy(basionymName
, TaxonName
.class);
177 if (basionymName
.getTaxonBases().isEmpty()){
178 basionym
= Synonym
.NewInstance(basionymName
, null);
180 basionym
= basionymName
.getTaxonBases().iterator().next();
182 //Synonym basionymSyn;
183 if (basionym
instanceof Taxon
){
185 if (!(taxonBase
instanceof Synonym
)){
186 logger
.debug("The taxon " + basionymName
.getTitleCache() + " is used in a concept and can not be a synonym " + name
.getTitleCache() + "but will be added as basionym for the homotypical group");
187 name
.addBasionym(basionymName
);
188 //basionymName.getHomotypicalGroup().addTypifiedName(name);
189 } else if (taxonBase
instanceof Synonym
){
190 Synonym synonym
= (Synonym
) taxonBase
;
191 ((Taxon
)basionym
).addSynonym(synonym
, SynonymType
.HOMOTYPIC_SYNONYM_OF
);
192 basionym
.getHomotypicGroup().setGroupBasionym(basionymName
);
193 taxonStore
.add(basionym
);
196 if (taxonBase
instanceof Taxon
){
197 Synonym synonym
= (Synonym
) basionym
;
198 ((Taxon
)taxonBase
).addSynonym(synonym
, SynonymType
.HOMOTYPIC_SYNONYM_OF
);
199 taxonBase
.getHomotypicGroup().setGroupBasionym(basionymName
);
200 taxonStore
.add(taxonBase
);
202 Taxon acc
= ((Synonym
)taxonBase
).getAcceptedTaxon();
204 acc
.addHomotypicSynonym((Synonym
)basionym
);
205 basionymName
.getHomotypicalGroup().setGroupBasionym(basionymName
);
212 basionymName
= TaxonNameFactory
.NewNonViralInstance(name
.getRank());
213 childName
= "RelatedName";
215 Element elName
= XmlHelp
.getSingleChildElement(success
, elBasionym
, childName
, tcsNamespace
, obligatory
);
216 String strName
= (elName
== null)?
"" : elName
.getTextNormalize();
217 basionymName
.setTitleCache(strName
, false);
218 Synonym basionymSyn
= Synonym
.NewInstance(basionymName
, unknownSec());
219 if (taxonBase
instanceof Taxon
){
220 Taxon taxon
= (Taxon
)taxonBase
;
221 taxon
.addSynonym(basionymSyn
, SynonymType
.HOMOTYPIC_SYNONYM_OF
);
222 taxon
.getHomotypicGroup().setGroupBasionym(basionymName
);
223 taxonStore
.add(taxon
);
225 Synonym syn
= (Synonym
) taxonBase
;
226 if (syn
.getAcceptedTaxon() != null){
227 Taxon accTaxon
= syn
.getAcceptedTaxon();
228 accTaxon
.addSynonym(basionymSyn
, SynonymType
.HOMOTYPIC_SYNONYM_OF
);
229 accTaxon
.getHomotypicGroup().setGroupBasionym(basionymName
);
230 taxonStore
.add(accTaxon
);
238 private int makeTaxonConcept(TcsXmlImportState state
, MapWrapper
<TaxonBase
> taxonMap
, Set
<TaxonBase
> taxonStore
, Element elTaxonConcept
, Namespace tcsNamespace
, ResultWrapper
<Boolean
> success
){
239 int taxonRelCount
= 0;
241 String childName
= "TaxonRelationships";
242 boolean obligatory
= false;
243 Element elTaxonRelationships
= XmlHelp
.getSingleChildElement(success
, elTaxonConcept
, childName
, tcsNamespace
, obligatory
);
245 if (elTaxonRelationships
!= null){
247 String tcsElementName
= "TaxonRelationship";
248 List
<Element
> elTaxonRelationshipList
= elTaxonRelationships
.getChildren(tcsElementName
, tcsNamespace
);
249 logger
.info("Number of taxonrelationships: " + elTaxonRelationshipList
.size());
250 for (Element elTaxonRelationship
: elTaxonRelationshipList
){
253 logger
.debug("TaxonRelationship "+ taxonRelCount
);
255 String strId
= elTaxonConcept
.getAttributeValue("id");
257 // String strConceptType = elTaxonConcept.getAttributeValue("type"); //original, revision, incomplete, aggregate, nominal
258 // String strPrimary = elTaxonConcept.getAttributeValue("primary"); //If primary='true' the concept is the first level response to a query. If 'false' the concept may be a secondary concept linked directly or indirectly to the definition of a primary concept.
259 // String strForm = elTaxonConcept.getAttributeValue("form"); //anamorph, teleomorph, hybrid
261 TaxonBase fromTaxon
= taxonMap
.get(removeVersionOfRef(strId
));
262 makeRelationshipType(state
, elTaxonRelationship
, taxonMap
, taxonStore
, fromTaxon
, success
);
264 if (fromTaxon
instanceof Taxon
){
265 makeHomotypicSynonymRelations((Taxon
)fromTaxon
);
269 return taxonRelCount
;
272 private int makeTaxonRelationshipAssertion(
273 TcsXmlImportState state
,
274 MapWrapper
<TaxonBase
> taxonMap
,
275 MapWrapper
<Reference
> referenceMap
,
276 Set
<TaxonBase
> taxonStore
,
278 Namespace tcsNamespace
,
279 ResultWrapper
<Boolean
> success
){
282 String childName
= "TaxonRelationshipAssertions";
283 boolean obligatory
= false;
284 Element elTaxonRelationshipAssertions
= XmlHelp
.getSingleChildElement(success
, elDataSet
, childName
, tcsNamespace
, obligatory
);
285 if(elTaxonRelationshipAssertions
== null){
289 childName
= "TaxonRelationshipAssertion";
290 List
<Element
> elTaxonRelationshipAssertionList
= elTaxonRelationshipAssertions
.getChildren(childName
, tcsNamespace
);
291 //for each taxon relationship assertion
292 for (Element elTaxonRelationshipAssertion
: elTaxonRelationshipAssertionList
){
293 if ((i
++ % modCount
) == 0){ logger
.info("TaxonRelationshipAssertions handled: " + (i
-1));}
294 String strId
= elTaxonRelationshipAssertion
.getAttributeValue("id");
297 childName
= "AccordingTo";
299 Element elAccordingTo
= XmlHelp
.getSingleChildElement(success
, elTaxonRelationshipAssertion
, childName
, tcsNamespace
, obligatory
);
300 Reference ref
= makeAccordingTo(elAccordingTo
, referenceMap
, success
);
302 childName
= "FromTaxonConcept";
304 Element elFromTaxonConcept
= XmlHelp
.getSingleChildElement(success
, elTaxonRelationshipAssertion
, childName
, tcsNamespace
, obligatory
);
306 Class
<?
extends TaxonBase
> clazz
= Taxon
.class;
308 TaxonBase fromTaxon
= makeReferenceType(elFromTaxonConcept
, clazz
, taxonMap
, success
);
310 makeRelationshipType(state
, elTaxonRelationshipAssertion
, taxonMap
, taxonStore
, fromTaxon
, success
);
311 }//elTaxonRelationshipAssertion
318 * Handles the TCS RelationshipType element.
320 * @param elRelationship
326 private void makeRelationshipType(
327 TcsXmlImportState state
328 , Element elRelationship
329 , MapWrapper
<TaxonBase
> taxonMap
330 , Set
<TaxonBase
> taxonStore
331 , TaxonBase fromTaxon
332 , ResultWrapper
<Boolean
> success
335 if (elRelationship
== null){
336 success
.setValue(false);
338 String strRelType
= elRelationship
.getAttributeValue("type");
342 ResultWrapper
<Boolean
> isInverse
= new ResultWrapper
<Boolean
>();
343 isInverse
.setValue(false);
344 if ("has vernacular".equalsIgnoreCase(strRelType
)){
345 handleVernacular(success
, state
, elRelationship
, fromTaxon
);
347 IRelationshipType relType
= TcsXmlTransformer
.tcsRelationshipType2Relationship(strRelType
, isInverse
);
349 //toTaxon (should be part of relationshipType)
350 boolean isSynonym
= (relType
instanceof SynonymType
);
351 TaxonBase toTaxon
= getToTaxon(elRelationship
, taxonMap
, state
.getMissingConceptLSIDs(), isSynonym
, success
, state
);
353 if (toTaxon
!= null && fromTaxon
!= null){
354 //exchange taxa if relationship is inverse
355 if (isInverse
.getValue() == true ){
356 TaxonBase tmp
= toTaxon
;
361 //Create relationship
362 if (! (toTaxon
instanceof Taxon
)){
363 logger
.warn("TaxonBase toTaxon is not of Type 'Taxon'. Relationship is not added.");
364 success
.setValue(false);
366 Taxon taxonTo
= (Taxon
)toTaxon
;
367 if (relType
instanceof SynonymType
){
368 SynonymType synRelType
= (SynonymType
)relType
;
369 if (! (fromTaxon
instanceof Synonym
)){
370 logger
.warn("TaxonBase fromTaxon is not of Type 'Synonym'. Relationship is not added.");
371 success
.setValue(false);
373 Synonym synonym
= (Synonym
)fromTaxon
;
374 TaxonName synName
= synonym
.getName();
375 TaxonName accName
= taxonTo
.getName();
376 if (synName
!= null && accName
!= null && synName
.isHomotypic(accName
)
377 && ( synRelType
.equals(SynonymType
.SYNONYM_OF
))){
378 synRelType
= SynonymType
.HOMOTYPIC_SYNONYM_OF
;
380 if (! relationExists(taxonTo
, synonym
, synRelType
)){
381 taxonTo
.addSynonym(synonym
, synRelType
);
383 //TODO citation, microReference
384 //TODO different synRelTypes -> warning
385 success
.setValue(false);
388 }else if (relType
instanceof TaxonRelationshipType
){
389 Reference citation
= null;
390 String microReference
= null;
391 makeTaxonRelationship(state
, (TaxonRelationshipType
)relType
, fromTaxon
, taxonTo
, citation
, microReference
, success
);
393 logger
.warn("Unknown Relationshiptype");
394 success
.setValue(false);
396 taxonStore
.add(toTaxon
);
399 if (toTaxon
== null){
400 // logger.warn("toTaxon (" + /*strToTaxon + */ ") could not be found in taxonMap. Relationship of type " + strRelType + " was not added to CDM");
402 if (fromTaxon
== null){
403 // logger.warn("fromTaxon (" + /*strTaxonAbout + */") could not be found in taxonMap. Relationship was not added to CDM");
405 success
.setValue(false);
408 } catch (UnknownCdmTypeException e
) {
410 logger
.warn("relationshipType " + strRelType
+ " not yet implemented");
411 success
.setValue(false);
416 private void handleVernacular(ResultWrapper
<Boolean
> success
, TcsXmlImportState state
, Element elRelationship
, TaxonBase taxonBase
) {
417 if (! taxonBase
.isInstanceOf(Taxon
.class)){
418 logger
.warn("From Taxon is not of type Taxon but of type " + taxonBase
.getClass().getSimpleName());
419 success
.setValue(false);
422 Taxon taxon
= CdmBase
.deproxy(taxonBase
, Taxon
.class);
423 Map
<String
, CommonTaxonName
> commonNameMap
= state
.getCommonNameMap();
424 CommonTaxonName commonTaxonName
= getCommonName(elRelationship
, commonNameMap
, success
);
425 TaxonDescription description
= getDescription(taxon
);
426 description
.addElement(commonTaxonName
);
430 private TaxonDescription
getDescription(Taxon taxon
) {
431 if (taxon
.getDescriptions().isEmpty()){
432 return TaxonDescription
.NewInstance(taxon
);
434 //TODO only if the description represents this TCS file
435 return taxon
.getDescriptions().iterator().next();
439 private CommonTaxonName
getCommonName(Element elTaxonRelationship
, Map
<String
, CommonTaxonName
> commonNameMap
, ResultWrapper
<Boolean
> success
){
440 CommonTaxonName result
= null;
441 if (elTaxonRelationship
== null || commonNameMap
== null){
442 success
.setValue(false);
444 String childName
= "ToTaxonConcept";
445 boolean obligatory
= true;
446 Element elToTaxonConcept
= XmlHelp
.getSingleChildElement(success
, elTaxonRelationship
, childName
, elTaxonRelationship
.getNamespace(), obligatory
);
448 String linkType
= elToTaxonConcept
.getAttributeValue("linkType");
449 if (linkType
== null || linkType
.equals("local")){
450 String ref
= elToTaxonConcept
.getAttributeValue("ref");
452 result
= commonNameMap
.get(ref
);
454 logger
.warn("Non ref not yet implemented for vernacular name relationship");
457 logger
.warn("External link types for vernacular name not yet implemented");
463 private void makeTaxonRelationship(TcsXmlImportState state
, TaxonRelationshipType relType
, TaxonBase fromTaxon
, Taxon taxonTo
, Reference citation
, String microReference
, ResultWrapper
<Boolean
> success
){
464 TaxonRelationshipType taxRelType
= relType
;
465 if (! (fromTaxon
instanceof Taxon
)){
466 logger
.warn("TaxonBase fromTaxon " + /*strTaxonAbout +*/ "is not of Type 'Taxon'. Relationship is not added.");
467 success
.setValue(false);
469 Taxon taxonFrom
= (Taxon
)fromTaxon
;
470 if (relType
.equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())){
471 makeTaxonomicallyIncluded(state
, taxonTo
, taxonFrom
, citation
, microReference
);
473 taxonFrom
.addTaxonRelation(taxonTo
, taxRelType
, citation
, microReference
);
478 private boolean makeTaxonomicallyIncluded(TcsXmlImportState state
, Taxon toTaxon
, Taxon fromTaxon
, Reference citation
, String microCitation
){
479 Reference sec
= toTaxon
.getSec();
480 Classification tree
= state
.getTree(sec
);
482 tree
= makeTree(state
, sec
);
484 TaxonNode childNode
= tree
.addParentChild(toTaxon
, fromTaxon
, citation
, microCitation
);
485 return (childNode
!= null);
489 @SuppressWarnings("rawtypes")
490 private TaxonBase
getToTaxon(Element elTaxonRelationship
, MapWrapper
<TaxonBase
> map
, List
<String
> missingNameID
,boolean isSynonym
, ResultWrapper
<Boolean
> success
, TcsXmlImportState state
){
491 TaxonBase result
= null;
492 if (elTaxonRelationship
== null || map
== null){
493 success
.setValue(false);
495 String childName
= "ToTaxonConcept";
496 boolean obligatory
= true;
497 Element elToTaxonConcept
= XmlHelp
.getSingleChildElement(success
, elTaxonRelationship
, childName
, elTaxonRelationship
.getNamespace(), obligatory
);
500 String linkType
= elToTaxonConcept
.getAttributeValue("linkType");
501 if (linkType
== null || linkType
.equals("local")){
502 String ref
= elToTaxonConcept
.getAttributeValue("ref");
504 result
= map
.get(ref
);
505 if (result
== null && state
.getConfig().isDoGetMissingNames()){
508 String
[] split
= ref
.split(":");
509 String id
= split
[split
.length
-1];
510 logger
.info("get name for id " + id
);
511 if (missingNameID
.contains(id
)){
514 InputStream nameStream
= service
.getNamesById(id
);
518 String nameUri
= "urn:lsid:ipni.org:names:"+ id
;
519 TaxonName name
= rdfNameImport
.handleRdfElementFromStream(nameStream
, rdfConfig
, (MapWrapper
<TaxonName
>)state
.getStore(ICdmIO
.TAXONNAME_STORE
), nameUri
);
521 if (name
.getTaxa().isEmpty()){
523 result
= Taxon
.NewInstance(name
, null);
525 result
= name
.getTaxa().iterator().next();
527 name
.addSource(OriginalSourceType
.Import
, ref
, "TaxonConcept", null, null);
528 result
.addSource(OriginalSourceType
.Import
, ref
, "TaxonConcept", null, null);
530 map
.put(removeVersionOfRef(ref
), result
);
532 missingNameID
.add(id
);
535 logger
.debug(e
.getMessage());
540 String title
= elToTaxonConcept
.getTextNormalize();
542 TaxonName taxonName
= TaxonNameFactory
.NewNonViralInstance(null);
543 taxonName
.setTitleCache(title
, true);
544 logger
.warn("Free text related taxon seems to be bug in TCS");
546 result
= Synonym
.NewInstance(taxonName
, TcsXmlTaxonImport
.unknownSec());
548 result
= Taxon
.NewInstance(taxonName
, TcsXmlTaxonImport
.unknownSec());
550 result
.setTitleCache(title
, true);
553 logger
.warn("External link types for synonym not yet implemented");
559 private boolean relationExists(Taxon taxonTo
, Synonym synonym
, SynonymType synRelType
){
560 if (synonym
== null || taxonTo
== null
561 || !taxonTo
.equals(synonym
.getAcceptedTaxon())){
564 return CdmUtils
.nullSafeEqual(synonym
.getType(),synRelType
);
568 private boolean makeHomotypicSynonymRelations(Taxon aboutTaxon
){
569 TaxonName aboutName
= aboutTaxon
.getName();
570 if (aboutName
!= null){
571 Set
<TaxonName
> typifiedNames
= aboutName
.getHomotypicalGroup().getTypifiedNames();
572 for (TaxonName typifiedName
: typifiedNames
){
573 //TODO check if name is part of this tcs file
574 if (typifiedName
.equals(aboutName
)){
577 Set
<Synonym
> syns
= typifiedName
.getSynonyms();
578 for(Synonym syn
:syns
){
579 aboutTaxon
.addSynonym(syn
, SynonymType
.HOMOTYPIC_SYNONYM_OF
);
587 protected boolean isIgnore(TcsXmlImportState state
){
588 return ! state
.getConfig().isDoRelTaxa();