Project

General

Profile

Download (8.15 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.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
 * 
42
 * @author a.mueller
43
 * @created 20.09.2009
44
 */
45

    
46
//TODO hierarchies, see http://dev.e-taxonomy.eu/trac/ticket/3619
47
@XmlEnum
48
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{
49
	
50
	//0
51
	@XmlEnumValue("Article")
52
	Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", null, ArticleDefaultCacheStrategy.class),
53
	//1
54
	@XmlEnumValue("Book")
55
	Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", null, BookDefaultCacheStrategy.class),
56
	//2
57
	@XmlEnumValue("Book Section")
58
	BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", null, BookSectionDefaultCacheStrategy.class),
59
	//3
60
	@XmlEnumValue("CD or DVD")
61
	CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null, CdDvdDefaultCacheStrategy.class),
62
	//4
63
	@XmlEnumValue("Database")
64
	Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null, ReferenceDefaultCacheStrategy.class),
65
	//5
66
	@XmlEnumValue("Generic")
67
	Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null, GenericDefaultCacheStrategy.class),
68
	//6
69
	@XmlEnumValue("Inproceedings")
70
	InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", null, ReferenceDefaultCacheStrategy.class),
71
	//7
72
	@XmlEnumValue("Journal")
73
	Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null, JournalDefaultCacheStrategy.class),
74
	//8
75
	@XmlEnumValue("Map")
76
	Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null, ReferenceDefaultCacheStrategy.class),
77
	//9
78
	@XmlEnumValue("Patent")
79
	Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null, ReferenceDefaultCacheStrategy.class),
80
	//10
81
	@XmlEnumValue("Personal Communication")
82
	PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null, ReferenceDefaultCacheStrategy.class),
83
	//11
84
	@XmlEnumValue("Print Series")
85
	PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null, ReferenceDefaultCacheStrategy.class),
86
	//12
87
	@XmlEnumValue("Proceedings")
88
	Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", null, ReferenceDefaultCacheStrategy.class),
89
	//13
90
	@XmlEnumValue("Report")
91
	Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null, ReferenceDefaultCacheStrategy.class),
92
	//14
93
	@XmlEnumValue("Thesis")
94
	Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "THE", null, ThesisDefaultCacheStrategy.class),
95
	//15
96
	@XmlEnumValue("Web Page")
97
	WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null, ReferenceDefaultCacheStrategy.class)
98
	;
99

    
100
	@SuppressWarnings("unused")
101
	private static final Logger logger = Logger.getLogger(ReferenceType.class);
102

    
103
	private Class<? extends IReferenceBaseCacheStrategy> cacheStrategy;
104

    
105
	private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent, Class<? extends IReferenceBaseCacheStrategy> cacheStrategy){
106
		this.cacheStrategy = cacheStrategy;
107
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
108
	}
109

    
110

    
111
	public IReferenceBaseCacheStrategy getCacheStrategy(){
112
		switch(this){
113
		case Article:
114
			return ArticleDefaultCacheStrategy.NewInstance();
115
		case Book:
116
			return BookDefaultCacheStrategy.NewInstance();
117
		case BookSection:
118
			return BookSectionDefaultCacheStrategy.NewInstance();
119
		case CdDvd:
120
			return CdDvdDefaultCacheStrategy.NewInstance();
121
		case Generic:
122
			return GenericDefaultCacheStrategy.NewInstance();
123
		case Journal:
124
			return JournalDefaultCacheStrategy.NewInstance();
125
		case Thesis:
126
			return ThesisDefaultCacheStrategy.NewInstance();
127
        default:
128
            return ReferenceDefaultCacheStrategy.NewInstance();
129
		}
130
	}
131

    
132
	/**
133
	 * Returns true if references of this type have volume information.
134
	 */
135
	public boolean isVolumeReference(){
136
		return (this == Article || isPrintedUnit() || this == Generic);
137
	}
138

    
139
	/**
140
	 * Returns true if references of this type are publications (inheriting from
141
	 * {@link IPublicationBase}) and therefore have a publisher and a publication place.
142
	 */
143
	public boolean isPublication(){
144
		return (this == CdDvd || this == Database || this == Generic
145
				|| this == Journal || isPrintedUnit() ||  this == PrintSeries
146
				|| this == Report  || this == Thesis
147
				|| this == WebPage || this == Map);
148
	}
149

    
150
	/**
151
	 * Returns true if references of this type are printed units (inheriting from
152
	 * {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string
153
	 * representing the series (seriesPart).
154
	 */
155
	public boolean isPrintedUnit(){
156
		return (this == Book || this == Proceedings);
157
	}
158

    
159
	/**
160
	 * Returns true if references of this type are parts of other references (inheriting from
161
	 * {@link ISectionBase}) and therefore may have an in-reference and pages.
162
	 */
163
	public boolean isSection(){
164
		return (this == BookSection || this == InProceedings
165
				|| isPrintedUnit() || this == Article );
166
	}
167

    
168
// *************************** DELEGATE **************************************/	
169
	
170
	private static EnumeratedTermVoc<ReferenceType> delegateVoc;
171
	private IEnumTerm<ReferenceType> delegateVocTerm;
172

    
173
	static {
174
		delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class);
175
	}
176
	
177
	@Override
178
	public String getKey(){return delegateVocTerm.getKey();}
179
	
180
	@Override
181
    public String getMessage(){return delegateVocTerm.getMessage();}
182

    
183
	@Override
184
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
185
		
186
	@Override
187
    public UUID getUuid() {return delegateVocTerm.getUuid();}
188

    
189
	@Override
190
    public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();}
191
	
192
	@Override
193
    public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
194

    
195
	@Override
196
	public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor);	}
197

    
198
	@Override
199
    public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
200

    
201
	public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);}
202
    public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
203

    
204

    
205
}
(26-26/28)