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 javax.persistence.Transient;
|
14
|
import javax.xml.bind.annotation.XmlEnum;
|
15
|
import javax.xml.bind.annotation.XmlEnumValue;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.Language;
|
18
|
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
|
19
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
|
20
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy;
|
21
|
import eu.etaxonomy.cdm.strategy.cache.reference.CdDvdDefaultCacheStrategy;
|
22
|
import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy;
|
23
|
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy;
|
24
|
import eu.etaxonomy.cdm.strategy.cache.reference.JournalDefaultCacheStrategy;
|
25
|
import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceBaseDefaultCacheStrategy;
|
26
|
import eu.etaxonomy.cdm.strategy.cache.reference.ThesisDefaultCacheStrategy;
|
27
|
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @created 20.09.2009
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
@XmlEnum
|
35
|
public enum ReferenceType {
|
36
|
@XmlEnumValue("Article")
|
37
|
Article("Article", ArticleDefaultCacheStrategy.class),
|
38
|
@XmlEnumValue("Book")
|
39
|
Book("Book", BookDefaultCacheStrategy.class),
|
40
|
@XmlEnumValue("Book Section")
|
41
|
BookSection("Book Section", BookSectionDefaultCacheStrategy.class),
|
42
|
@XmlEnumValue("CD or DVD")
|
43
|
CdDvd("CD or DVD", CdDvdDefaultCacheStrategy.class),
|
44
|
@XmlEnumValue("Database")
|
45
|
Database("Database", ReferenceBaseDefaultCacheStrategy.class),
|
46
|
@XmlEnumValue("Generic")
|
47
|
Generic("Generic", GenericDefaultCacheStrategy.class),
|
48
|
@XmlEnumValue("Inproceedings")
|
49
|
InProceedings("In Proceedings", ReferenceBaseDefaultCacheStrategy.class),
|
50
|
@XmlEnumValue("Journal")
|
51
|
Journal("Journal", JournalDefaultCacheStrategy.class),
|
52
|
@XmlEnumValue("Map")
|
53
|
Map("Map", ReferenceBaseDefaultCacheStrategy.class),
|
54
|
@XmlEnumValue("Patent")
|
55
|
Patent("Patent", ReferenceBaseDefaultCacheStrategy.class),
|
56
|
@XmlEnumValue("Personal Communication")
|
57
|
PersonalCommunication("Personal Communication", ReferenceBaseDefaultCacheStrategy.class),
|
58
|
@XmlEnumValue("Print Series")
|
59
|
PrintSeries("Print Series", ReferenceBaseDefaultCacheStrategy.class),
|
60
|
@XmlEnumValue("Proceedings")
|
61
|
Proceedings("Proceedings", ReferenceBaseDefaultCacheStrategy.class),
|
62
|
@XmlEnumValue("Report")
|
63
|
Report("Report", ReferenceBaseDefaultCacheStrategy.class),
|
64
|
@XmlEnumValue("Thesis")
|
65
|
Thesis("Thesis", ThesisDefaultCacheStrategy.class),
|
66
|
@XmlEnumValue("Web Page")
|
67
|
WebPage("Web Page", ReferenceBaseDefaultCacheStrategy.class),
|
68
|
@XmlEnumValue("Printed Unit Base")
|
69
|
@Deprecated // all references are ReferenceBases this type should not longer be used. Use isPrintedUnit() for tests against this type instead.
|
70
|
PrintedUnitBase("Printed Unit Base", ReferenceBaseDefaultCacheStrategy.class),
|
71
|
@XmlEnumValue("Publication Base")
|
72
|
@Deprecated // all references are ReferenceBases this type should not longer be used. Use isPublication() for tests against this type instead.
|
73
|
PublicationBase("Publication Base", ReferenceBaseDefaultCacheStrategy.class);
|
74
|
|
75
|
|
76
|
private String readableString;
|
77
|
private Class<? extends IReferenceBaseCacheStrategy> cacheStrategy;
|
78
|
|
79
|
private ReferenceType(String defaultString, Class<? extends IReferenceBaseCacheStrategy> cacheStrategy){
|
80
|
readableString = defaultString;
|
81
|
this.cacheStrategy = cacheStrategy;
|
82
|
}
|
83
|
|
84
|
@Transient
|
85
|
public String getMessage(){
|
86
|
return getMessage(Language.DEFAULT());
|
87
|
}
|
88
|
public String getMessage(Language language){
|
89
|
//TODO make multi-lingual
|
90
|
return readableString;
|
91
|
}
|
92
|
|
93
|
public IReferenceBaseCacheStrategy getCacheStrategy(){
|
94
|
switch(this){
|
95
|
case Article:
|
96
|
return ArticleDefaultCacheStrategy.NewInstance();
|
97
|
case Book:
|
98
|
return BookDefaultCacheStrategy.NewInstance();
|
99
|
case BookSection:
|
100
|
return BookSectionDefaultCacheStrategy.NewInstance();
|
101
|
case CdDvd:
|
102
|
return CdDvdDefaultCacheStrategy.NewInstance();
|
103
|
case Generic:
|
104
|
return GenericDefaultCacheStrategy.NewInstance();
|
105
|
case Journal:
|
106
|
return JournalDefaultCacheStrategy.NewInstance();
|
107
|
case Thesis:
|
108
|
return ThesisDefaultCacheStrategy.NewInstance();
|
109
|
}
|
110
|
return ReferenceBaseDefaultCacheStrategy.NewInstance();
|
111
|
}
|
112
|
|
113
|
public boolean isVolumeReference(){
|
114
|
return (this == Article || isPrintedUnit());
|
115
|
}
|
116
|
|
117
|
public boolean isPublication(){
|
118
|
return (this == CdDvd || this == Database || this == Generic
|
119
|
|| this == Journal || isPrintedUnit() || this == PrintSeries
|
120
|
|| this == Proceedings || this == Report
|
121
|
|| this == Thesis || this == WebPage);
|
122
|
}
|
123
|
|
124
|
public boolean isPrintedUnit(){
|
125
|
return (this == Book);
|
126
|
}
|
127
|
|
128
|
public boolean isSection(){
|
129
|
return (this == BookSection || this == InProceedings || isVolumeReference());
|
130
|
}
|
131
|
|
132
|
}
|