1
|
/**
|
2
|
* Copyright (C) 2009 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 org.apache.log4j.Logger;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.agent.Person;
|
15
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
16
|
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
|
17
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
|
18
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy;
|
19
|
import eu.etaxonomy.cdm.strategy.cache.reference.CdDvdDefaultCacheStrategy;
|
20
|
import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy;
|
21
|
import eu.etaxonomy.cdm.strategy.cache.reference.JournalDefaultCacheStrategy;
|
22
|
import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceDefaultCacheStrategy;
|
23
|
import eu.etaxonomy.cdm.strategy.cache.reference.SectionDefaultCacheStrategy;
|
24
|
import eu.etaxonomy.cdm.strategy.cache.reference.ThesisDefaultCacheStrategy;
|
25
|
|
26
|
public class ReferenceFactory {
|
27
|
private static final Logger logger = Logger.getLogger(ReferenceFactory.class);
|
28
|
|
29
|
public static Reference newArticle(){
|
30
|
Reference<ArticleDefaultCacheStrategy> article = new Reference(ReferenceType.Article);
|
31
|
article.setCacheStrategy(ReferenceType.Article.getCacheStrategy());
|
32
|
return article;
|
33
|
}
|
34
|
|
35
|
public static Reference newJournal(){
|
36
|
Reference<JournalDefaultCacheStrategy> journal = new Reference(ReferenceType.Journal);
|
37
|
journal.setCacheStrategy(ReferenceType.Journal.getCacheStrategy());
|
38
|
return journal;
|
39
|
}
|
40
|
|
41
|
public static Reference newBook(){
|
42
|
Reference<BookDefaultCacheStrategy> book = new Reference<BookDefaultCacheStrategy>(ReferenceType.Book);
|
43
|
book.setCacheStrategy(ReferenceType.Book.getCacheStrategy());
|
44
|
return book;
|
45
|
}
|
46
|
|
47
|
public static Reference newThesis(){
|
48
|
Reference<ThesisDefaultCacheStrategy> thesis = new Reference<ThesisDefaultCacheStrategy>(ReferenceType.Thesis);
|
49
|
thesis.setCacheStrategy(ReferenceType.Thesis.getCacheStrategy());
|
50
|
return thesis;
|
51
|
}
|
52
|
|
53
|
public static Reference newInProceedings(){
|
54
|
Reference<ReferenceDefaultCacheStrategy> inProceedings = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.InProceedings);
|
55
|
inProceedings.setCacheStrategy(ReferenceType.InProceedings.getCacheStrategy());
|
56
|
return inProceedings;
|
57
|
}
|
58
|
|
59
|
public static Reference newProceedings(){
|
60
|
Reference<ReferenceDefaultCacheStrategy> proceedings = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Proceedings);
|
61
|
proceedings.setCacheStrategy(ReferenceType.Proceedings.getCacheStrategy());
|
62
|
return proceedings;
|
63
|
}
|
64
|
|
65
|
public static Reference newBookSection(){
|
66
|
Reference<BookSectionDefaultCacheStrategy> bookSection = new Reference<BookSectionDefaultCacheStrategy>(ReferenceType.BookSection);
|
67
|
bookSection.setCacheStrategy(ReferenceType.BookSection.getCacheStrategy());
|
68
|
return bookSection;
|
69
|
}
|
70
|
|
71
|
|
72
|
public static Reference newSection(){
|
73
|
//TODO we still need a separate cache strategy
|
74
|
Reference<SectionDefaultCacheStrategy> section = new Reference<SectionDefaultCacheStrategy>(ReferenceType.Section);
|
75
|
section.setCacheStrategy(ReferenceType.Section.getCacheStrategy());
|
76
|
return section;
|
77
|
}
|
78
|
|
79
|
public static Reference newCdDvd(){
|
80
|
Reference<CdDvdDefaultCacheStrategy> cdDvd= new Reference<CdDvdDefaultCacheStrategy>(ReferenceType.CdDvd);
|
81
|
cdDvd.setCacheStrategy(ReferenceType.CdDvd.getCacheStrategy());
|
82
|
return cdDvd;
|
83
|
}
|
84
|
|
85
|
public static Reference newGeneric(){
|
86
|
Reference<?> generic = new Reference<GenericDefaultCacheStrategy>(ReferenceType.Generic);
|
87
|
generic.setCacheStrategy(ReferenceType.Generic.getCacheStrategy());
|
88
|
return generic;
|
89
|
}
|
90
|
|
91
|
public static Reference newMap(){
|
92
|
Reference<ReferenceDefaultCacheStrategy> map = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Map);
|
93
|
map.setCacheStrategy(ReferenceType.Map.getCacheStrategy());
|
94
|
return map;
|
95
|
|
96
|
}
|
97
|
|
98
|
public static Reference newReport(){
|
99
|
Reference<ReferenceDefaultCacheStrategy> report = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Report);
|
100
|
report.setCacheStrategy(ReferenceType.Report.getCacheStrategy());
|
101
|
return report;
|
102
|
|
103
|
}
|
104
|
|
105
|
public static Reference newWebPage(){
|
106
|
Reference<ReferenceDefaultCacheStrategy> webPage = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.WebPage);
|
107
|
webPage.setCacheStrategy(ReferenceType.WebPage.getCacheStrategy());
|
108
|
return webPage;
|
109
|
}
|
110
|
|
111
|
public static Reference newDatabase(){
|
112
|
Reference<ReferenceDefaultCacheStrategy> db = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Database);
|
113
|
db.setCacheStrategy(ReferenceType.Database.getCacheStrategy());
|
114
|
return db;
|
115
|
}
|
116
|
|
117
|
|
118
|
/**
|
119
|
* Creates a new empty print series instance.
|
120
|
*/
|
121
|
public static Reference newPrintSeries() {
|
122
|
Reference<ReferenceDefaultCacheStrategy> refBase = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.PrintSeries);
|
123
|
refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy());
|
124
|
return refBase;
|
125
|
}
|
126
|
|
127
|
/**
|
128
|
* Creates a new print series instance with a given title string.
|
129
|
*/
|
130
|
public static Reference newPrintSeries(String series) {
|
131
|
Reference<ReferenceDefaultCacheStrategy> refBase = newPrintSeries();
|
132
|
refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy());
|
133
|
return refBase;
|
134
|
}
|
135
|
|
136
|
public static Reference newBookSection(Reference book, Person partAuthor,
|
137
|
String sectionTitle, String pages) {
|
138
|
Reference<?> bookSection = newBookSection();
|
139
|
bookSection.setAuthorTeam(partAuthor);
|
140
|
bookSection.setTitle(sectionTitle);
|
141
|
bookSection.setPages(pages);
|
142
|
return bookSection;
|
143
|
}
|
144
|
|
145
|
public static Reference newArticle(Reference inJournal, Person partAuthor,
|
146
|
String title, String pages, String series, String volume, TimePeriod datePublished) {
|
147
|
Reference<?> article = newArticle();
|
148
|
article.setInReference(inJournal);
|
149
|
article.setAuthorTeam(partAuthor);
|
150
|
article.setTitle(title);
|
151
|
article.setPages(pages);
|
152
|
article.setVolume(volume);
|
153
|
article.setDatePublished(datePublished);
|
154
|
return article;
|
155
|
}
|
156
|
|
157
|
/**
|
158
|
* Returns a new reference for the according reference type. If reference type is <code>null</code>,
|
159
|
* <code>null</code> is returned.
|
160
|
* @param referenceType
|
161
|
* @return
|
162
|
*/
|
163
|
public static Reference<?> newReference(ReferenceType referenceType) {
|
164
|
if (referenceType == null){
|
165
|
return null;
|
166
|
}
|
167
|
switch(referenceType){
|
168
|
case Article:
|
169
|
return newArticle();
|
170
|
case Journal:
|
171
|
return newJournal();
|
172
|
case BookSection:
|
173
|
return newBookSection();
|
174
|
case CdDvd:
|
175
|
return newCdDvd();
|
176
|
case Database:
|
177
|
return newDatabase();
|
178
|
case InProceedings:
|
179
|
return newInProceedings();
|
180
|
case Map:
|
181
|
return newMap();
|
182
|
case Patent:
|
183
|
return newPatent();
|
184
|
case PersonalCommunication:
|
185
|
return newPersonalCommunication();
|
186
|
case PrintSeries:
|
187
|
return newPrintSeries();
|
188
|
case Proceedings:
|
189
|
return newProceedings();
|
190
|
case Report:
|
191
|
return newReport();
|
192
|
case Thesis:
|
193
|
return newThesis();
|
194
|
case WebPage:
|
195
|
return newWebPage();
|
196
|
case Book:
|
197
|
return newBook();
|
198
|
case Generic:
|
199
|
return newGeneric();
|
200
|
case Section:
|
201
|
return newSection();
|
202
|
default:
|
203
|
logger.warn("Unknown reference type " + referenceType.getMessage() + ". Created generic reference instead.");
|
204
|
return newGeneric();
|
205
|
}
|
206
|
}
|
207
|
|
208
|
public static Reference newPersonalCommunication() {
|
209
|
Reference<ReferenceDefaultCacheStrategy> personalCommunication = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.PersonalCommunication);
|
210
|
personalCommunication.setCacheStrategy(ReferenceType.PersonalCommunication.getCacheStrategy());
|
211
|
return personalCommunication;
|
212
|
}
|
213
|
|
214
|
public static Reference newPatent() {
|
215
|
Reference<ReferenceDefaultCacheStrategy> patent = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Patent);
|
216
|
patent.setCacheStrategy(ReferenceType.Patent.getCacheStrategy());
|
217
|
return patent;
|
218
|
}
|
219
|
|
220
|
|
221
|
|
222
|
}
|