Project

General

Profile

Download (9.51 KB) Statistics
| Branch: | Tag: | Revision:
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.ReferenceDefaultCacheStrategy;
33
import eu.etaxonomy.cdm.strategy.cache.reference.SectionDefaultCacheStrategy;
34
import eu.etaxonomy.cdm.strategy.cache.reference.ThesisDefaultCacheStrategy;
35
import eu.etaxonomy.cdm.strategy.cache.reference.WebPageDefaultCacheStrategy;
36

    
37

    
38
/**
39
 * The reference type is used to define the type of a {@link Reference reference}.<BR>
40
 * When changing the type of a reference one must be careful with handling attached information.
41
 * E.g. changing the type of a reference from article to book section requires to either exchange
42
 * the in reference or to change the type of the in reference which may have further consequences.
43
 *
44
 * @author a.mueller
45
 * @created 20.09.2009
46
 */
47

    
48
//TODO hierarchies, see http://dev.e-taxonomy.eu/trac/ticket/3619
49
@XmlEnum
50
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{
51

    
52

    
53
	/**
54
	 * A reference of type section is a part-of another reference. Section is a generalized type for all
55
	 * references which are expected to be part of another reference (e.g. an article which is part of a journal,
56
	 * a book section which is part of a book) or which may have an in-reference
57
	 * such as books which may be part of a print series or websites which may be part of other websites.
58
	 * <BR>
59
	 * However, section as concrete type should only be used if no more specific type is available.
60
	 * This is usually the case for parts of other sections such parts of articles, parts of book sections, or
61
	 * similar cases).
62
	 *
63
	 * @see ISectionBase
64
	 */
65
	@XmlEnumValue("Section")
66
	Section(UUID.fromString("98035142-ca82-46c5-bbef-ad225f668644"), "Section", "SEC", null, ReferenceDefaultCacheStrategy.class),
67

    
68
	//0
69
	/**
70
	 * Article in a journal.
71
	 * Article is a specialization of {@link #Section}.
72
	 */
73
	@XmlEnumValue("Article")
74
	Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", Section, ArticleDefaultCacheStrategy.class),
75
	//1
76
	@XmlEnumValue("Book")
77
	Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", Section, BookDefaultCacheStrategy.class),
78
	//2
79
	/**
80
	 * A part in a book, e.g. a chapter.
81
	 * BookSection is a specialization of {@link #Section}
82
	 */
83
	@XmlEnumValue("Book Section")
84
	BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", Section, BookSectionDefaultCacheStrategy.class),
85
	//3
86
	@XmlEnumValue("CD or DVD")
87
	CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null, CdDvdDefaultCacheStrategy.class),
88
	//4
89
	@XmlEnumValue("Database")
90
	Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null, ReferenceDefaultCacheStrategy.class),
91
	//5
92
	@XmlEnumValue("Generic")
93
	Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null, GenericDefaultCacheStrategy.class),
94
	//6
95
	@XmlEnumValue("Inproceedings")
96
	InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", Section, ReferenceDefaultCacheStrategy.class),
97
	//7
98
	@XmlEnumValue("Journal")
99
	Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null, JournalDefaultCacheStrategy.class),
100
	//8
101
	@XmlEnumValue("Map")
102
	Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null, ReferenceDefaultCacheStrategy.class),
103
	//9
104
	@XmlEnumValue("Patent")
105
	Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null, ReferenceDefaultCacheStrategy.class),
106
	//10
107
	@XmlEnumValue("Personal Communication")
108
	PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null, ReferenceDefaultCacheStrategy.class),
109
	//11
110
	@XmlEnumValue("Print Series")
111
	PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null, ReferenceDefaultCacheStrategy.class),
112
	//12
113
	@XmlEnumValue("Proceedings")
114
	Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", Section, ReferenceDefaultCacheStrategy.class),
115
	//13
116
	@XmlEnumValue("Report")
117
	Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null, ReferenceDefaultCacheStrategy.class),
118
	//14
