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