Project

General

Profile

Download (7.22 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.model.reference;
11

    
12

    
13
import javax.persistence.Entity;
14
import javax.persistence.ManyToOne;
15
import javax.persistence.Transient;
16
import javax.xml.bind.annotation.XmlAccessType;
17
import javax.xml.bind.annotation.XmlAccessorType;
18
import javax.xml.bind.annotation.XmlAttribute;
19
import javax.xml.bind.annotation.XmlElement;
20
import javax.xml.bind.annotation.XmlIDREF;
21
import javax.xml.bind.annotation.XmlRootElement;
22
import javax.xml.bind.annotation.XmlSchemaType;
23
import javax.xml.bind.annotation.XmlTransient;
24
import javax.xml.bind.annotation.XmlType;
25

    
26
import org.apache.log4j.Logger;
27
import org.hibernate.annotations.Cascade;
28
import org.hibernate.annotations.CascadeType;
29
import org.hibernate.annotations.Index;
30
import org.hibernate.annotations.Table;
31

    
32
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
33
import eu.etaxonomy.cdm.model.common.IParsable;
34
import eu.etaxonomy.cdm.model.media.IdentifyableMediaEntity;
35
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
36
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
37
import eu.etaxonomy.cdm.model.taxon.Synonym;
38
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy;
39

    
40
/**
41
 * The upmost (abstract) class for references (information sources). Its two
42
 * direct subclasses {@link StrictReferenceBase StrictReferenceBase} and {@link BibtexReference BibtexReference}
43
 * allow either on the one side to handle different kind of references with their
44
 * peculiarities or on the other side to follow the flat BibTeX format
45
 * (see "http://en.wikipedia.org/wiki/BibTeX").
46
 * <P>
47
 * This class corresponds to: <ul>
48
 * <li> PublicationCitation according to the TDWG ontology
49
 * <li> Publication according to the TCS
50
 * <li> Reference according to the ABCD schema
51
 * </ul>
52
 * 
53
 * @author m.doering
54
 * @version 1.0
55
 * @created 08-Nov-2007 13:06:47
56
 */
57
@XmlAccessorType(XmlAccessType.FIELD)
58
@XmlType(name = "ReferenceBase", propOrder = {
59
	"uri",
60
	"isNomenclaturallyRelevant",
61
    "authorTeam"
62
})
63
@XmlRootElement(name = "RelationshipBase")
64
@Entity
65
@Table(appliesTo="ReferenceBase", indexes = { @Index(name = "ReferenceBaseTitleCacheIndex", columnNames = { "persistentTitleCache" }) })
66
public abstract class ReferenceBase extends IdentifyableMediaEntity implements IParsable{
67
	
68
	static Logger logger = Logger.getLogger(ReferenceBase.class);
69
	
70
	//URIs like DOIs, LSIDs or Handles for this reference
71
	@XmlElement(name = "URI")
72
	private String uri;
73
	
74
	//flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a
75
	//nomenclatural reference in a name this flag should be automatically set
76
	@XmlElement(name = "IsNomenclaturallyRelevant")
77
	private boolean isNomenclaturallyRelevant;
78
	
79
	@XmlElement(name = "AuthorTeam")
80
	@XmlIDREF
81
	@XmlSchemaType(name = "IDREF")
82
	private TeamOrPersonBase authorTeam;
83

    
84
	//this flag will be set to true if the parseName method was unable to successfully parse the name
85
	@XmlAttribute
86
	private boolean hasProblem = false;
87
	
88
	@XmlTransient
89
	protected IReferenceBaseCacheStrategy<ReferenceBase> cacheStrategy;
90
	
91
	/**
92
	 * Returns the {@link agent.TeamOrPersonBase author (team)} who created the
93
	 * content of <i>this</i> reference.
94
	 * 
95
	 * @return  the author (team) of <i>this</i> reference
96
	 * @see 	agent.TeamOrPersonBase
97
	 */
98
	@ManyToOne
99
	@Cascade({CascadeType.SAVE_UPDATE})
100
	public TeamOrPersonBase getAuthorTeam(){
101
		return this.authorTeam;
102
	}
103

    
104
	/**
105
	 * @see #getAuthorTeam()
106
	 */
107
	public void setAuthorTeam(TeamOrPersonBase authorTeam){
108
		this.authorTeam = authorTeam;
109
	}
110

    
111
	/**
112
	 * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
113
	 * reference. An URI is a string of characters used to identify a resource
114
	 * on the Internet.
115
	 * 
116
	 * @return  the URI of <i>this</i> reference
117
	 */
118
	public String getUri(){
119
		return this.uri;
120
	}
121
	/**
122
	 * @see #getUri()
123
	 */
124
	public void setUri(String uri){
125
		this.uri = uri;
126
	}
127

    
128
	/**
129
	 * Returns "true" if the isNomenclaturallyRelevant flag is set. This 
130
	 * indicates that a {@link TaxonNameBase taxon name} has been originally
131
	 * published in <i>this</i> reference following the rules of a
132
	 * {@link name.NomenclaturalCode nomenclature code} and is therefore used for
133
	 * nomenclatural citations. This flag will be set as soon as <i>this</i>
134
	 * reference is used as a nomenclatural reference for any taxon name.
135
	 */
136
	public boolean isNomenclaturallyRelevant(){
137
		return this.isNomenclaturallyRelevant;
138
	}
139

    
140
	/**
141
	 * @see #isNomenclaturallyRelevant()
142
	 */
143
	public void setNomenclaturallyRelevant(boolean isNomenclaturallyRelevant){
144
		this.isNomenclaturallyRelevant = isNomenclaturallyRelevant;
145
	}
146

    
147
	/**
148
	 * Returns a formatted string containing the entire reference citation,
149
	 * including authors, corresponding to <i>this</i> reference.
150
	 * 
151
	 * @see  #generateTitle()
152
	 */
153
	@Transient
154
	// TODO implement 
155
	public String getCitation(){
156
		return "";
157
	}
158
	
159
	/**
160
	 * Returns a string containing the date (mostly only the year) of
161
	 * publication / creation of <i>this</i> reference.
162
	 */
163
	@Transient
164
	public abstract String getYear();
165

    
166
	/**
167
	 * Returns the boolean value of the flag indicating whether the used {@link eu.etaxonomy.cdm.strategy.parser.INonViralNameParser parser} 
168
	 * method was able to parse the string designating <i>this</i> reference
169
	 * successfully (false) or not (true).
170
	 *  
171
	 * @return  the boolean value of the hasProblem flag
172
	 * @see     #getCitation()
173
	 */
174
	public boolean getHasProblem(){
175
		return this.hasProblem;
176
	}
177
	/**
178
	 * @see  #getHasProblem()
179
	 */
180
	public void setHasProblem(boolean hasProblem){
181
		this.hasProblem = hasProblem;
182
	}
183
	
184
	/**
185
	 * Generates, according to the {@link strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
186
	 * assigned to <i>this</i> reference, a string that identifies <i>this</i>
187
	 * reference and returns it. This string may be stored in the inherited
188
	 * {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
189
	 * This method overrides the generic and inherited
190
	 * IdentifiableEntity#generateTitle() method.
191
	 *
192
	 * @return  the string identifying <i>this</i> reference
193
	 * @see  	#getCitation()
194
	 * @see  	common.IdentifiableEntity#getTitleCache()
195
	 * @see  	common.IdentifiableEntity#generateTitle()
196
	 * @see  	strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
197
	 */
198
	@Override
199
	public String generateTitle(){
200
		if (cacheStrategy == null){
201
			logger.warn("No CacheStrategy defined for ReferenceBase: " + this.getUuid());
202
			return null;
203
		}else{
204
			return cacheStrategy.getTitleCache(this);
205
		}
206
	}
207
	
208
//**************************** CLONE *********************************/
209

    
210

    
211
	/** 
212
	 * Clones <i>this</i> reference. This is a shortcut that enables to create
213
	 * a new instance that differs only slightly from <i>this</i> reference by
214
	 * modifying only some of the attributes.
215
	 * 
216
	 * @see media.IdentifyableMediaEntity#clone()
217
	 * @see java.lang.Object#clone()
218
	 */
219
	public Object clone() throws CloneNotSupportedException{
220
		ReferenceBase result = (ReferenceBase)super.clone();
221
		//no changes to: authorTeam, hasProblem, nomenclaturallyRelevant, uri
222
		return result;
223
	}
224
	
225
}
(20-20/26)