Project

General

Profile

« Previous | Next » 

Revision 90046bc4

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-model #5830

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/ReferenceFactory.java
5 5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/ 
8
*/
9 9

  
10 10
package eu.etaxonomy.cdm.model.reference;
11 11

  
......
13 13

  
14 14
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
15 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 16

  
26 17
public class ReferenceFactory {
27 18
	private static final Logger logger = Logger.getLogger(ReferenceFactory.class);
28
	
19

  
29 20
	public static Reference newArticle(){
30
		Reference<ArticleDefaultCacheStrategy> article = new Reference(ReferenceType.Article);
21
		Reference article = new Reference(ReferenceType.Article);
31 22
		article.setCacheStrategy(ReferenceType.Article.getCacheStrategy());
32 23
		return article;
33 24
	}
34 25

  
35 26
	public static Reference newJournal(){
36
		Reference<JournalDefaultCacheStrategy> journal = new Reference(ReferenceType.Journal);
27
		Reference journal = new Reference(ReferenceType.Journal);
37 28
		journal.setCacheStrategy(ReferenceType.Journal.getCacheStrategy());
38 29
		return journal;
39 30
	}
40
	
31

  
41 32
	public static Reference newBook(){
42
		Reference<BookDefaultCacheStrategy> book = new Reference<BookDefaultCacheStrategy>(ReferenceType.Book);
33
		Reference book = new Reference(ReferenceType.Book);
43 34
		book.setCacheStrategy(ReferenceType.Book.getCacheStrategy());
44 35
		return book;
45 36
	}
46
	
37

  
47 38
	public static Reference newThesis(){
48
		Reference<ThesisDefaultCacheStrategy> thesis = new Reference<ThesisDefaultCacheStrategy>(ReferenceType.Thesis);
39
		Reference thesis = new Reference(ReferenceType.Thesis);
49 40
		thesis.setCacheStrategy(ReferenceType.Thesis.getCacheStrategy());
50 41
		return thesis;
51 42
	}
52
	
43

  
53 44
	public static Reference newInProceedings(){
54
		Reference<ReferenceDefaultCacheStrategy> inProceedings = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.InProceedings);
45
		Reference inProceedings = new Reference(ReferenceType.InProceedings);
55 46
		inProceedings.setCacheStrategy(ReferenceType.InProceedings.getCacheStrategy());
56 47
		return inProceedings;
57 48
	}
58
	
49

  
59 50
	public static Reference newProceedings(){
60
		Reference<ReferenceDefaultCacheStrategy> proceedings = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Proceedings);
51
		Reference proceedings = new Reference(ReferenceType.Proceedings);
61 52
		proceedings.setCacheStrategy(ReferenceType.Proceedings.getCacheStrategy());
62 53
		return proceedings;
63 54
	}
64
	
55

  
65 56
	public static Reference newBookSection(){
66
		Reference<BookSectionDefaultCacheStrategy> bookSection = new Reference<BookSectionDefaultCacheStrategy>(ReferenceType.BookSection);
57
		Reference bookSection = new Reference(ReferenceType.BookSection);
67 58
		bookSection.setCacheStrategy(ReferenceType.BookSection.getCacheStrategy());
68 59
		return bookSection;
69 60
	}
70
	
71
	
61

  
62

  
72 63
	public static Reference newSection(){
73
		//TODO we still need a separate cache strategy
74
		Reference<SectionDefaultCacheStrategy> section = new Reference<SectionDefaultCacheStrategy>(ReferenceType.Section);
64
		Reference section = new Reference(ReferenceType.Section);
75 65
		section.setCacheStrategy(ReferenceType.Section.getCacheStrategy());
76 66
		return section;
77 67
	}
78
	
68

  
79 69
	public static Reference newCdDvd(){
80
		Reference<CdDvdDefaultCacheStrategy> cdDvd= new Reference<CdDvdDefaultCacheStrategy>(ReferenceType.CdDvd);
70
		Reference cdDvd= new Reference(ReferenceType.CdDvd);
81 71
		cdDvd.setCacheStrategy(ReferenceType.CdDvd.getCacheStrategy());
82 72
		return cdDvd;
83 73
	}
84
	
74

  
85 75
	public static Reference newGeneric(){
86
		Reference<?> generic = new Reference<GenericDefaultCacheStrategy>(ReferenceType.Generic);
76
		Reference generic = new Reference(ReferenceType.Generic);
87 77
		generic.setCacheStrategy(ReferenceType.Generic.getCacheStrategy());
88 78
		return generic;
89 79
	}
90
	
80

  
91 81
	public static Reference newMap(){
92
		Reference<ReferenceDefaultCacheStrategy> map = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Map);
82
		Reference map = new Reference(ReferenceType.Map);
93 83
		map.setCacheStrategy(ReferenceType.Map.getCacheStrategy());
