Revision 48014773
Added by Andreas Müller almost 9 years ago
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/centralAfrica/ferns/CentralAfricaFernsTaxonRelationImport.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
68 | 68 |
@Component |
69 | 69 |
public class CentralAfricaFernsTaxonRelationImport extends CentralAfricaFernsImportBase<TaxonBase> implements IMappingImport<TaxonBase, CentralAfricaFernsImportState>{ |
70 | 70 |
private static final Logger logger = Logger.getLogger(CentralAfricaFernsTaxonRelationImport.class); |
71 |
|
|
71 |
|
|
72 | 72 |
private DbImportMapping<?,?> mapping; |
73 |
|
|
74 |
|
|
73 |
|
|
74 |
|
|
75 | 75 |
private static final String pluralString = "taxon relations"; |
76 | 76 |
private static final String dbTableName = "[African pteridophytes]"; |
77 | 77 |
private static final Class<?> cdmTargetClass = TaxonBase.class; |
78 | 78 |
|
79 |
private Map<String, UUID> nameCacheTaxonMap = new HashMap<String, UUID>(); |
|
80 |
private Map<String, UUID> titleCacheTaxonMap = new HashMap<String, UUID>(); |
|
79 |
private final Map<String, UUID> nameCacheTaxonMap = new HashMap<String, UUID>();
|
|
80 |
private final Map<String, UUID> titleCacheTaxonMap = new HashMap<String, UUID>();
|
|
81 | 81 |
|
82 | 82 |
private CentralAfricaFernsImportState state; |
83 | 83 |
|
84 |
|
|
84 |
|
|
85 | 85 |
public CentralAfricaFernsTaxonRelationImport(){ |
86 | 86 |
super(pluralString, dbTableName, cdmTargetClass); |
87 | 87 |
} |
88 | 88 |
|
89 |
|
|
89 |
|
|
90 | 90 |
@Override |
91 | 91 |
protected String getIdQuery() { |
92 | 92 |
String strQuery = " SELECT [Taxon number] FROM " + dbTableName;; |
... | ... | |
97 | 97 |
protected DbImportMapping<?,?> getMapping() { |
98 | 98 |
if (mapping == null){ |
99 | 99 |
mapping = new DbImportMapping(); |
100 |
|
|
100 |
|
|
101 | 101 |
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "createObject", ResultSet.class, CentralAfricaFernsImportState.class)); |
102 | 102 |
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "mapCommonName", ResultSet.class, CentralAfricaFernsImportState.class)); |
103 | 103 |
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "mapDistribution", ResultSet.class, CentralAfricaFernsImportState.class )); |
... | ... | |
119 | 119 |
String strRecordQuery = strSelect + strFrom + strWhere + strOrderBy ; |
120 | 120 |
return strRecordQuery; |
121 | 121 |
} |
122 |
|
|
122 |
|
|
123 | 123 |
|
124 | 124 |
/* (non-Javadoc) |
125 | 125 |
* @see eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportBase#doInvoke(eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportState) |
... | ... | |
140 | 140 |
*/ |
141 | 141 |
private void fillTaxonMap() { |
142 | 142 |
List<String> propPath = Arrays.asList(new String []{"name"}); |
143 |
|
|
144 |
List<Taxon> taxonList = (List)getTaxonService().list(Taxon.class, null, null, null, propPath );
|
|
143 |
|
|
144 |
List<Taxon> taxonList = getTaxonService().list(Taxon.class, null, null, null, propPath ); |
|
145 | 145 |
for (Taxon taxon : taxonList){ |
146 | 146 |
NonViralName<?> nvn = CdmBase.deproxy(taxon.getName(), NonViralName.class); |
147 | 147 |
UUID uuid = taxon.getUuid(); |
... | ... | |
159 | 159 |
Class<?> cdmClass; |
160 | 160 |
Set<String> idSet; |
161 | 161 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
162 |
|
|
162 |
|
|
163 | 163 |
try{ |
164 | 164 |
Set<String> taxonIdSet = new HashSet<String>(); |
165 | 165 |
// Set<String> referenceIdSet = new HashSet<String>(); |
... | ... | |
174 | 174 |
cdmClass = TaxonBase.class; |
175 | 175 |
Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, taxonIdSet, nameSpace); |
176 | 176 |
result.put(nameSpace, taxonMap); |
177 |
|
|
178 |
|
|
177 |
|
|
178 |
|
|
179 | 179 |
//reference map |
180 | 180 |
this.sourceReference = getFernsSourceReference(state); |
181 | 181 |
// nameSpace = "Reference"; |
... | ... | |
188 | 188 |
} |
189 | 189 |
return result; |
190 | 190 |
} |
191 |
|
|
191 |
|
|
192 | 192 |
|
193 | 193 |
/* (non-Javadoc) |
194 | 194 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase) |
... | ... | |
207 | 207 |
//accepted Taxon |
208 | 208 |
result = handleTaxon(rs, state); |
209 | 209 |
} |
210 |
|
|
210 |
|
|
211 | 211 |
return result; |
212 | 212 |
} catch (Exception e) { |
213 | 213 |
e.printStackTrace(); |
... | ... | |
216 | 216 |
|
217 | 217 |
} |
218 | 218 |
|
219 |
|
|
219 |
|
|
220 | 220 |
/** |
221 | 221 |
* Class to store all epithets of the database record. Maybe extended with business logic. |
222 | 222 |
*/ |
... | ... | |
240 | 240 |
private String subFormaName; |
241 | 241 |
} |
242 | 242 |
|
243 |
|
|
243 |
|
|
244 | 244 |
/** |
245 | 245 |
* Handles records with status synonym. A synonym relationship to the accepted taxon |
246 | 246 |
* is created. |
... | ... | |
252 | 252 |
private Synonym handleSynonym(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException { |
253 | 253 |
String accTaxonId = rs.getString("Current"); |
254 | 254 |
String nomRemarksString = rs.getString("Current/Synonym"); |
255 |
|
|
255 |
|
|
256 | 256 |
String synonymId = state.getTaxonNumber(); |
257 | 257 |
Synonym synonym = (Synonym)state.getRelatedObject(TAXON_NAMESPACE, synonymId); |
258 | 258 |
if (synonym == null){ |
... | ... | |
260 | 260 |
return null; |
261 | 261 |
} |
262 | 262 |
TaxonBase<?> taxonBase = CdmBase.deproxy(state.getRelatedObject(TAXON_NAMESPACE, accTaxonId), TaxonBase.class); |
263 |
|
|
263 |
|
|
264 | 264 |
if (taxonBase != null){ |
265 | 265 |
if (taxonBase.isInstanceOf(Taxon.class)){ |
266 | 266 |
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
... | ... | |
270 | 270 |
} |
271 | 271 |
}else{ |
272 | 272 |
logger.warn("Accepted taxon (" + accTaxonId + ") for synonym (" + synonymId +") is not of type 'Current'"); |
273 |
}
|
|
273 |
} |
|
274 | 274 |
}else{ |
275 | 275 |
logger.warn("Taxon (" + accTaxonId + ") not found for synonym (" + synonymId +")"); |
276 | 276 |
} |
277 |
|
|
277 |
|
|
278 | 278 |
return synonym; |
279 | 279 |
} |
280 | 280 |
|
281 |
|
|
281 |
|
|
282 | 282 |
/** |
283 |
* Handles all records with status 'current'. Creates parent-child relationships to the
|
|
283 |
* Handles all records with status 'current'. Creates parent-child relationships to the |
|
284 | 284 |
* higher taxa. Uses a complex algorithm to reuse existing higher taxa. |
285 | 285 |
* @param rs |
286 | 286 |
* @param state |
... | ... | |
312 | 312 |
epithets.subVariety = rs.getString("Subvariery"); |
313 | 313 |
epithets.formaName = rs.getString("Forma name"); |
314 | 314 |
epithets.subFormaName = rs.getString("Subforma"); |
315 |
|
|
315 |
|
|
316 | 316 |
makeNextHigherTaxon(state, rs, child, epithets); |
317 | 317 |
return child; |
318 | 318 |
} |
319 | 319 |
|
320 | 320 |
|
321 | 321 |
/** |
322 |
* Adds recursively this taxon to the next higher taxon. If the taxon exists already
|
|
322 |
* Adds recursively this taxon to the next higher taxon. If the taxon exists already |
|
323 | 323 |
* the relationship is not added again.<BR> |
324 |
* If the author is missing in the old taxon but not in the new taxon the
|
|
325 |
* old taxon will get the new taxons author.(NOT VALID ANY MORE)<BR>
|
|
324 |
* If the author is missing in the old taxon but not in the new taxon the |
|
325 |
* old taxon will get the new taxons author.(NOT VALID ANY MORE)<BR> |
|
326 | 326 |
* If authors differ a new taxon is created.<BR> |
327 | 327 |
* If a higher taxon exists the method is called recursively on this taxon. |
328 |
* @throws SQLException
|
|
328 |
* @throws SQLException |
|
329 | 329 |
*/ |
330 | 330 |
private void makeNextHigherTaxon(CentralAfricaFernsImportState state, ResultSet rs, Taxon child, Epithets epithets) throws SQLException { |
331 | 331 |
|
332 | 332 |
Taxon constructedHigherTaxon = constructNextHigherTaxon(state, rs, child, epithets); |
333 | 333 |
Reference<?> citation = null; |
334 | 334 |
String microcitation = null; |
335 |
|
|
335 |
|
|
336 | 336 |
if (constructedHigherTaxon != null){ |
337 | 337 |
handleHigherTaxonMustExist(state, rs, child, epithets, constructedHigherTaxon, citation, microcitation); |
338 | 338 |
}else{ |
... | ... | |
392 | 392 |
} |
393 | 393 |
makeNextHigherTaxon(state, rs, parentTaxon, epithets); |
394 | 394 |
} |
395 |
|
|
395 |
|
|
396 | 396 |
|
397 | 397 |
/** |
398 | 398 |
* Merges author information of the constructed taxon into the existing taxon. |
399 | 399 |
* Returns the existing taxon. |
400 |
* @param state
|
|
400 |
* @param state |
|
401 | 401 |
* @param parentTaxon |
402 | 402 |
* @param constructedHigherTaxon |
403 | 403 |
*/ |
... | ... | |
419 | 419 |
|
420 | 420 |
|
421 | 421 |
/** |
422 |
* Strategy for the decision if an existing parent or a constructed higher taxon should
|
|
422 |
* Strategy for the decision if an existing parent or a constructed higher taxon should |
|
423 | 423 |
* be taken as parent in case that the authors of the name differ somehow. |
424 |
* Current strategy: use existing parent if constructed higher taxon has no authors
|
|
424 |
* Current strategy: use existing parent if constructed higher taxon has no authors |
|
425 | 425 |
* at all. Use constructed taxon otherwise. |
426 | 426 |
* @param existingParentTaxon |
427 | 427 |
* @param constructedHigherTaxon |
... | ... | |
443 | 443 |
} |
444 | 444 |
|
445 | 445 |
/** |
446 |
* Strategy for the decision if an existing parent or a constructed higher taxon
|
|
446 |
* Strategy for the decision if an existing parent or a constructed higher taxon |
|
447 | 447 |
* should be taken as parent in case that the name caches differ somehow. |
448 | 448 |
* Current strategy: Not implemented. Always use constructed higher taxon. |
449 | 449 |
* @param existingParentTaxon |
... | ... | |
460 | 460 |
|
461 | 461 |
/** |
462 | 462 |
* Handles the case that the existing parent taxon and the constructed parent taxon |
463 |
* have a diffent rank. Returns the constructedHigherTaxon if no common grand parent exists.
|
|
463 |
* have a diffent rank. Returns the constructedHigherTaxon if no common grand parent exists. |
|
464 | 464 |
* @param parentTaxon |
465 | 465 |
* @param constructedHigherTaxon |
466 | 466 |
* @return |
... | ... | |
474 | 474 |
if (compare < 0){ |
475 | 475 |
lowerTaxon = constructedHigherTaxon; |
476 | 476 |
grandParentTaxon = parentTaxon; |
477 |
}
|
|
477 |
} |
|
478 | 478 |
Taxon commonGrandParent = checkIsGrandParent(lowerTaxon, grandParentTaxon); |
479 | 479 |
if (commonGrandParent != null){ |
480 | 480 |
if (lowerTaxon == constructedHigherTaxon){ |
481 |
//TODO merge
|
|
481 |
//TODO merge |
|
482 | 482 |
logger.warn("Merge in between taxon not yet implemented"); |
483 | 483 |
} |
484 | 484 |
}else{ |
... | ... | |
492 | 492 |
* taxon of the constructed taxon's child (condition will not be checked). |
493 | 493 |
* Returns null if no such taxon exists. |
494 | 494 |
* @param constructedHigherTaxon |
495 |
* @param state
|
|
495 |
* @param state |
|
496 | 496 |
* @return |
497 | 497 |
*/ |
498 | 498 |
private Taxon findExistingNonParentTaxon(CentralAfricaFernsImportState state, Taxon constructedHigherTaxon) { |
... | ... | |
531 | 531 |
|
532 | 532 |
//TODO was wenn lowerTaxon constructed ist |
533 | 533 |
logger.warn("checkIsGrandParent not yet fully implemented"); |
534 |
Taxon nextParent = getParent(childTaxon);
|
|
534 |
Taxon nextParent = getParent(childTaxon); |
|
535 | 535 |
if (namesMatch(nextParent, grandParentTaxon)){ |
536 | 536 |
//TODO which one to return? Merging ? |
537 | 537 |
logger.warn("checkIsGrandParent(matching) not yet fully implemented"); |
... | ... | |
555 | 555 |
private boolean nameCachesMatch(BotanicalName name1, BotanicalName name2) { |
556 | 556 |
return CdmUtils.nullSafeEqual(name1.getNameCache(), name2.getNameCache()); |
557 | 557 |
} |
558 |
|
|
558 |
|
|
559 | 559 |
/** |
560 | 560 |
* Checks if the name caches of the related names match. |
561 | 561 |
*@param taxon1 |
... | ... | |
584 | 584 |
String exCombinationAuthor2 = name2.computeExCombinationAuthorNomenclaturalTitle(); |
585 | 585 |
String exBasionymAuthor1 = name1.computeExBasionymAuthorNomenclaturalTitle(); |
586 | 586 |
String exBasionymAuthor2 = name2.computeExBasionymAuthorNomenclaturalTitle(); |
587 |
boolean result =
|
|
587 |
boolean result = |
|
588 | 588 |
CdmUtils.nullSafeEqual(combinationAuthor1, combinationAuthor2) && |
589 | 589 |
CdmUtils.nullSafeEqual(basionymAuthor1, basionymAuthor2) && |
590 | 590 |
CdmUtils.nullSafeEqual(exCombinationAuthor1, exCombinationAuthor2) && |
591 | 591 |
CdmUtils.nullSafeEqual(exBasionymAuthor1, exBasionymAuthor2); |
592 | 592 |
return result; |
593 | 593 |
} |
594 |
|
|
594 |
|
|
595 | 595 |
/** |
596 | 596 |
* Checks if all authors of the related names match. |
597 | 597 |
* @param taxon1 |
... | ... | |
613 | 613 |
private int compareRanks(BotanicalName name1, BotanicalName name2) { |
614 | 614 |
return name1.getRank().compareTo(name2.getRank()); |
615 | 615 |
} |
616 |
|
|
616 |
|
|
617 | 617 |
/** |
618 | 618 |
* Compares the ranks of the according names. |
619 | 619 |
* @param taxon1 |
... | ... | |
625 | 625 |
BotanicalName name2 = CdmBase.deproxy(taxon2.getName(), BotanicalName.class); |
626 | 626 |
return compareRanks(name1, name2); |
627 | 627 |
} |
628 |
|
|
629 |
|
|
628 |
|
|
629 |
|
|
630 | 630 |
|
631 | 631 |
/** |
632 | 632 |
* Checks if 2 names match. |
633 |
* Current strategy: true, if ranks are equal, nameCaches match and authors match
|
|
633 |
* Current strategy: true, if ranks are equal, nameCaches match and authors match |
|
634 | 634 |
* @param name1 |
635 | 635 |
* @param name2 |
636 | 636 |
* @return |
... | ... | |
638 | 638 |
private boolean namesMatch(BotanicalName name1, BotanicalName name2) { |
639 | 639 |
return compareRanks(name1, name2)==0 && nameCachesMatch(name1, name2) && authorsMatch(name1, name2); |
640 | 640 |
} |
641 |
|
|
641 |
|
|
642 | 642 |
/** |
643 | 643 |
* Checks if the according names match. |
644 | 644 |
* @see #namesMatch(BotanicalName, BotanicalName) |
... | ... | |
652 | 652 |
return namesMatch(name1, name2); |
653 | 653 |
} |
654 | 654 |
|
655 |
|
|
655 |
|
|
656 | 656 |
/** |
657 | 657 |
* Returns the only parent of the taxon. If not parent exists <code>null</code> is |
658 | 658 |
* returned. |
... | ... | |
677 | 677 |
} |
678 | 678 |
} |
679 | 679 |
} |
680 |
|
|
680 |
|
|
681 | 681 |
|
682 | 682 |
/** |
683 | 683 |
* Persists and saves the newly created taxon to the CDM store and to the look-up |
... | ... | |
693 | 693 |
nameCacheTaxonMap.put(nameCache, constructedHigherTaxon.getUuid()); |
694 | 694 |
titleCacheTaxonMap.put(titleCache, constructedHigherTaxon.getUuid()); |
695 | 695 |
state.addRelatedObject(HIGHER_TAXON_NAMESPACE, nameCache, constructedHigherTaxon); |
696 |
|
|
696 |
|
|
697 | 697 |
//persist |
698 | 698 |
// Reference citation = state.getConfig().getSourceReference(); //throws nonUniqueObject exception |
699 |
Reference<?> citation = null;
|
|
699 |
Reference<?> citation = null; |
|
700 | 700 |
String id = state.getTaxonNumber() + "-" + constructedName.getRank().getTitleCache(); |
701 | 701 |
addOriginalSource(constructedName, id, NAME_NAMESPACE, citation); |
702 | 702 |
addOriginalSource(constructedHigherTaxon, id, TAXON_NAMESPACE, citation); |
703 | 703 |
getTaxonService().save(constructedHigherTaxon); |
704 |
|
|
704 |
|
|
705 | 705 |
return constructedHigherTaxon; |
706 | 706 |
} |
707 | 707 |
|
... | ... | |
742 | 742 |
} |
743 | 743 |
state.addRelatedObject(DbImportTaxIncludedInMapper.TAXONOMIC_TREE_NAMESPACE, treeKey, tree); |
744 | 744 |
} |
745 |
|
|
745 |
|
|
746 | 746 |
TaxonNode childNode; |
747 | 747 |
if (parent != null){ |
748 | 748 |
childNode = tree.addParentChild(parent, child, citation, microCitation); |
... | ... | |
760 | 760 |
* @throws SQLException |
761 | 761 |
*/ |
762 | 762 |
private Taxon constructNextHigherTaxon(CentralAfricaFernsImportState state, ResultSet rs, Taxon childTaxon, Epithets epithets) throws SQLException { |
763 |
|
|
763 |
|
|
764 | 764 |
Taxon result = null; |
765 | 765 |
BotanicalName childName = CdmBase.deproxy(childTaxon.getName(), BotanicalName.class); |
766 | 766 |
Rank childRank = childName.getRank(); |
... | ... | |
775 | 775 |
if (higherName.getRank() == null){ |
776 | 776 |
handleUninomial(childRank, higherName, epithets); |
777 | 777 |
} |
778 |
|
|
778 |
|
|
779 | 779 |
if (higherName.getRank() != null){ |
780 | 780 |
result = Taxon.NewInstance(higherName, childTaxon.getSec()); |
781 | 781 |
//TODO correct?? |
... | ... | |
792 | 792 |
|
793 | 793 |
BotanicalName taxonName = BotanicalName.NewInstance(null); |
794 | 794 |
Rank newRank = null; |
795 |
|
|
795 |
|
|
796 | 796 |
if (StringUtils.isNotBlank(epithets.subFormaName) && lowerTaxonRank.isLower(Rank.SUBFORM())){ |
797 | 797 |
taxonName.setInfraSpecificEpithet(epithets.subFormaName); |
798 | 798 |
newRank = Rank.SUBFORM(); |
... | ... | |
809 | 809 |
taxonName.setInfraSpecificEpithet(epithets.subspeciesName); |
810 | 810 |
newRank = Rank.SUBSPECIES(); |
811 | 811 |
} |
812 |
|
|
812 |
|
|
813 | 813 |
if (newRank != null){ |
814 | 814 |
taxonName.setSpecificEpithet(epithets.specificEpithet); |
815 | 815 |
taxonName.setGenusOrUninomial(epithets.genusName); |
816 | 816 |
taxonName.setRank(newRank); |
817 | 817 |
} |
818 |
|
|
818 |
|
|
819 | 819 |
return taxonName; |
820 | 820 |
} |
821 | 821 |
|
822 | 822 |
private BotanicalName handleSpecies(Rank lowerTaxonRank, BotanicalName taxonName, Epithets epithets) { |
823 | 823 |
Rank newRank = null; |
824 |
|
|
824 |
|
|
825 | 825 |
if (StringUtils.isNotBlank(epithets.specificEpithet) && lowerTaxonRank.isLower(Rank.SPECIES())){ |
826 | 826 |
taxonName.setSpecificEpithet(epithets.specificEpithet); |
827 | 827 |
newRank = Rank.SPECIES(); |
... | ... | |
835 | 835 |
|
836 | 836 |
private BotanicalName handleInfraGeneric(Rank lowerTaxonRank, BotanicalName taxonName, Epithets epithets) { |
837 | 837 |
Rank newRank = null; |
838 |
|
|
838 |
|
|
839 | 839 |
if (StringUtils.isNotBlank(epithets.seriesName) && lowerTaxonRank.isLower(Rank.SERIES())){ |
840 | 840 |
taxonName.setInfraGenericEpithet(epithets.seriesName); |
841 | 841 |
newRank = Rank.SERIES(); |
... | ... | |
859 | 859 |
|
860 | 860 |
|
861 | 861 |
private BotanicalName handleUninomial(Rank lowerTaxonRank, BotanicalName taxonName, Epithets epithets) { |
862 |
|
|
862 |
|
|
863 | 863 |
Rank newRank = null; |
864 | 864 |
if (StringUtils.isNotBlank(epithets.genusName) && lowerTaxonRank.isLower(Rank.GENUS())){ |
865 | 865 |
taxonName.setGenusOrUninomial(epithets.genusName); |
... | ... | |
886 | 886 |
taxonName.setRank(newRank); |
887 | 887 |
return taxonName; |
888 | 888 |
} |
889 |
|
|
889 |
|
|
890 | 890 |
|
891 | 891 |
/** |
892 | 892 |
* for internal use only, used by MethodMapper |
... | ... | |
902 | 902 |
String[] split = commonNames.split(","); |
903 | 903 |
for (String commonNameString: split){ |
904 | 904 |
CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameString.trim(), Language.ENGLISH()); |
905 |
description.addElement(commonName);
|
|
905 |
description.addElement(commonName); |
|
906 | 906 |
} |
907 | 907 |
}else{ |
908 | 908 |
logger.warn(taxonNumber + " - Accepted taxon for synonym can't be defined for common name. Synonym " + taxonBase.getName().getTitleCache()); |
... | ... | |
910 | 910 |
} |
911 | 911 |
return taxonBase; |
912 | 912 |
} |
913 |
|
|
913 |
|
|
914 | 914 |
|
915 | 915 |
/** |
916 | 916 |
* for internal use only, used by MethodMapper |
... | ... | |
927 | 927 |
TaxonNameBase<?,?> nameUsedInSource = taxonBase.getName(); |
928 | 928 |
Taxon taxon = getAcceptedTaxon(taxonBase); |
929 | 929 |
if (taxon != null){ |
930 |
|
|
930 |
|
|
931 | 931 |
if (StringUtils.isNotBlank(countriesString) ){ |
932 | 932 |
makeCountries(state, taxonNumber, taxon, nameUsedInSource, countriesString, province, distributionDetailed); |
933 | 933 |
} |
... | ... | |
945 | 945 |
return null; |
946 | 946 |
} |
947 | 947 |
} |
948 |
|
|
949 |
|
|
948 |
|
|
949 |
|
|
950 | 950 |
/** |
951 | 951 |
* for internal use only, used by MethodMapper |
952 |
* @param commonNames
|
|
952 |
* @param commonNames |
|
953 | 953 |
*/ |
954 | 954 |
private TaxonBase mapEcology(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException{ |
955 | 955 |
String taxonNumber = state.getTaxonNumber(); |
... | ... | |
957 | 957 |
TaxonBase<?> taxonBase = state.getRelatedObject(state.CURRENT_OBJECT_NAMESPACE, state.CURRENT_OBJECT_ID, TaxonBase.class); |
958 | 958 |
if (StringUtils.isNotBlank(ecologyString)){ |
959 | 959 |
Taxon taxon = getAcceptedTaxon(taxonBase); |
960 |
|
|
960 |
|
|
961 | 961 |
if (taxon != null){ |
962 | 962 |
TaxonDescription description = getTaxonDescription(taxon, false, true); |
963 | 963 |
TextData ecology = TextData.NewInstance(Feature.ECOLOGY()); |
964 | 964 |
ecology.putText(Language.ENGLISH(), ecologyString.trim()); |
965 |
description.addElement(ecology);
|
|
965 |
description.addElement(ecology); |
|
966 | 966 |
}else{ |
967 | 967 |
logger.warn(taxonNumber + " - Accepted taxon for synonym can't be defined for ecology. Synonym " + taxonBase.getName().getTitleCache()); |
968 | 968 |
} |
... | ... | |
982 | 982 |
} |
983 | 983 |
} |
984 | 984 |
|
985 |
|
|
985 |
|
|
986 | 986 |
private void makeProvince(Taxon taxon, String province) { |
987 | 987 |
if (StringUtils.isNotBlank(province)){ |
988 | 988 |
TaxonDescription description = getTaxonDescription(taxon, false, true); |
... | ... | |
991 | 991 |
distribution.putText(Language.ENGLISH(), province); |
992 | 992 |
} |
993 | 993 |
} |
994 |
|
|
994 |
|
|
995 | 995 |
|
996 | 996 |
/** |
997 | 997 |
* @param state |
... | ... | |
1000 | 1000 |
* @param countriesString |
1001 | 1001 |
*/ |
1002 | 1002 |
private void makeCountries(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonNameBase nameUsedInSource, String countriesString, String province, String distributionDetailed) { |
1003 |
countriesString = countriesString.replaceAll("\\*", "");
|
|
1003 |
countriesString = countriesString.replaceAll("\\*", ""); |
|
1004 | 1004 |
countriesString = countriesString.replace(" ", " "); |
1005 | 1005 |
countriesString = countriesString.replace(", endemic", " - endemic"); |
1006 | 1006 |
countriesString = countriesString.replace("(endemic)", " - endemic"); |
... | ... | |
1008 | 1008 |
countriesString = countriesString.replace("(naturalised)", " - naturalised"); |
1009 | 1009 |
countriesString = countriesString.replace("Madagascar-", "Madagascar -"); |
1010 | 1010 |
countriesString = countriesString.replace("Mah\u00e9", "Mahe"); |
1011 |
|
|
1011 |
|
|
1012 | 1012 |
String[] split = countriesString.split("[,;]"); |
1013 | 1013 |
String remainingString = null; |
1014 | 1014 |
for (String countryString : split){ |
... | ... | |
1045 | 1045 |
} |
1046 | 1046 |
//status |
1047 | 1047 |
country = makeCountryStatus(state, country, distribution); |
1048 |
|
|
1048 |
|
|
1049 | 1049 |
//brackets |
1050 | 1050 |
country = makeCountryBrackets(state, taxonNumber, taxon, nameUsedInSource, country); |
1051 | 1051 |
String countryWithoutIslands = null; |
... | ... | |
1062 | 1062 |
if (country.endsWith("Islands")){ |
1063 | 1063 |
country = country.replace("Islands", "Is."); |
1064 | 1064 |
} |
1065 |
|
|
1066 |
|
|
1065 |
|
|
1066 |
|
|
1067 | 1067 |
//areas |
1068 | 1068 |
if (TdwgAreaProvider.isTdwgAreaLabel(country)){ |
1069 | 1069 |
//tdwg |
... | ... | |
1083 | 1083 |
//others |
1084 | 1084 |
NamedAreaLevel level = null; |
1085 | 1085 |
NamedAreaType areaType = null; |
1086 |
|
|
1086 |
|
|
1087 | 1087 |
UUID uuid = state.getTransformer().getNamedAreaUuid(country); |
1088 | 1088 |
if (uuid == null){ |
1089 | 1089 |
logger.error(taxonNumber + " - Unknown country: " + country); |
1090 | 1090 |
} |
1091 | 1091 |
area = getNamedArea(state, uuid, country, country, country, areaType, level); |
1092 | 1092 |
} |
1093 |
|
|
1093 |
|
|
1094 | 1094 |
distribution.setArea(area); |
1095 | 1095 |
if (areaDoubtful == true){ |
1096 | 1096 |
if (distribution.getStatus().equals(PresenceAbsenceTerm.PRESENT())){ |
... | ... | |
1134 | 1134 |
private String makeCountryStatus(CentralAfricaFernsImportState state, String country, Distribution distribution) throws UndefinedTransformerMethodException { |
1135 | 1135 |
PresenceAbsenceTerm status = null; |
1136 | 1136 |
String[] split = country.split(" - "); |
1137 |
|
|
1137 |
|
|
1138 | 1138 |
if (split.length == 2){ |
1139 | 1139 |
country = split[0].trim(); |
1140 | 1140 |
String statusString = split[1]; |
... | ... | |
1157 | 1157 |
} |
1158 | 1158 |
|
1159 | 1159 |
|
1160 |
|
|
1160 |
|
|
1161 | 1161 |
|
1162 | 1162 |
/* (non-Javadoc) |
1163 | 1163 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
... | ... | |
1176 | 1176 |
return ! state.getConfig().isDoRelTaxa(); |
1177 | 1177 |
} |
1178 | 1178 |
|
1179 |
|
|
1180 |
|
|
1179 |
|
|
1180 |
|
|
1181 | 1181 |
//************************ OLD ********************************************************** |
1182 | 1182 |
|
1183 | 1183 |
/** |
1184 |
* Adds the higherTaxon authors to the existingHigherTaxon authors if the higherTaxon has authors and
|
|
1184 |
* Adds the higherTaxon authors to the existingHigherTaxon authors if the higherTaxon has authors and |
|
1185 | 1185 |
* the existingHigherTaxon has no authors. |
1186 | 1186 |
* Returns false if both taxa have authors and the authors differ from each other. |
1187 | 1187 |
* @param higherTaxon |
... | ... | |
1197 | 1197 |
return true; |
1198 | 1198 |
} |
1199 | 1199 |
if (! existingName.hasAuthors()){ |
1200 |
existingName.setCombinationAuthorTeam(newName.getCombinationAuthorTeam());
|
|
1201 |
existingName.setExCombinationAuthorTeam(newName.getExCombinationAuthorTeam());
|
|
1202 |
existingName.setBasionymAuthorTeam(newName.getBasionymAuthorTeam());
|
|
1203 |
existingName.setExBasionymAuthorTeam(newName.getExBasionymAuthorTeam());
|
|
1200 |
existingName.setCombinationAuthorship(newName.getCombinationAuthorship());
|
|
1201 |
existingName.setExCombinationAuthorship(newName.getExCombinationAuthorship());
|
|
1202 |
existingName.setBasionymAuthorship(newName.getBasionymAuthorship());
|
|
1203 |
existingName.setExBasionymAuthorship(newName.getExBasionymAuthorship());
|
|
1204 | 1204 |
return true; |
1205 | 1205 |
} |
1206 | 1206 |
boolean authorsAreSame = true; |
1207 |
authorsAreSame &= getNomTitleNz(existingName.getCombinationAuthorTeam()).equals(getNomTitleNz(newName.getCombinationAuthorTeam()));
|
|
1208 |
authorsAreSame &= getNomTitleNz(existingName.getExCombinationAuthorTeam()).equals(getNomTitleNz(newName.getExCombinationAuthorTeam()));
|
|
1209 |
authorsAreSame &= getNomTitleNz(existingName.getBasionymAuthorTeam()).equals(getNomTitleNz(newName.getBasionymAuthorTeam()));
|
|
1210 |
authorsAreSame &= getNomTitleNz(existingName.getExBasionymAuthorTeam()).equals(getNomTitleNz(newName.getExBasionymAuthorTeam()));
|
|
1207 |
authorsAreSame &= getNomTitleNz(existingName.getCombinationAuthorship()).equals(getNomTitleNz(newName.getCombinationAuthorship()));
|
|
1208 |
authorsAreSame &= getNomTitleNz(existingName.getExCombinationAuthorship()).equals(getNomTitleNz(newName.getExCombinationAuthorship()));
|
|
1209 |
authorsAreSame &= getNomTitleNz(existingName.getBasionymAuthorship()).equals(getNomTitleNz(newName.getBasionymAuthorship()));
|
|
1210 |
authorsAreSame &= getNomTitleNz(existingName.getExBasionymAuthorship()).equals(getNomTitleNz(newName.getExBasionymAuthorship()));
|
|
1211 | 1211 |
return authorsAreSame; |
1212 |
|
|
1213 |
|
|
1212 |
|
|
1213 |
|
|
1214 | 1214 |
} |
1215 | 1215 |
|
1216 | 1216 |
/** |
Also available in: Unified diff
Rename NonViralName authorteams to authorship #4968