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
.cdm
.model
.taxon
;
12 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
13 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
15 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.hibernate
.annotations
.Cascade
;
19 import org
.hibernate
.annotations
.CascadeType
;
20 import org
.hibernate
.annotations
.Index
;
21 import org
.hibernate
.annotations
.Table
;
23 import java
.lang
.reflect
.Method
;
25 import javax
.persistence
.*;
28 * Upmost abstract class for the use of a taxon name by a reference either
29 * as a taxon ("accepted/correct" name) or as a (junior) synonym.
30 * For instance: "Juncus longirostris Kuvaev sec. Kirschner, J. et al. 2002".
31 * Within a taxonomic view/treatment a taxon name can be used only once.
35 * @created 08-Nov-2007 13:06:56
38 @Table(appliesTo
="TaxonBase", indexes
= { @Index(name
= "taxonBaseTitleCacheIndex", columnNames
= { "titleCache" }) })
39 public abstract class TaxonBase
extends IdentifiableEntity
{
40 static Logger logger
= Logger
.getLogger(TaxonBase
.class);
42 private static Method methodTaxonNameAddTaxonBase
;
44 private static void initMethods() {
45 if (methodTaxonNameAddTaxonBase
== null){
47 methodTaxonNameAddTaxonBase
= TaxonNameBase
.class.getDeclaredMethod("addTaxonBase", TaxonBase
.class);
48 methodTaxonNameAddTaxonBase
.setAccessible(true);
49 } catch (Exception e
) {
51 //TODO handle exception
56 protected TaxonBase(){
60 protected TaxonBase(TaxonNameBase taxonNameBase
, ReferenceBase sec
){
62 if (taxonNameBase
!= null){
64 this.invokeSetMethod(methodTaxonNameAddTaxonBase
, taxonNameBase
);
69 //The assignment to the Taxon or to the Synonym class is not definitive
70 private boolean isDoubtful
;
71 private TaxonNameBase name
;
72 // The concept reference
73 private ReferenceBase sec
;
76 public String
generateTitle() {
78 if (name
!= null && name
.getTitleCache() != null){
79 title
= name
.getTitleCache() + " sec. ";
81 title
+= sec
.getTitleCache();
86 title
= this.toString();
92 @JoinColumn(name
="taxonName_fk")
93 @Cascade(CascadeType
.SAVE_UPDATE
)
94 public TaxonNameBase
getName(){
97 @Deprecated //for hibernate use only, use taxon.addDescription() instead
98 private void setName(TaxonNameBase newName
){
103 public HomotypicalGroup
getHomotypicGroup(){
104 if (this.getName() == null){
107 return this.getName().getHomotypicalGroup();
111 public boolean isDoubtful(){
112 return this.isDoubtful
;
114 public void setDoubtful(boolean isDoubtful
){
115 this.isDoubtful
= isDoubtful
;
119 @Cascade(CascadeType
.SAVE_UPDATE
)
120 public ReferenceBase
getSec() {
124 public void setSec(ReferenceBase sec
) {
129 public boolean isSaveable(){
130 if ( (this.getName() == null) || (this.getSec() == null) ){