119
	@XmlEnumValue("Thesis")
120
	Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "THE", null, ThesisDefaultCacheStrategy.class),
121
	//15
122
	@XmlEnumValue("Web Page")
123
	WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null, ReferenceDefaultCacheStrategy.class),
124

    
125
	;
126

    
127
	@SuppressWarnings("unused")
128
	private static final Logger logger = Logger.getLogger(ReferenceType.class);
129

    
130
	private Class<? extends IReferenceBaseCacheStrategy> cacheStrategy;
131

    
132
	private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent, Class<? extends IReferenceBaseCacheStrategy> cacheStrategy){
133
		this.cacheStrategy = cacheStrategy;
134
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
135
	}
136

    
137

    
138
	public IReferenceBaseCacheStrategy getCacheStrategy(){
139
		switch(this){
140
		case Article:
141
			return ArticleDefaultCacheStrategy.NewInstance();
142
		case Book:
143
			return BookDefaultCacheStrategy.NewInstance();
144
		case BookSection:
145
			return BookSectionDefaultCacheStrategy.NewInstance();
146
		case CdDvd:
147
			return CdDvdDefaultCacheStrategy.NewInstance();
148
		case Generic:
149
			return GenericDefaultCacheStrategy.NewInstance();
150
		case Journal:
151
			return JournalDefaultCacheStrategy.NewInstance();
152
		case Thesis:
153
			return ThesisDefaultCacheStrategy.NewInstance();
154
		case Section:
155
			return SectionDefaultCacheStrategy.NewInstance();
156
		case WebPage:
157
			return WebPageDefaultCacheStrategy.NewInstance();
158
        default:
159
            return ReferenceDefaultCacheStrategy.NewInstance();
160
		}
161
	}
162

    
163
	/**
164
	 * Returns true if references of this type have volume information.
165
	 */
166
	public boolean isVolumeReference(){
167
		return (this == Article || isPrintedUnit() || this == Generic);
168
	}
169

    
170
	/**
171
	 * Returns true if references of this type are publications (inheriting from
172
	 * {@link IPublicationBase}) and therefore have a publisher and a publication place.
173
	 */
174
	public boolean isPublication(){
175
		return (this == CdDvd || this == Database || this == Generic
176
				|| this == Journal || isPrintedUnit() ||  this == PrintSeries
177
				|| this == Report  || this == Thesis
178
				|| this == WebPage || this == Map);
179
	}
180

    
181
	/**
182
	 * Returns true if references of this type are printed units (inheriting from
183
	 * {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string
184
	 * representing the series (seriesPart).
185
	 */
186
	public boolean isPrintedUnit(){
187
		return (this == Book || this == Proceedings);
188
	}
189

    
190

    
191

    
192
	/**
193
	 * Returns true if references of this type are parts of other references (inheriting from
194
	 * {@link ISection}) and therefore may have an in-reference and pages.
195
	 */
196
	public boolean isSection(){
197
//		return (this == BookSection || this == InProceedings
198
//				|| isPrintedUnit() || this == Article );
199
		return this == Section || isKindOf(Section);
200
	}
201

    
202
// *************************** DELEGATE **************************************/
203

    
204
	private static EnumeratedTermVoc<ReferenceType> delegateVoc;
205
	private IEnumTerm<ReferenceType> delegateVocTerm;
206

    
207
	static {
208
		delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class);
209
	}
210

    
211
	@Override
212
	public String getKey(){return delegateVocTerm.getKey();}
213

    
214
	@Override
215
    public String getMessage(){return delegateVocTerm.getMessage();}
216

    
217
	@Override
218
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
219

    
220
	@Override
221
    public UUID getUuid() {return delegateVocTerm.getUuid();}
222

    
223
	@Override
224
    public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();}
225

    
226
	@Override
227
    public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
228

    
229
	@Override
230
	public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor);	}
231

    
232
	@Override
233
    public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
234

    
235
	public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);}
236
    public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
237

    
238

    
239
}
(26-26/28)