Project

General

Profile

Download (4.93 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.FetchType;
15
import javax.persistence.ManyToOne;
16
import javax.persistence.Transient;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
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.XmlType;
24

    
25
import org.apache.log4j.Logger;
26
import org.hibernate.annotations.Cascade;
27
import org.hibernate.annotations.CascadeType;
28
import org.hibernate.envers.Audited;
29
import org.hibernate.search.annotations.Indexed;
30
import org.hibernate.search.annotations.IndexedEmbedded;
31
import org.springframework.beans.factory.annotation.Configurable;
32

    
33
import sun.management.resources.agent;
34
import eu.etaxonomy.cdm.model.agent.Institution;
35
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
36
import eu.etaxonomy.cdm.strategy.cache.reference.ThesisDefaultCacheStrategy;
37

    
38
/**
39
 * This class represents thesis. A thesis is a document that presents the
40
 * author's research and findings and is submitted at a
41
 * {@link eu.etaxonomy.cdm.model.agent.Institution high school institution} in support of candidature for
42
 * a degree or professional qualification.
43
 * <P>
44
 * This class corresponds, according to the TDWG ontology, to the publication type
45
 * term (from PublicationTypeTerm): "Thesis".
46
 * 
47
 * @author m.doering
48
 * @version 1.0
49
 * @created 08-Nov-2007 13:06:59
50
 */
51
@XmlAccessorType(XmlAccessType.FIELD)
52
@XmlType(name = "Thesis", propOrder = {
53
//    "school"
54
})
55
@XmlRootElement(name = "Thesis")
56
@Entity
57
@Indexed(index = "eu.etaxonomy.cdm.model.reference.ReferenceBase")
58
@Audited
59
@Configurable
60
public class Thesis extends PublicationBase<INomenclaturalReferenceCacheStrategy<Thesis>> implements INomenclaturalReference, Cloneable{
61
	private static final long serialVersionUID = -1554558008861571165L;
62
	private static final Logger logger = Logger.getLogger(Thesis.class);
63
	
64
//	@XmlElement(name = "School")
65
//    @XmlIDREF
66
//    @XmlSchemaType(name = "IDREF")
67
//	@ManyToOne(fetch = FetchType.LAZY)
68
//	@IndexedEmbedded
69
//	@Cascade(CascadeType.SAVE_UPDATE)
70
//	private Institution school;
71
	
72
	protected Thesis() {
73
		super();
74
		this.type = ReferenceType.Thesis;
75
		this.cacheStrategy = ThesisDefaultCacheStrategy.NewInstance();
76
	}
77

    
78
	/** 
79
	 * Creates a new empty thesis instance
80
	 * 
81
	 * @see #NewInstance(Institution)
82
	 */
83
	public static Thesis NewInstance(){
84
		Thesis result = new Thesis();
85
		return result;
86
	}
87
	
88
	/** 
89
	 * Creates a new thesis instance with the given {@link eu.etaxonomy.cdm.model.agent.Institution high school institution}.
90
	 * 
91
	 * @param	school		the high school institution where <i>this</i> thesis
92
	 * 						has been submitted
93
	 * @see 				#NewInstance()
94
	 */
95
	public static Thesis NewInstance(Institution school){
96
		Thesis result = NewInstance();
97
		result.setSchool(school);
98
		return result;
99
	}
100
	
101
	/**
102
	 * Returns the {@link eu.etaxonomy.cdm.model.agent.Institution high school institution} in which <i>this</i>
103
	 * report has been submitted.
104
	 * 
105
	 * @return  the high school institution
106
	 * @see 	agent.Institution
107
	 */
108
	public Institution getSchool(){
109
		return this.school;
110
	}
111

    
112
	/**
113
	 * @see #getSchool()
114
	 */
115
	public void setSchool(Institution school){
116
		this.school = school;
117
	}
118
	
119
	/**
120
	 * Returns a formatted string containing the entire citation used for
121
	 * nomenclatural purposes based on <i>this</i> generic reference - including
122
	 * (abbreviated) title but not authors - and on the given
123
	 * details.
124
	 * 
125
	 * @param  microReference	the string with the details (generally pages)
126
	 * 							within <i>this</i> generic reference
127
	 * @return					the formatted string representing the
128
	 * 							nomenclatural citation
129
	 * @see  					#getCitation()
130
	 */
131
	@Transient
132
	public String getNomenclaturalCitation(String microReference) {
133
		if (cacheStrategy == null){
134
			logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
135
			return null;
136
		}else{
137
			return cacheStrategy.getNomenclaturalCitation(this,microReference);
138
		}
139
	}
140
	
141
	
142

    
143
	
144
	/** 
145
	 * Clones <i>this</i> thesis instance. This is a shortcut that enables to
146
	 * create a new instance that differs only slightly from <i>this</i>
147
	 * thesis instance by modifying only some of the attributes.<BR>
148
	 * This method overrides the clone method from {@link PublicationBase PublicationBase}.
149
	 * 
150
	 * @see PublicationBase#clone()
151
	 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
152
	 * @see java.lang.Object#clone()
153
	 */
154
	@Override
155
	public Thesis clone(){
156
		Thesis result = (Thesis)super.clone();
157
		//no changes to: institution
158
		return result;
159
	}
160

    
161
}
(44-44/47)