2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import org
.apache
.log4j
.Logger
;
14 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
15 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
16 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
19 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 import eu
.etaxonomy
.cdm
.strategy
.parser
.INonViralNameParser
;
26 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImpl
;
27 import eu
.etaxonomy
.taxeditor
.TaxEditorPlugin
;
34 public class CdmUtil
{
35 private static final Logger logger
= Logger
.getLogger(CdmUtil
.class);
37 static INonViralNameParser nonViralNameParser
;
40 * Checks whether synonym's name is the basionym of the taxon's name.
46 public static boolean isSynonymBasionym(Taxon taxon
, Synonym synonym
) {
47 TaxonNameBase synonymName
= synonym
.getName();
48 TaxonNameBase taxonName
= taxon
.getName();
49 if (taxonName
== null || synonymName
== null) {
52 TaxonNameBase basionymName
= taxonName
.getBasionym();
53 if (synonymName
.equals(basionymName
)) {
60 * Checks whether name belongs to the same homotypic group as taxon's name.
66 public static boolean isNameHomotypic(TaxonNameBase name
, Taxon taxon
) {
67 TaxonNameBase taxonName
= taxon
.getName();
68 if (taxonName
== null || name
== null) {
71 HomotypicalGroup homotypicGroup
= taxonName
.getHomotypicalGroup();
72 if (homotypicGroup
== null) {
75 if (homotypicGroup
.equals(name
.getHomotypicalGroup())) {
82 * Returns whatever is currently considered the display name for Taxon
83 * objects. Currently titleCache.
88 public static String
getDisplayName(Taxon taxon
) {
89 TaxonNameBase name
= taxon
.getName();
93 return name
.getTitleCache();
96 private static INonViralNameParser
getNonViralNameParser() {
97 if (nonViralNameParser
== null) {
98 nonViralNameParser
= NonViralNameParserImpl
.NewInstance();
100 return nonViralNameParser
;
103 public static TaxonNameBase
parseFullReference(String fullReference
,
104 NomenclaturalCode nomCode
, Rank rank
) {
105 return getNonViralNameParser().parseFullReference(fullReference
,
109 public static void parseFullName(NonViralName nameToBeFilled
,
110 String fullNameString
, Rank rank
, boolean makeEmpty
) {
112 getNonViralNameParser().parseFullName(nameToBeFilled
, fullNameString
,
116 public static ReferenceBase
getSessionDefaultSec() {
120 public static void makeTaxonSynonym(Taxon oldTaxon
,
121 Taxon newAcceptedTaxon
, SynonymRelationshipType synonymType
,
122 ReferenceBase citation
, String citationMicroReference
) {
123 ITaxonService taxonService
= TaxEditorPlugin
.getDefault()
125 taxonService
.makeTaxonSynonym(oldTaxon
, newAcceptedTaxon
, synonymType
,
126 citation
, citationMicroReference
);