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
|
import java.io.Serializable;
|
13
|
import java.util.HashSet;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import javax.xml.bind.annotation.XmlEnum;
|
18
|
import javax.xml.bind.annotation.XmlEnumValue;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.common.Language;
|
23
|
import eu.etaxonomy.cdm.model.term.EnumeratedTermVoc;
|
24
|
import eu.etaxonomy.cdm.model.term.IEnumTerm;
|
25
|
|
26
|
|
27
|
/**
|
28
|
* The reference type is used to define the type of a {@link Reference reference}.<BR>
|
29
|
* When changing the type of a reference one must be careful with handling attached information.
|
30
|
* E.g. changing the type of a reference from article to book section requires to either exchange
|
31
|
* the in reference or to change the type of the in reference which may have further consequences.
|
32
|
*
|
33
|
* @author a.mueller
|
34
|
* @since 20.09.2009
|
35
|
*/
|
36
|
|
37
|
//TODO hierarchies, see https://dev.e-taxonomy.eu/redmine/issues/3619
|
38
|
@XmlEnum
|
39
|
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{
|
40
|
|
41
|
|
42
|
/**
|
43
|
* A reference of type section is a part-of another reference. Section is a generalized type for all
|
44
|
* references which are expected to be part of another reference (e.g. an article which is part of a journal,
|
45
|
* a book section which is part of a book) or which may have an in-reference
|
46
|
* such as books which may be part of a print series or websites which may be part of other websites.
|
47
|
* <BR>
|
48
|
* However, section as concrete type should only be used if no more specific type is available.
|
49
|
* This is usually the case for parts of other sections such parts of articles, parts of book sections, or
|
50
|
* similar cases).
|
51
|
*
|
52
|
* @see ISectionBase
|
53
|
*/
|
54
|
@XmlEnumValue("Section")
|
55
|
Section(UUID.fromString("98035142-ca82-46c5-bbef-ad225f668644"), "Section", "SEC", null),
|
56
|
|
57
|
//0
|
58
|
/**
|
59
|
* Article in a journal.
|
60
|
* Article is a specialization of {@link #Section}.
|
61
|
*/
|
62
|
@XmlEnumValue("Article")
|
63
|
Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", Section),
|
64
|
//1
|
65
|
@XmlEnumValue("Book")
|
66
|
Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", Section),
|
67
|
//2
|
68
|
/**
|
69
|
* A part in a book, e.g. a chapter.
|
70
|
* BookSection is a specialization of {@link #Section}
|
71
|
*/
|
72
|
@XmlEnumValue("Book Section")
|
73
|
BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", Section),
|
74
|
//3
|
75
|
@XmlEnumValue("CD or DVD")
|
76
|
CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null),
|
77
|
//4
|
78
|
@XmlEnumValue("Database")
|
79
|
Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null),
|
80
|
//5
|
81
|
@XmlEnumValue("Generic")
|
82
|
Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null),
|
83
|
//6
|
84
|
@XmlEnumValue("Inproceedings")
|
85
|
InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", Section),
|
86
|
//7
|
87
|
@XmlEnumValue("Journal")
|
88
|
Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null),
|
89
|
//8
|
90
|
@XmlEnumValue("Map")
|
91
|
Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null),
|
92
|
//9
|
93
|
@XmlEnumValue("Patent")
|
94
|
Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null),
|
95
|
//10
|
96
|
@XmlEnumValue("Personal Communication")
|
97
|
PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null),
|
98
|
//11
|
99
|
@XmlEnumValue("Print Series")
|
100
|
PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null),
|
101
|
//12
|
102
|
@XmlEnumValue("Proceedings")
|
103
|
Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", Section),
|
104
|
//13
|
105
|
@XmlEnumValue("Report")
|
106
|
Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null),
|
107
|
//14
|
108
|
@XmlEnumValue("Thesis")
|
109
|
Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "THE", null),
|
110
|
//15
|
111
|
@XmlEnumValue("Web Page")
|
112
|
WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null),
|
113
|
|
114
|
;
|
115
|
|
116
|
@SuppressWarnings("unused")
|
117
|
private static final Logger logger = Logger.getLogger(ReferenceType.class);
|
118
|
|
119
|
|
120
|
private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent){
|
121
|
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* Returns true if references of this type have volume information.
|
126
|
*/
|
127
|
public boolean isVolumeReference(){
|
128
|
return (this == Article || isPrintedUnit() || this == Generic);
|
129
|
}
|
130
|
|
131
|
/**
|
132
|
* Returns true if references of this type are publications (inheriting from
|
133
|
* {@link IPublicationBase}) and therefore have a publisher and a publication place.
|
134
|
*/
|
135
|
public boolean isPublication(){
|
136
|
return (this == CdDvd || this == Database || this == Generic
|
137
|
|| this == Journal || isPrintedUnit() || this == PrintSeries
|
138
|
|| this == Report || this == Thesis
|
139
|
|| this == WebPage || this == Map);
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* Returns true if references of this type are printed units (inheriting from
|
144
|
* {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string
|
145
|
* representing the series (seriesPart).
|
146
|
*/
|
147
|
public boolean isPrintedUnit(){
|
148
|
return (this == Book || this == Proceedings);
|
149
|
}
|
150
|
|
151
|
|
152
|
|
153
|
/**
|
154
|
* Returns true if references of this type are parts of other references (inheriting from
|
155
|
* {@link ISection}) and therefore may have an in-reference and pages.
|
156
|
*/
|
157
|
public boolean isSection(){
|
158
|
// return (this == BookSection || this == InProceedings
|
159
|
// || isPrintedUnit() || this == Article );
|
160
|
return this == Section || isKindOf(Section);
|
161
|
}
|
162
|
|
163
|
/**
|
164
|
* Provides the set of type which are applicable as in-references for
|
165
|
* the <code>subReferenceType</code> passed to this method:
|
166
|
*
|
167
|
* The type specific rules are:
|
168
|
* <ul>
|
169
|
* <li>Article -> Journal</li>
|
170
|
* <li>Book -> PrintSeries | Journal<br>(Journal is needed here to cover historic
|
171
|
* situations: In Ehrenberg's times (Phycology) some articles (prior to publication in a journal)
|
172
|
* were printed and delivered to colleagues and libraries (published preprints). Therefore it necessary to allow these as (small)
|
173
|
* books being a part of a Journal.)</li>
|
174
|
* <li>BookSection -> Book</li>
|
175
|
* <li>InProceedings -> Proceedings</li>
|
176
|
* <li>Section -> Article | Book | Thesis | Patent | Report | Webpage | inProceedings</li>
|
177
|
* </ul>
|
178
|
* In case the passed <code>subReferenceType</code> matches none of the above rules the returned set will be empty.
|
179
|
* <p>
|
180
|
* NOTE: If these constraints are being used in UI contexts, it might be sensible in specific situations to add {@link #Generic} and <code>null</code>
|
181
|
* to the list in case it was not empty.
|
182
|
*
|
183
|
* @param subReferenceType
|
184
|
* The type of the part for which the possible in-refrence types are to be returned.
|
185
|
* @return a set, may be empty, never <code>null</code>
|
186
|
*/
|
187
|
public static Set<ReferenceType> inReferenceContraints(ReferenceType subReferenceType){
|
188
|
Set<ReferenceType> inRefTypes = new HashSet<>();
|
189
|
|
190
|
if(subReferenceType != null && !subReferenceType.equals(ReferenceType.Generic)){
|
191
|
if(subReferenceType.isArticle()){
|
192
|
inRefTypes.add(ReferenceType.Journal);
|
193
|
} else if (subReferenceType == ReferenceType.BookSection) {
|
194
|
inRefTypes.add(ReferenceType.Book);
|
195
|
} else if (subReferenceType.isBook()) {
|
196
|
inRefTypes.add(ReferenceType.PrintSeries);
|
197
|
inRefTypes.add(ReferenceType.Journal);
|
198
|
} else if (subReferenceType == ReferenceType.InProceedings) {
|
199
|
inRefTypes.add(ReferenceType.Proceedings);
|
200
|
} else if (subReferenceType == ReferenceType.Section) {
|
201
|
inRefTypes.add(ReferenceType.Article);
|
202
|
inRefTypes.add(ReferenceType.Book);
|
203
|
inRefTypes.add(ReferenceType.Thesis);
|
204
|
inRefTypes.add(ReferenceType.Patent);
|
205
|
inRefTypes.add(ReferenceType.Report);
|
206
|
inRefTypes.add(ReferenceType.WebPage);
|
207
|
inRefTypes.add(ReferenceType.InProceedings);
|
208
|
inRefTypes.add(ReferenceType.BookSection);
|
209
|
}
|
210
|
}
|
211
|
|
212
|
return inRefTypes;
|
213
|
}
|
214
|
|
215
|
// *************************** DELEGATE **************************************/
|
216
|
|
217
|
private static EnumeratedTermVoc<ReferenceType> delegateVoc;
|
218
|
private IEnumTerm<ReferenceType> delegateVocTerm;
|
219
|
|
220
|
static {
|
221
|
delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class);
|
222
|
}
|
223
|
|
224
|
@Override
|
225
|
public String getKey(){return delegateVocTerm.getKey();}
|
226
|
|
227
|
@Override
|
228
|
public String getMessage(){return delegateVocTerm.getMessage();}
|
229
|
|
230
|
@Override
|
231
|
public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
|
232
|
|
233
|
@Override
|
234
|
public UUID getUuid() {return delegateVocTerm.getUuid();}
|
235
|
|
236
|
@Override
|
237
|
public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();}
|
238
|
|
239
|
@Override
|
240
|
public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
|
241
|
|
242
|
@Override
|
243
|
public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor); }
|
244
|
|
245
|
@Override
|
246
|
public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
|
247
|
|
248
|
public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);}
|
249
|
public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
|
250
|
|
251
|
/**
|
252
|
* @return
|
253
|
*/
|
254
|
public boolean isArticle() {
|
255
|
return this == Article;
|
256
|
}
|
257
|
public boolean isBook() {
|
258
|
return this == Book;
|
259
|
}
|
260
|
public boolean isBookSection() {
|
261
|
return this == BookSection;
|
262
|
}
|
263
|
//TBC
|
264
|
|
265
|
|
266
|
}
|