1 |
9479da48
|
Andreas Müller
|
/**
|
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 |
788ff862
|
Andreas Müller
|
import javax.persistence.Entity;
|
14 |
|
|
import javax.persistence.ManyToOne;
|
15 |
|
|
import javax.persistence.Transient;
|
16 |
f0989f41
|
a.babadshanjan
|
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 |
6a3a07f6
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlIDREF;
|
21 |
f0989f41
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlRootElement;
|
22 |
6a3a07f6
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlSchemaType;
|
23 |
f0989f41
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlTransient;
|
24 |
|
|
import javax.xml.bind.annotation.XmlType;
|
25 |
9479da48
|
Andreas Müller
|
|
26 |
|
|
import org.apache.log4j.Logger;
|
27 |
|
|
import org.hibernate.annotations.Cascade;
|
28 |
|
|
import org.hibernate.annotations.CascadeType;
|
29 |
d50a2c5d
|
Andreas Müller
|
import org.hibernate.annotations.Index;
|
30 |
|
|
import org.hibernate.annotations.Table;
|
31 |
|
|
|
32 |
788ff862
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
33 |
|
|
import eu.etaxonomy.cdm.model.common.IParsable;
|
34 |
|
|
import eu.etaxonomy.cdm.model.media.IdentifyableMediaEntity;
|
35 |
c3440568
|
m.geoffroy
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
36 |
52edc3df
|
m.geoffroy
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
37 |
|
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
38 |
788ff862
|
Andreas Müller
|
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy;
|
39 |
9479da48
|
Andreas Müller
|
|
40 |
|
|
/**
|
41 |
04c7a71a
|
m.geoffroy
|
* 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 |
52edc3df
|
m.geoffroy
|
* <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 |
c3440568
|
m.geoffroy
|
*
|
53 |
9479da48
|
Andreas Müller
|
* @author m.doering
|
54 |
|
|
* @version 1.0
|
55 |
|
|
* @created 08-Nov-2007 13:06:47
|
56 |
|
|
*/
|
57 |
f0989f41
|
a.babadshanjan
|
@XmlAccessorType(XmlAccessType.FIELD)
|
58 |
|
|
@XmlType(name = "ReferenceBase", propOrder = {
|
59 |
|
|
"uri",
|
60 |
|
|
"isNomenclaturallyRelevant",
|
61 |
dbff59db
|
a.babadshanjan
|
"authorTeam"
|
62 |
f0989f41
|
a.babadshanjan
|
})
|
63 |
|
|
@XmlRootElement(name = "RelationshipBase")
|
64 |
9479da48
|
Andreas Müller
|
@Entity
|
65 |
0ec8aee7
|
Andreas Müller
|
@Table(appliesTo="ReferenceBase", indexes = { @Index(name = "ReferenceBaseTitleCacheIndex", columnNames = { "persistentTitleCache" }) })
|
66 |
81c31b35
|
Andreas Müller
|
public abstract class ReferenceBase extends IdentifyableMediaEntity implements IParsable{
|
67 |
f0989f41
|
a.babadshanjan
|
|
68 |
9479da48
|
Andreas Müller
|
static Logger logger = Logger.getLogger(ReferenceBase.class);
|
69 |
f0989f41
|
a.babadshanjan
|
|
70 |
9479da48
|
Andreas Müller
|
//URIs like DOIs, LSIDs or Handles for this reference
|
71 |
f0989f41
|
a.babadshanjan
|
@XmlElement(name = "URI")
|
72 |
9479da48
|
Andreas Müller
|
private String uri;
|
73 |
f0989f41
|
a.babadshanjan
|
|
74 |
9479da48
|
Andreas Müller
|
//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 |
f0989f41
|
a.babadshanjan
|
@XmlElement(name = "IsNomenclaturallyRelevant")
|
77 |
9479da48
|
Andreas Müller
|
private boolean isNomenclaturallyRelevant;
|
78 |
f0989f41
|
a.babadshanjan
|
|
79 |
|
|
@XmlElement(name = "AuthorTeam")
|
80 |
6a3a07f6
|
a.babadshanjan
|
@XmlIDREF
|
81 |
|
|
@XmlSchemaType(name = "IDREF")
|
82 |
65556fd5
|
Andreas Müller
|
private TeamOrPersonBase authorTeam;
|
83 |
f0989f41
|
a.babadshanjan
|
|
84 |
81c31b35
|
Andreas Müller
|
//this flag will be set to true if the parseName method was unable to successfully parse the name
|
85 |
f0989f41
|
a.babadshanjan
|
@XmlAttribute
|
86 |
81c31b35
|
Andreas Müller
|
private boolean hasProblem = false;
|
87 |
|
|
|
88 |
dbff59db
|
a.babadshanjan
|
@XmlTransient
|
89 |
788ff862
|
Andreas Müller
|
protected IReferenceBaseCacheStrategy<ReferenceBase> cacheStrategy;
|
90 |
9479da48
|
Andreas Müller
|
|
91 |
52edc3df
|
m.geoffroy
|
/**
|
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 |
9479da48
|
Andreas Müller
|
@ManyToOne
|
99 |
|
|
@Cascade({CascadeType.SAVE_UPDATE})
|
100 |
65556fd5
|
Andreas Müller
|
public TeamOrPersonBase getAuthorTeam(){
|
101 |
9479da48
|
Andreas Müller
|
return this.authorTeam;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
52edc3df
|
m.geoffroy
|
/**
|
105 |
|
|
* @see #getAuthorTeam()
|
106 |
|
|
*/
|
107 |
788ff862
|
Andreas Müller
|
public void setAuthorTeam(TeamOrPersonBase authorTeam){
|
108 |
9479da48
|
Andreas Müller
|
this.authorTeam = authorTeam;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
52edc3df
|
m.geoffroy
|
/**
|
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 |
9479da48
|
Andreas Müller
|
public String getUri(){
|
119 |
|
|
return this.uri;
|
120 |
|
|
}
|
121 |
52edc3df
|
m.geoffroy
|
/**
|
122 |
|
|
* @see #getUri()
|
123 |
|
|
*/
|
124 |
9479da48
|
Andreas Müller
|
public void setUri(String uri){
|
125 |
|
|
this.uri = uri;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
52edc3df
|
m.geoffroy
|
/**
|
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 |
1cfec1e9
|
m.geoffroy
|
* {@link name.NomenclaturalCode nomenclature code} and is therefore used for
|
133 |
52edc3df
|
m.geoffroy
|
* 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 |
9479da48
|
Andreas Müller
|
public boolean isNomenclaturallyRelevant(){
|
137 |
|
|
return this.isNomenclaturallyRelevant;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
/**
|
141 |
52edc3df
|
m.geoffroy
|
* @see #isNomenclaturallyRelevant()
|
142 |
9479da48
|
Andreas Müller
|
*/
|
143 |
|
|
public void setNomenclaturallyRelevant(boolean isNomenclaturallyRelevant){
|
144 |
|
|
this.isNomenclaturallyRelevant = isNomenclaturallyRelevant;
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
/**
|
148 |
52edc3df
|
m.geoffroy
|
* Returns a formatted string containing the entire reference citation,
|
149 |
|
|
* including authors, corresponding to <i>this</i> reference.
|
150 |
|
|
*
|
151 |
|
|
* @see #generateTitle()
|
152 |
9479da48
|
Andreas Müller
|
*/
|
153 |
|
|
@Transient
|
154 |
52edc3df
|
m.geoffroy
|
// TODO implement
|
155 |
9479da48
|
Andreas Müller
|
public String getCitation(){
|
156 |
|
|
return "";
|
157 |
|
|
}
|
158 |
|
|
|
159 |
52edc3df
|
m.geoffroy
|
/**
|
160 |
|
|
* Returns a string containing the date (mostly only the year) of
|
161 |
|
|
* publication / creation of <i>this</i> reference.
|
162 |
|
|
*/
|
163 |
9479da48
|
Andreas Müller
|
@Transient
|
164 |
|
|
public abstract String getYear();
|
165 |
|
|
|
166 |
52edc3df
|
m.geoffroy
|
/**
|
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 |
81c31b35
|
Andreas Müller
|
public boolean getHasProblem(){
|
175 |
|
|
return this.hasProblem;
|
176 |
|
|
}
|
177 |
52edc3df
|
m.geoffroy
|
/**
|
178 |
|
|
* @see #getHasProblem()
|
179 |
|
|
*/
|
180 |
81c31b35
|
Andreas Müller
|
public void setHasProblem(boolean hasProblem){
|
181 |
|
|
this.hasProblem = hasProblem;
|
182 |
|
|
}
|
183 |
|
|
|
184 |
52edc3df
|
m.geoffroy
|
/**
|
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 |
788ff862
|
Andreas Müller
|
@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 |
835c12dd
|
Andreas Müller
|
|
208 |
|
|
//**************************** CLONE *********************************/
|
209 |
|
|
|
210 |
52edc3df
|
m.geoffroy
|
|
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 |
04c7a71a
|
m.geoffroy
|
* @see java.lang.Object#clone()
|
218 |
835c12dd
|
Andreas Müller
|
*/
|
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 |
9479da48
|
Andreas Müller
|
}
|