94 84
		return map;
95
		
85

  
96 86
	}
97
	
87

  
98 88
	public static Reference newReport(){
99
		Reference<ReferenceDefaultCacheStrategy> report = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Report);
89
		Reference report = new Reference(ReferenceType.Report);
100 90
		report.setCacheStrategy(ReferenceType.Report.getCacheStrategy());
101 91
		return report;
102
		
92

  
103 93
	}
104
	
94

  
105 95
	public static Reference newWebPage(){
106
		Reference<ReferenceDefaultCacheStrategy> webPage = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.WebPage);
96
		Reference webPage = new Reference(ReferenceType.WebPage);
107 97
		webPage.setCacheStrategy(ReferenceType.WebPage.getCacheStrategy());
108 98
		return webPage;
109 99
	}
110
	
100

  
111 101
	public static Reference newDatabase(){
112
		Reference<ReferenceDefaultCacheStrategy> db = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Database);
102
		Reference db = new Reference(ReferenceType.Database);
113 103
		db.setCacheStrategy(ReferenceType.Database.getCacheStrategy());
114 104
		return db;
115 105
	}
116 106

  
117 107

  
118
	/** 
108
	/**
119 109
	 * Creates a new empty print series instance.
120 110
	 */
121 111
	public static Reference newPrintSeries() {
122
		Reference<ReferenceDefaultCacheStrategy> refBase = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.PrintSeries);
112
		Reference refBase = new Reference(ReferenceType.PrintSeries);
123 113
		refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy());
124 114
		return refBase;
125 115
	}
126
	
127
	/** 
116

  
117
	/**
128 118
	 * Creates a new print series instance with a given title string.
129 119
	 */
130 120
	public static Reference newPrintSeries(String series) {
131
		Reference<ReferenceDefaultCacheStrategy> refBase = newPrintSeries();
121
		Reference refBase = newPrintSeries();
122
		refBase.setTitle(series);
132 123
		refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy());
133 124
		return refBase;
134 125
	}
135 126

  
136 127
	public static Reference newBookSection(Reference book, TeamOrPersonBase partAuthor,
137 128
			String sectionTitle, String pages) {
138
		Reference<?> bookSection = newBookSection();
129
		Reference bookSection = newBookSection();
130
		bookSection.setInBook(book);
139 131
		bookSection.setAuthorship(partAuthor);
140 132
		bookSection.setTitle(sectionTitle);
141 133
		bookSection.setPages(pages);
......
143 135
	}
144 136

  
145 137
	public static Reference newArticle(Reference inJournal, TeamOrPersonBase partAuthor,
146
			String title, String pages, String series, String volume, TimePeriod datePublished) {
147
		Reference<?> article = newArticle();
138
			String title, String pages, String seriesPart, String volume, TimePeriod datePublished) {
139
		IArticle article = newArticle();
148 140
		article.setInReference(inJournal);
149 141
		article.setAuthorship(partAuthor);
150 142
		article.setTitle(title);
151 143
		article.setPages(pages);
152 144
		article.setVolume(volume);
145
		article.setSeriesPart(seriesPart);
153 146
		article.setDatePublished(datePublished);
154
		return article;
147
		return (Reference)article;
155 148
	}
156 149

  
157 150
	/**
......
160 153
	 * @param referenceType
161 154
	 * @return
162 155
	 */
163
	public static Reference<?> newReference(ReferenceType referenceType) {
156
	public static Reference newReference(ReferenceType referenceType) {
164 157
		if (referenceType == null){
165 158
			return null;
166 159
		}
......
201 194
				return newSection();
202 195
			default:
203 196
				logger.warn("Unknown reference type " + referenceType.getMessage() + ". Created generic reference instead.");
204
				return newGeneric();	
197
				return newGeneric();
205 198
		}
206 199
	}
207 200

  
208 201
	public static Reference newPersonalCommunication() {
209
		Reference<ReferenceDefaultCacheStrategy> personalCommunication = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.PersonalCommunication);
202
		Reference personalCommunication = new Reference(ReferenceType.PersonalCommunication);
210 203
		personalCommunication.setCacheStrategy(ReferenceType.PersonalCommunication.getCacheStrategy());
211 204
		return personalCommunication;
212 205
	}
213 206

  
214 207
	public static Reference newPatent() {
215
		Reference<ReferenceDefaultCacheStrategy> patent = new Reference<ReferenceDefaultCacheStrategy>(ReferenceType.Patent);
208
		Reference patent = new Reference(ReferenceType.Patent);
216 209
		patent.setCacheStrategy(ReferenceType.Patent.getCacheStrategy());
217 210
		return patent;
218 211
	}
219
	
220
	
221
	
212

  
213

  
214

  
222 215
}

Also available in: Unified diff