1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.model.reference;
|
12
|
|
13
|
import java.io.Serializable;
|
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.EnumeratedTermVoc;
|
23
|
import eu.etaxonomy.cdm.model.common.IEnumTerm;
|
24
|
import eu.etaxonomy.cdm.model.common.Language;
|
25
|
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
|
26
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
|
27
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy;
|
28
|
import eu.etaxonomy.cdm.strategy.cache.reference.CdDvdDefaultCacheStrategy;
|
29
|
import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy;
|
30
|
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy;
|
31
|
import eu.etaxonomy.cdm.strategy.cache.reference.JournalDefaultCacheStrategy;
|
32
|
import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceBaseDefaultCacheStrategy;
|
33
|
import eu.etaxonomy.cdm.strategy.cache.reference.ThesisDefaultCacheStrategy;
|
34
|
|
35
|
|
36
|
/**
|
37
|
* The reference type is used to define the type of a {@link Reference reference}.<BR>
|
38
|
* When changing the type of a reference one must be careful with handling attached information.
|
39
|
* E.g. changing the type of a reference from article to book section requires to either exchange
|
40
|
* the in reference or to change the type of the in reference which may have further consequences.
|
41
|
* @author a.mueller
|
42
|
* @created 20.09.2009
|
43
|
* @version 1.0
|
44
|
*/
|
45
|
@XmlEnum
|
46
|
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{
|
47
|
|
48
|
//0
|
49
|
@XmlEnumValue("Article")
|
50
|
Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", null, ArticleDefaultCacheStrategy.class),
|
51
|
//1
|
52
|
@XmlEnumValue("Book")
|
53
|
Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", null, BookDefaultCacheStrategy.class),
|
54
|
//2
|
55
|
@XmlEnumValue("Book Section")
|
56
|
BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", null, BookSectionDefaultCacheStrategy.class),
|
57
|
//3
|
58
|
@XmlEnumValue("CD or DVD")
|
59
|
CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null, CdDvdDefaultCacheStrategy.class),
|
60
|
//4
|
61
|
@XmlEnumValue("Database")
|
62
|
Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null, ReferenceBaseDefaultCacheStrategy.class),
|
63
|
//5
|
64
|
@XmlEnumValue("Generic")
|
65
|
Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null, GenericDefaultCacheStrategy.class),
|
66
|
//6
|
67
|
@XmlEnumValue("Inproceedings")
|
68
|
InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", null, ReferenceBaseDefaultCacheStrategy.class),
|
69
|
//7
|
70
|
@XmlEnumValue("Journal")
|
71
|
Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null, JournalDefaultCacheStrategy.class),
|
72
|
//8
|
73
|
@XmlEnumValue("Map")
|
74
|
Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null, ReferenceBaseDefaultCacheStrategy.class),
|
75
|
//9
|
76
|
@XmlEnumValue("Patent")
|
77
|
Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null, ReferenceBaseDefaultCacheStrategy.class),
|
78
|
//10
|
79
|
@XmlEnumValue("Personal Communication")
|
80
|
PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null, ReferenceBaseDefaultCacheStrategy.class),
|
81
|
//11
|
82
|
@XmlEnumValue("Print Series")
|
83
|
PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null, ReferenceBaseDefaultCacheStrategy.class),
|
84
|
//12
|
85
|
@XmlEnumValue("Proceedings")
|
86
|
Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", null, ReferenceBaseDefaultCacheStrategy.class),
|
87
|
//13
|
88
|
@XmlEnumValue("Report")
|
89
|
Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null, ReferenceBaseDefaultCacheStrategy.class),
|
90
|
//14
|
91
|
@XmlEnumValue("Thesis")
|
92
|
Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "TES", null, ThesisDefaultCacheStrategy.class),
|
93
|
//15
|
94
|
@XmlEnumValue("Web Page")
|
95
|
WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null, ReferenceBaseDefaultCacheStrategy.class)
|
96
|
;
|
97
|
|
98
|
@SuppressWarnings("unused")
|
99
|
private static final Logger logger = Logger.getLogger(ReferenceType.class);
|
100
|
|
101
|
private Class<? extends IReferenceBaseCacheStrategy> cacheStrategy;
|
102
|
|
103
|
private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent, Class<? extends IReferenceBaseCacheStrategy> cacheStrategy){
|
104
|
this.cacheStrategy = cacheStrategy;
|
105
|
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
|
106
|
}
|
107
|
|
108
|
|
109
|
public IReferenceBaseCacheStrategy getCacheStrategy(){
|
110
|
switch(this){
|
111
|
case Article:
|
112
|
return ArticleDefaultCacheStrategy.NewInstance();
|
113
|
case Book:
|
114
|
return BookDefaultCacheStrategy.NewInstance();
|
115
|
case BookSection:
|
116
|
return BookSectionDefaultCacheStrategy.NewInstance();
|
117
|
case CdDvd:
|
118
|
return CdDvdDefaultCacheStrategy.NewInstance();
|
119
|
case Generic:
|
120
|
return GenericDefaultCacheStrategy.NewInstance();
|
121
|
case Journal:
|
122
|
return JournalDefaultCacheStrategy.NewInstance();
|
123
|
case Thesis:
|
124
|
return ThesisDefaultCacheStrategy.NewInstance();
|
125
|
default:
|
126
|
return ReferenceBaseDefaultCacheStrategy.NewInstance();
|
127
|
}
|
128
|
}
|
129
|
|
130
|
/**
|
131
|
* Returns true if references of this type have volume information.
|
132
|
*/
|
133
|
public boolean isVolumeReference(){
|
134
|
return (this == Article || isPrintedUnit() || this == Generic);
|
135
|
}
|
136
|
|
137
|
/**
|
138
|
* Returns true if references of this type are publications (inheriting from
|
139
|
* {@link IPublicationBase}) and therefore have a publisher and a publication place.
|
140
|
*/
|
141
|
public boolean isPublication(){
|
142
|
return (this == CdDvd || this == Database || this == Generic
|
143
|
|| this == Journal || isPrintedUnit() || this == PrintSeries
|
144
|
|| this == Report || this == Thesis
|
145
|
|| this == WebPage || this == Map);
|
146
|
}
|
147
|
|
148
|
/**
|
149
|
* Returns true if references of this type are printed units (inheriting from
|
150
|
* {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string
|
151
|
* representing the series (seriesPart).
|
152
|
*/
|
153
|
public boolean isPrintedUnit(){
|
154
|
return (this == Book || this == Proceedings);
|
155
|
}
|
156
|
|
157
|
/**
|
158
|
* Returns true if references of this type are parts of other references (inheriting from
|
159
|
* {@link ISectionBase}) and therefore may have an in-reference and pages.
|
160
|
*/
|
161
|
public boolean isSection(){
|
162
|
return (this == BookSection || this == InProceedings
|
163
|
|| isPrintedUnit() || this == Article );
|
164
|
}
|
165
|
|
166
|
// *************************** DELEGATE **************************************/
|
167
|
|
168
|
private static EnumeratedTermVoc<ReferenceType> delegateVoc;
|
169
|
private IEnumTerm<ReferenceType> delegateVocTerm;
|
170
|
|
171
|
static {
|
172
|
delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class);
|
173
|
}
|
174
|
|
175
|
@Override
|
176
|
public String getKey(){return delegateVocTerm.getKey();}
|
177
|
|
178
|
@Override
|
179
|
public String getMessage(){return delegateVocTerm.getMessage();}
|
180
|
|
181
|
@Override
|
182
|
public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
|
183
|
|
184
|
@Override
|
185
|
public UUID getUuid() {return delegateVocTerm.getUuid();}
|
186
|
|
187
|
@Override
|
188
|
public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();}
|
189
|
|
190
|
@Override
|
191
|
public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
|
192
|
|
193
|
@Override
|
194
|
public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor); }
|
195
|
|
196
|
@Override
|
197
|
public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
|
198
|
|
199
|
public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);}
|
200
|
public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
|
201
|
|
202
|
|
203
|
}
|