Revision d774802a
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/Reference.java | ||
---|---|---|
568 | 568 |
} else{ |
569 | 569 |
this.type = type; |
570 | 570 |
} |
571 |
this.setCacheStrategy(type.getCacheStrategy()); |
|
572 | 571 |
} |
573 | 572 |
@Override |
574 | 573 |
public ReferenceType getType() { |
... | ... | |
719 | 718 |
// TODO implement |
720 | 719 |
@Transient |
721 | 720 |
public String getCitation(){ |
722 |
rectifyCacheStrategy(); |
|
723 | 721 |
if (getCacheStrategy() == null){ |
724 | 722 |
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid()); |
725 | 723 |
return null; |
... | ... | |
731 | 729 |
|
732 | 730 |
@Override |
733 | 731 |
public String generateTitle() { |
734 |
rectifyCacheStrategy(); |
|
735 | 732 |
return super.generateTitle(); |
736 | 733 |
} |
737 | 734 |
|
738 | 735 |
public String generateAbbrevTitle() { |
739 |
rectifyCacheStrategy(); //TODO needed, is called by getCacheStrategy already |
|
740 | 736 |
return getCacheStrategy().getFullAbbrevTitleString(this); |
741 | 737 |
} |
742 | 738 |
|
... | ... | |
836 | 832 |
@Override |
837 | 833 |
@Transient |
838 | 834 |
public String getNomenclaturalCitation(String microReference) { |
839 |
rectifyCacheStrategy(); |
|
840 | 835 |
String typeName = this.getType()== null ? "(no type defined)" : this.getType().getMessage(); |
841 | 836 |
if (getCacheStrategy() == null){ |
842 | 837 |
logger.warn("No CacheStrategy defined for "+ typeName + ": " + this.getUuid()); |
... | ... | |
1019 | 1014 |
|
1020 | 1015 |
@Override |
1021 | 1016 |
public IReferenceCacheStrategy getCacheStrategy() { |
1022 |
rectifyCacheStrategy(); |
|
1023 | 1017 |
return this.cacheStrategy; |
1024 | 1018 |
} |
1025 | 1019 |
|
1026 |
/** |
|
1027 |
* The type property of this class is mapped on the field level to the data base column, so |
|
1028 |
* Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor} |
|
1029 |
* to set the property. This PropertyAccessor directly sets the field instead of using the according setter so |
|
1030 |
* the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to |
|
1031 |
* validate the CacheStrategy before it is to be used. |
|
1032 |
*/ |
|
1033 |
private void rectifyCacheStrategy() { |
|
1034 |
if(!cacheStrategyRectified ){ |
|
1035 |
setType(getType()); |
|
1036 |
cacheStrategyRectified = true; |
|
1037 |
} |
|
1020 |
@Override |
|
1021 |
public void setCacheStrategy(IReferenceCacheStrategy referenceCacheStrategy) { |
|
1022 |
this.cacheStrategy = referenceCacheStrategy; |
|
1038 | 1023 |
} |
1039 | 1024 |
|
1040 | 1025 |
|
1041 |
@Override |
|
1042 |
public void setCacheStrategy(IReferenceCacheStrategy iReferenceBaseCacheStrategy) { |
|
1043 |
this.cacheStrategy = iReferenceBaseCacheStrategy; |
|
1044 |
|
|
1045 |
} |
|
1046 |
|
|
1047 |
|
|
1048 |
|
|
1049 |
|
|
1050 |
// @Override |
|
1051 |
// protected void initListener(){ |
|
1052 |
// PropertyChangeListener listener = new PropertyChangeListener() { |
|
1053 |
// @Override |
|
1054 |
// public void propertyChange(PropertyChangeEvent e) { |
|
1055 |
// boolean protectedByLowerCache = false; |
|
1056 |
// //authorship cache |
|
1057 |
// if (fieldHasCacheUpdateProperty(e.getPropertyName(), "authorshipCache")){ |
|
1058 |
// if (protectedAuthorshipCache){ |
|
1059 |
// protectedByLowerCache = true; |
|
1060 |
// }else{ |
|
1061 |
// authorshipCache = null; |
|
1062 |
// } |
|
1063 |
// } |
|
1064 |
// |
|
1065 |
// //title cache |
|
1066 |
// if (! fieldHasNoUpdateProperty(e.getPropertyName(), "titleCache")){ |
|
1067 |
// if (isProtectedTitleCache()|| protectedByLowerCache == true ){ |
|
1068 |
// protectedByLowerCache = true; |
|
1069 |
// }else{ |
|
1070 |
// titleCache = null; |
|
1071 |
// } |
|
1072 |
// } |
|
1073 |
// //full title cache |
|
1074 |
// if (! fieldHasNoUpdateProperty(e.getPropertyName(), "fullTitleCache")){ |
|
1075 |
// if (isProtectedFullTitleCache()|| protectedByLowerCache == true ){ |
|
1076 |
// protectedByLowerCache = true; |
|
1077 |
// }else{ |
|
1078 |
// fullTitleCache = null; |
|
1079 |
// } |
|
1080 |
// } |
|
1081 |
// } |
|
1082 |
// }; |
|
1083 |
// addPropertyChangeListener(listener); //didn't use this.addXXX to make lsid.AssemblerTest run in cdmlib-remote |
|
1084 |
// } |
|
1085 |
|
|
1086 | 1026 |
|
1087 | 1027 |
//*********************** CLONE ********************************************************/ |
1088 | 1028 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/ReferenceFactory.java | ||
---|---|---|
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.TeamOrPersonBase; |
|
15 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
16 |
|
|
17 |
public class ReferenceFactory { |
|
18 |
private static final Logger logger = Logger.getLogger(ReferenceFactory.class); |
|
19 |
|
|
20 |
public static Reference newArticle(){ |
|
21 |
Reference article = new Reference(ReferenceType.Article); |
|
22 |
article.setCacheStrategy(ReferenceType.Article.getCacheStrategy()); |
|
23 |
return article; |
|
24 |
} |
|
25 |
|
|
26 |
public static Reference newJournal(){ |
|
27 |
Reference journal = new Reference(ReferenceType.Journal); |
|
28 |
journal.setCacheStrategy(ReferenceType.Journal.getCacheStrategy()); |
|
29 |
return journal; |
|
30 |
} |
|
31 |
|
|
32 |
public static Reference newBook(){ |
|
33 |
Reference book = new Reference(ReferenceType.Book); |
|
34 |
book.setCacheStrategy(ReferenceType.Book.getCacheStrategy()); |
|
35 |
return book; |
|
36 |
} |
|
37 |
|
|
38 |
public static Reference newThesis(){ |
|
39 |
Reference thesis = new Reference(ReferenceType.Thesis); |
|
40 |
thesis.setCacheStrategy(ReferenceType.Thesis.getCacheStrategy()); |
|
41 |
return thesis; |
|
42 |
} |
|
43 |
|
|
44 |
public static Reference newInProceedings(){ |
|
45 |
Reference inProceedings = new Reference(ReferenceType.InProceedings); |
|
46 |
inProceedings.setCacheStrategy(ReferenceType.InProceedings.getCacheStrategy()); |
|
47 |
return inProceedings; |
|
48 |
} |
|
49 |
|
|
50 |
public static Reference newProceedings(){ |
|
51 |
Reference proceedings = new Reference(ReferenceType.Proceedings); |
|
52 |
proceedings.setCacheStrategy(ReferenceType.Proceedings.getCacheStrategy()); |
|
53 |
return proceedings; |
|
54 |
} |
|
55 |
|
|
56 |
public static Reference newBookSection(){ |
|
57 |
Reference bookSection = new Reference(ReferenceType.BookSection); |
|
58 |
bookSection.setCacheStrategy(ReferenceType.BookSection.getCacheStrategy()); |
|
59 |
return bookSection; |
|
60 |
} |
|
61 |
|
|
62 |
|
|
63 |
public static Reference newSection(){ |
|
64 |
Reference section = new Reference(ReferenceType.Section); |
|
65 |
section.setCacheStrategy(ReferenceType.Section.getCacheStrategy()); |
|
66 |
return section; |
|
67 |
} |
|
68 |
|
|
69 |
public static Reference newCdDvd(){ |
|
70 |
Reference cdDvd= new Reference(ReferenceType.CdDvd); |
|
71 |
cdDvd.setCacheStrategy(ReferenceType.CdDvd.getCacheStrategy()); |
|
72 |
return cdDvd; |
|
73 |
} |
|
74 |
|
|
75 |
public static Reference newGeneric(){ |
|
76 |
Reference generic = new Reference(ReferenceType.Generic); |
|
77 |
generic.setCacheStrategy(ReferenceType.Generic.getCacheStrategy()); |
|
78 |
return generic; |
|
79 |
} |
|
80 |
|
|
81 |
public static Reference newMap(){ |
|
82 |
Reference map = new Reference(ReferenceType.Map); |
|
83 |
map.setCacheStrategy(ReferenceType.Map.getCacheStrategy()); |
|
84 |
return map; |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
public static Reference newReport(){ |
|
89 |
Reference report = new Reference(ReferenceType.Report); |
|
90 |
report.setCacheStrategy(ReferenceType.Report.getCacheStrategy()); |
|
91 |
return report; |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
public static Reference newWebPage(){ |
|
96 |
Reference webPage = new Reference(ReferenceType.WebPage); |
|
97 |
webPage.setCacheStrategy(ReferenceType.WebPage.getCacheStrategy()); |
|
98 |
return webPage; |
|
99 |
} |
|
100 |
|
|
101 |
public static Reference newDatabase(){ |
|
102 |
Reference db = new Reference(ReferenceType.Database); |
|
103 |
db.setCacheStrategy(ReferenceType.Database.getCacheStrategy()); |
|
104 |
return db; |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
/** |
|
109 |
* Creates a new empty print series instance. |
|
110 |
*/ |
|
111 |
public static Reference newPrintSeries() { |
|
112 |
Reference refBase = new Reference(ReferenceType.PrintSeries); |
|
113 |
refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy()); |
|
114 |
return refBase; |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
public static Reference newPersonalCommunication() { |
|
119 |
Reference personalCommunication = new Reference(ReferenceType.PersonalCommunication); |
|
120 |
personalCommunication.setCacheStrategy(ReferenceType.PersonalCommunication.getCacheStrategy()); |
|
121 |
return personalCommunication; |
|
122 |
} |
|
123 |
|
|
124 |
public static Reference newPatent() { |
|
125 |
Reference patent = new Reference(ReferenceType.Patent); |
|
126 |
patent.setCacheStrategy(ReferenceType.Patent.getCacheStrategy()); |
|
127 |
return patent; |
|
128 |
} |
|
129 |
|
|
130 |
// ******************** Short cuts **********************************************/ |
|
131 |
|
|
132 |
/** |
|
133 |
* Creates a new print series instance with a given title string. |
|
134 |
*/ |
|
135 |
public static Reference newPrintSeries(String series) { |
|
136 |
Reference refBase = newPrintSeries(); |
|
137 |
refBase.setTitle(series); |
|
138 |
refBase.setCacheStrategy(ReferenceType.PrintSeries.getCacheStrategy()); |
|
139 |
return refBase; |
|
140 |
} |
|
141 |
|
|
142 |
public static Reference newBookSection(Reference book, TeamOrPersonBase partAuthor, |
|
143 |
String sectionTitle, String pages) { |
|
144 |
Reference bookSection = newBookSection(); |
|
145 |
bookSection.setInBook(book); |
|
146 |
bookSection.setAuthorship(partAuthor); |
|
147 |
bookSection.setTitle(sectionTitle); |
|
148 |
bookSection.setPages(pages); |
|
149 |
return bookSection; |
|
150 |
} |
|
151 |
|
|
152 |
public static Reference newArticle(Reference inJournal, TeamOrPersonBase partAuthor, |
|
153 |
String title, String pages, String seriesPart, String volume, TimePeriod datePublished) { |
|
154 |
IArticle article = newArticle(); |
|
155 |
article.setInReference(inJournal); |
|
156 |
article.setAuthorship(partAuthor); |
|
157 |
article.setTitle(title); |
|
158 |
article.setPages(pages); |
|
159 |
article.setVolume(volume); |
|
160 |
article.setSeriesPart(seriesPart); |
|
161 |
article.setDatePublished(datePublished); |
|
162 |
return (Reference)article; |
|
163 |
} |
|
164 |
|
|
165 |
//****************************** by Type **************************************/ |
|
166 |
|
|
167 |
/** |
|
168 |
* Returns a new reference for the according reference type. If reference type is <code>null</code>, |
|
169 |
* <code>null</code> is returned. |
|
170 |
* @param referenceType |
|
171 |
* @return |
|
172 |
*/ |
|
173 |
public static Reference newReference(ReferenceType referenceType) { |
|
174 |
if (referenceType == null){ |
|
175 |
return null; |
|
176 |
} |
|
177 |
switch(referenceType){ |
|
178 |
case Article: |
|
179 |
return newArticle(); |
|
180 |
case Journal: |
|
181 |
return newJournal(); |
|
182 |
case BookSection: |
|
183 |
return newBookSection(); |
|
184 |
case CdDvd: |
|
185 |
return newCdDvd(); |
|
186 |
case Database: |
|
187 |
return newDatabase(); |
|
188 |
case InProceedings: |
|
189 |
return newInProceedings(); |
|
190 |
case Map: |
|
191 |
return newMap(); |
|
192 |
case Patent: |
|
193 |
return newPatent(); |
|
194 |
case PersonalCommunication: |
|
195 |
return newPersonalCommunication(); |
|
196 |
case PrintSeries: |
|
197 |
return newPrintSeries(); |
|
198 |
case Proceedings: |
|
199 |
return newProceedings(); |
|
200 |
case Report: |
|
201 |
return newReport(); |
|
202 |
case Thesis: |
|
203 |
return newThesis(); |
|
204 |
case WebPage: |
|
205 |
return newWebPage(); |
|
206 |
case Book: |
|
207 |
return newBook(); |
|
208 |
case Generic: |
|
209 |
return newGeneric(); |
|
210 |
case Section: |
|
211 |
return newSection(); |
|
212 |
default: |
|
213 |
logger.warn("Unknown reference type " + referenceType.getMessage() + ". Created generic reference instead."); |
|
214 |
return newGeneric(); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
} |
|
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.TeamOrPersonBase; |
|
15 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
16 |
|
|
17 |
public class ReferenceFactory { |
|
18 |
private static final Logger logger = Logger.getLogger(ReferenceFactory.class); |
|
19 |
|
|
20 |
public static Reference newArticle(){ |
|
21 |
return new Reference(ReferenceType.Article); |
|
22 |
} |
|
23 |
|
|
24 |
public static Reference newJournal(){ |
|
25 |
return new Reference(ReferenceType.Journal); |
|
26 |
} |
|
27 |
|
|
28 |
public static Reference newBook(){ |
|
29 |
return new Reference(ReferenceType.Book); |
|
30 |
} |
|
31 |
|
|
32 |
public static Reference newThesis(){ |
|
33 |
return new Reference(ReferenceType.Thesis); |
|
34 |
} |
|
35 |
|
|
36 |
public static Reference newInProceedings(){ |
|
37 |
return new Reference(ReferenceType.InProceedings); |
|
38 |
} |
|
39 |
|
|
40 |
public static Reference newProceedings(){ |
|
41 |
return new Reference(ReferenceType.Proceedings); |
|
42 |
} |
|
43 |
|
|
44 |
public static Reference newBookSection(){ |
|
45 |
return new Reference(ReferenceType.BookSection); |
|
46 |
} |
|
47 |
|
|
48 |
public static Reference newSection(){ |
|
49 |
return new Reference(ReferenceType.Section); |
|
50 |
} |
|
51 |
|
|
52 |
public static Reference newCdDvd(){ |
|
53 |
return new Reference(ReferenceType.CdDvd); |
|
54 |
} |
|
55 |
|
|
56 |
public static Reference newGeneric(){ |
|
57 |
return new Reference(ReferenceType.Generic); |
|
58 |
} |
|
59 |
|
|
60 |
public static Reference newMap(){ |
|
61 |
return new Reference(ReferenceType.Map); |
|
62 |
} |
|
63 |
|
|
64 |
public static Reference newReport(){ |
|
65 |
return new Reference(ReferenceType.Report); |
|
66 |
} |
|
67 |
|
|
68 |
public static Reference newWebPage(){ |
|
69 |
return new Reference(ReferenceType.WebPage); |
|
70 |
} |
|
71 |
|
|
72 |
public static Reference newDatabase(){ |
|
73 |
return new Reference(ReferenceType.Database); |
|
74 |
} |
|
75 |
|
|
76 |
public static Reference newPrintSeries() { |
|
77 |
return new Reference(ReferenceType.PrintSeries); |
|
78 |
} |
|
79 |
|
|
80 |
public static Reference newPersonalCommunication() { |
|
81 |
return new Reference(ReferenceType.PersonalCommunication); |
|
82 |
} |
|
83 |
|
|
84 |
public static Reference newPatent() { |
|
85 |
return new Reference(ReferenceType.Patent); |
|
86 |
} |
|
87 |
|
|
88 |
// ******************** Short cuts **********************************************/ |
|
89 |
|
|
90 |
/** |
|
91 |
* Creates a new print series instance with a given title string. |
|
92 |
*/ |
|
93 |
public static Reference newPrintSeries(String series) { |
|
94 |
Reference refBase = newPrintSeries(); |
|
95 |
refBase.setTitle(series); |
|
96 |
return refBase; |
|
97 |
} |
|
98 |
|
|
99 |
public static Reference newBookSection(Reference book, TeamOrPersonBase partAuthor, |
|
100 |
String sectionTitle, String pages) { |
|
101 |
Reference bookSection = newBookSection(); |
|
102 |
bookSection.setInBook(book); |
|
103 |
bookSection.setAuthorship(partAuthor); |
|
104 |
bookSection.setTitle(sectionTitle); |
|
105 |
bookSection.setPages(pages); |
|
106 |
return bookSection; |
|
107 |
} |
|
108 |
|
|
109 |
public static Reference newArticle(Reference inJournal, TeamOrPersonBase partAuthor, |
|
110 |
String title, String pages, String seriesPart, String volume, TimePeriod datePublished) { |
|
111 |
IArticle article = newArticle(); |
|
112 |
article.setInReference(inJournal); |
|
113 |
article.setAuthorship(partAuthor); |
|
114 |
article.setTitle(title); |
|
115 |
article.setPages(pages); |
|
116 |
article.setVolume(volume); |
|
117 |
article.setSeriesPart(seriesPart); |
|
118 |
article.setDatePublished(datePublished); |
|
119 |
return (Reference)article; |
|
120 |
} |
|
121 |
|
|
122 |
//****************************** by Type **************************************/ |
|
123 |
|
|
124 |
/** |
|
125 |
* Returns a new reference for the according reference type. If reference type is <code>null</code>, |
|
126 |
* <code>null</code> is returned. |
|
127 |
* @param referenceType |
|
128 |
* @return |
|
129 |
*/ |
|
130 |
public static Reference newReference(ReferenceType referenceType) { |
|
131 |
if (referenceType == null){ |
|
132 |
return null; |
|
133 |
} |
|
134 |
switch(referenceType){ |
|
135 |
case Article: |
|
136 |
return newArticle(); |
|
137 |
case Journal: |
|
138 |
return newJournal(); |
|
139 |
case BookSection: |
|
140 |
return newBookSection(); |
|
141 |
case CdDvd: |
|
142 |
return newCdDvd(); |
|
143 |
case Database: |
|
144 |
return newDatabase(); |
|
145 |
case InProceedings: |
|
146 |
return newInProceedings(); |
|
147 |
case Map: |
|
148 |
return newMap(); |
|
149 |
case Patent: |
|
150 |
return newPatent(); |
|
151 |
case PersonalCommunication: |
|
152 |
return newPersonalCommunication(); |
|
153 |
case PrintSeries: |
|
154 |
return newPrintSeries(); |
|
155 |
case Proceedings: |
|
156 |
return newProceedings(); |
|
157 |
case Report: |
|
158 |
return newReport(); |
|
159 |
case Thesis: |
|
160 |
return newThesis(); |
|
161 |
case WebPage: |
|
162 |
return newWebPage(); |
|
163 |
case Book: |
|
164 |
return newBook(); |
|
165 |
case Generic: |
|
166 |
return newGeneric(); |
|
167 |
case Section: |
|
168 |
return newSection(); |
|
169 |
default: |
|
170 |
logger.warn("Unknown reference type " + referenceType.getMessage() + ". Created generic reference instead."); |
|
171 |
return newGeneric(); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/ReferenceType.java | ||
---|---|---|
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.INomenclaturalReferenceCacheStrategy; |
|
26 |
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceCacheStrategy; |
|
27 |
import eu.etaxonomy.cdm.strategy.cache.reference.NewDefaultReferenceCacheStrategy; |
|
28 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.ArticleDefaultCacheStrategy; |
|
29 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.BookDefaultCacheStrategy; |
|
30 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.BookSectionDefaultCacheStrategy; |
|
31 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.CdDvdDefaultCacheStrategy; |
|
32 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.GenericDefaultCacheStrategy; |
|
33 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.JournalDefaultCacheStrategy; |
|
34 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.ReferenceDefaultCacheStrategy; |
|
35 |
import eu.etaxonomy.cdm.strategy.cache.reference.old.ThesisDefaultCacheStrategy; |
|
36 |
|
|
37 |
|
|
38 |
/** |
|
39 |
* The reference type is used to define the type of a {@link Reference reference}.<BR> |
|
40 |
* When changing the type of a reference one must be careful with handling attached information. |
|
41 |
* E.g. changing the type of a reference from article to book section requires to either exchange |
|
42 |
* the in reference or to change the type of the in reference which may have further consequences. |
|
43 |
* |
|
44 |
* @author a.mueller |
|
45 |
* @created 20.09.2009 |
|
46 |
*/ |
|
47 |
|
|
48 |
//TODO hierarchies, see http://dev.e-taxonomy.eu/trac/ticket/3619 |
|
49 |
@XmlEnum |
|
50 |
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{ |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* A reference of type section is a part-of another reference. Section is a generalized type for all |
|
55 |
* references which are expected to be part of another reference (e.g. an article which is part of a journal, |
|
56 |
* a book section which is part of a book) or which may have an in-reference |
|
57 |
* such as books which may be part of a print series or websites which may be part of other websites. |
|
58 |
* <BR> |
|
59 |
* However, section as concrete type should only be used if no more specific type is available. |
|
60 |
* This is usually the case for parts of other sections such parts of articles, parts of book sections, or |
|
61 |
* similar cases). |
|
62 |
* |
|
63 |
* @see ISectionBase |
|
64 |
*/ |
|
65 |
@XmlEnumValue("Section") |
|
66 |
Section(UUID.fromString("98035142-ca82-46c5-bbef-ad225f668644"), "Section", "SEC", null, ReferenceDefaultCacheStrategy.class), |
|
67 |
|
|
68 |
//0 |
|
69 |
/** |
|
70 |
* Article in a journal. |
|
71 |
* Article is a specialization of {@link #Section}. |
|
72 |
*/ |
|
73 |
@XmlEnumValue("Article") |
|
74 |
Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", Section, ArticleDefaultCacheStrategy.class), |
|
75 |
//1 |
|
76 |
@XmlEnumValue("Book") |
|
77 |
Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", Section, BookDefaultCacheStrategy.class), |
|
78 |
//2 |
|
79 |
/** |
|
80 |
* A part in a book, e.g. a chapter. |
|
81 |
* BookSection is a specialization of {@link #Section} |
|
82 |
*/ |
|
83 |
@XmlEnumValue("Book Section") |
|
84 |
BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", Section, BookSectionDefaultCacheStrategy.class), |
|
85 |
//3 |
|
86 |
@XmlEnumValue("CD or DVD") |
|
87 |
CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null, CdDvdDefaultCacheStrategy.class), |
|
88 |
//4 |
|
89 |
@XmlEnumValue("Database") |
|
90 |
Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null, ReferenceDefaultCacheStrategy.class), |
|
91 |
//5 |
|
92 |
@XmlEnumValue("Generic") |
|
93 |
Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null, GenericDefaultCacheStrategy.class), |
|
94 |
//6 |
|
95 |
@XmlEnumValue("Inproceedings") |
|
96 |
InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", Section, ReferenceDefaultCacheStrategy.class), |
|
97 |
//7 |
|
98 |
@XmlEnumValue("Journal") |
|
99 |
Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null, JournalDefaultCacheStrategy.class), |
|
100 |
//8 |
|
101 |
@XmlEnumValue("Map") |
|
102 |
Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null, ReferenceDefaultCacheStrategy.class), |
|
103 |
//9 |
|
104 |
@XmlEnumValue("Patent") |
|
105 |
Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null, ReferenceDefaultCacheStrategy.class), |
|
106 |
//10 |
|
107 |
@XmlEnumValue("Personal Communication") |
|
108 |
PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null, ReferenceDefaultCacheStrategy.class), |
|
109 |
//11 |
|
110 |
@XmlEnumValue("Print Series") |
|
111 |
PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null, ReferenceDefaultCacheStrategy.class), |
|
112 |
//12 |
|
113 |
@XmlEnumValue("Proceedings") |
|
114 |
Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", Section, ReferenceDefaultCacheStrategy.class), |
|
115 |
//13 |
|
116 |
@XmlEnumValue("Report") |
|
117 |
Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null, ReferenceDefaultCacheStrategy.class), |
|
118 |
//14 |
|
119 |
@XmlEnumValue("Thesis") |
|
120 |
Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "THE", null, ThesisDefaultCacheStrategy.class), |
|
121 |
//15 |
|
122 |
@XmlEnumValue("Web Page") |
|
123 |
WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null, ReferenceDefaultCacheStrategy.class), |
|
124 |
|
|
125 |
; |
|
126 |
|
|
127 |
@SuppressWarnings("unused") |
|
128 |
private static final Logger logger = Logger.getLogger(ReferenceType.class); |
|
129 |
|
|
130 |
private Class<? extends IReferenceCacheStrategy> cacheStrategy; |
|
131 |
|
|
132 |
private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent, Class<? extends IReferenceCacheStrategy> cacheStrategy){ |
|
133 |
this.cacheStrategy = cacheStrategy; |
|
134 |
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent); |
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
public INomenclaturalReferenceCacheStrategy getCacheStrategy(){ |
|
139 |
// if (true){ |
|
140 |
return NewDefaultReferenceCacheStrategy.NewInstance(); |
|
141 |
// } |
|
142 |
// switch(this){ |
|
143 |
// case Article: |
|
144 |
// return ArticleDefaultCacheStrategy.NewInstance(); |
|
145 |
// case Book: |
|
146 |
// return BookDefaultCacheStrategy.NewInstance(); |
|
147 |
// case BookSection: |
|
148 |
// return BookSectionDefaultCacheStrategy.NewInstance(); |
|
149 |
// case CdDvd: |
|
150 |
// return CdDvdDefaultCacheStrategy.NewInstance(); |
|
151 |
// case Generic: |
|
152 |
// return GenericDefaultCacheStrategy.NewInstance(); |
|
153 |
// case Journal: |
|
154 |
// return JournalDefaultCacheStrategy.NewInstance(); |
|
155 |
// case Thesis: |
|
156 |
// return ThesisDefaultCacheStrategy.NewInstance(); |
|
157 |
// case Section: |
|
158 |
// return SectionDefaultCacheStrategy.NewInstance(); |
|
159 |
// case WebPage: |
|
160 |
// return WebPageDefaultCacheStrategy.NewInstance(); |
|
161 |
// default: |
|
162 |
// return ReferenceDefaultCacheStrategy.NewInstance(); |
|
163 |
// } |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* Returns true if references of this type have volume information. |
|
168 |
*/ |
|
169 |
public boolean isVolumeReference(){ |
|
170 |
return (this == Article || isPrintedUnit() || this == Generic); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Returns true if references of this type are publications (inheriting from |
|
175 |
* {@link IPublicationBase}) and therefore have a publisher and a publication place. |
|
176 |
*/ |
|
177 |
public boolean isPublication(){ |
|
178 |
return (this == CdDvd || this == Database || this == Generic |
|
179 |
|| this == Journal || isPrintedUnit() || this == PrintSeries |
|
180 |
|| this == Report || this == Thesis |
|
181 |
|| this == WebPage || this == Map); |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* Returns true if references of this type are printed units (inheriting from |
|
186 |
* {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string |
|
187 |
* representing the series (seriesPart). |
|
188 |
*/ |
|
189 |
public boolean isPrintedUnit(){ |
|
190 |
return (this == Book || this == Proceedings); |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
/** |
|
196 |
* Returns true if references of this type are parts of other references (inheriting from |
|
197 |
* {@link ISection}) and therefore may have an in-reference and pages. |
|
198 |
*/ |
|
199 |
public boolean isSection(){ |
|
200 |
// return (this == BookSection || this == InProceedings |
|
201 |
// || isPrintedUnit() || this == Article ); |
|
202 |
return this == Section || isKindOf(Section); |
|
203 |
} |
|
204 |
|
|
205 |
// *************************** DELEGATE **************************************/ |
|
206 |
|
|
207 |
private static EnumeratedTermVoc<ReferenceType> delegateVoc; |
|
208 |
private IEnumTerm<ReferenceType> delegateVocTerm; |
|
209 |
|
|
210 |
static { |
|
211 |
delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class); |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public String getKey(){return delegateVocTerm.getKey();} |
|
216 |
|
|
217 |
@Override |
|
218 |
public String getMessage(){return delegateVocTerm.getMessage();} |
|
219 |
|
|
220 |
@Override |
|
221 |
public String getMessage(Language language){return delegateVocTerm.getMessage(language);} |
|
222 |
|
|
223 |
@Override |
|
224 |
public UUID getUuid() {return delegateVocTerm.getUuid();} |
|
225 |
|
|
226 |
@Override |
|
227 |
public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();} |
|
228 |
|
|
229 |
@Override |
|
230 |
public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();} |
|
231 |
|
|
232 |
@Override |
|
233 |
public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor); } |
|
234 |
|
|
235 |
@Override |
|
236 |
public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);} |
|
237 |
|
|
238 |
public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);} |
|
239 |
public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);} |
|
240 |
|
|
241 |
|
|
242 |
} |
|
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 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* The reference type is used to define the type of a {@link Reference reference}.<BR> |
|
29 |
* When changing the type of a reference one must be careful with handling attached information. |
|
30 |
* E.g. changing the type of a reference from article to book section requires to either exchange |
|
31 |
* the in reference or to change the type of the in reference which may have further consequences. |
|
32 |
* |
|
33 |
* @author a.mueller |
|
34 |
* @created 20.09.2009 |
|
35 |
*/ |
|
36 |
|
|
37 |
//TODO hierarchies, see http://dev.e-taxonomy.eu/trac/ticket/3619 |
|
38 |
@XmlEnum |
|
39 |
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{ |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* A reference of type section is a part-of another reference. Section is a generalized type for all |
|
44 |
* references which are expected to be part of another reference (e.g. an article which is part of a journal, |
|
45 |
* a book section which is part of a book) or which may have an in-reference |
|
46 |
* such as books which may be part of a print series or websites which may be part of other websites. |
|
47 |
* <BR> |
|
48 |
* However, section as concrete type should only be used if no more specific type is available. |
|
49 |
* This is usually the case for parts of other sections such parts of articles, parts of book sections, or |
|
50 |
* similar cases). |
|
51 |
* |
|
52 |
* @see ISectionBase |
|
53 |
*/ |
|
54 |
@XmlEnumValue("Section") |
|
55 |
Section(UUID.fromString("98035142-ca82-46c5-bbef-ad225f668644"), "Section", "SEC", null), |
|
56 |
|
|
57 |
//0 |
|
58 |
/** |
|
59 |
* Article in a journal. |
|
60 |
* Article is a specialization of {@link #Section}. |
|
61 |
*/ |
|
62 |
@XmlEnumValue("Article") |
|
63 |
Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", "ART", Section), |
|
64 |
//1 |
|
65 |
@XmlEnumValue("Book") |
|
66 |
Book(UUID.fromString("9280876c-accb-4c47-873d-46bbf4296f18"), "Book", "BK", Section), |
|
67 |
//2 |
|
68 |
/** |
|
69 |
* A part in a book, e.g. a chapter. |
|
70 |
* BookSection is a specialization of {@link #Section} |
|
71 |
*/ |
|
72 |
@XmlEnumValue("Book Section") |
|
73 |
BookSection(UUID.fromString("b197435d-deec-46fa-9c66-e0e6c44c57fb"), "Book Section", "BS", Section), |
|
74 |
//3 |
|
75 |
@XmlEnumValue("CD or DVD") |
|
76 |
CdDvd(UUID.fromString("7d7c9f56-d6fd-45aa-852f-b965afe08ec0"), "CD or DVD", "CD", null), |
|
77 |
//4 |
|
78 |
@XmlEnumValue("Database") |
|
79 |
Database(UUID.fromString("a36dbaec-0536-4a20-9fbc-e1b10ba35ea6"), "Database", "DB", null), |
|
80 |
//5 |
|
81 |
@XmlEnumValue("Generic") |
|
82 |
Generic(UUID.fromString("df149dd8-f2b4-421c-b478-acc4cce63f25"), "Generic", "GEN", null), |
|
83 |
//6 |
|
84 |
@XmlEnumValue("Inproceedings") |
|
85 |
InProceedings(UUID.fromString("a84dae35-6708-4c3d-8bb6-41b989947fa2"), "In Proceedings", "IPR", Section), |
|
86 |
//7 |
|
87 |
@XmlEnumValue("Journal") |
|
88 |
Journal(UUID.fromString("d8675c58-41cd-44fb-86be-e966bd4bc747"), "Journal", "JOU", null), |
|
89 |
//8 |
|
90 |
@XmlEnumValue("Map") |
|
91 |
Map(UUID.fromString("f4acc990-a277-4d80-9192-bc04be4b1cab"), "Map", "MAP", null), |
|
92 |
//9 |
|
93 |
@XmlEnumValue("Patent") |
|
94 |
Patent(UUID.fromString("e44e0e6b-a721-417c-9b03-01926ea0bf56"), "Patent", "PAT", null), |
|
95 |
//10 |
|
96 |
@XmlEnumValue("Personal Communication") |
|
97 |
PersonalCommunication(UUID.fromString("4ba5607e-1b9d-473c-89dd-8f1c2d27ae50"), "Personal Communication", "PEC", null), |
|
98 |
//11 |
|
99 |
@XmlEnumValue("Print Series") |
|
100 |
PrintSeries(UUID.fromString("d455f30d-2685-4f57-804a-3df5ba4e0888"), "Print Series", "SER", null), |
|
101 |
//12 |
|
102 |
@XmlEnumValue("Proceedings") |
|
103 |
Proceedings(UUID.fromString("cd934865-cb25-41f1-a155-f344ccb0c57f"), "Proceedings", "PRO", Section), |
|
104 |
//13 |
|
105 |
@XmlEnumValue("Report") |
|
106 |
Report(UUID.fromString("4d5459b8-b65b-47cb-9579-2fe7be360d04"), "Report", "REP", null), |
|
107 |
//14 |
|
108 |
@XmlEnumValue("Thesis") |
|
109 |
Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", "THE", null), |
|
110 |
//15 |
|
111 |
@XmlEnumValue("Web Page") |
|
112 |
WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", "WEB", null), |
|
113 |
|
|
114 |
; |
|
115 |
|
|
116 |
@SuppressWarnings("unused") |
|
117 |
private static final Logger logger = Logger.getLogger(ReferenceType.class); |
|
118 |
|
|
119 |
|
|
120 |
private ReferenceType(UUID uuid, String defaultString, String key, ReferenceType parent){ |
|
121 |
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent); |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Returns true if references of this type have volume information. |
|
126 |
*/ |
|
127 |
public boolean isVolumeReference(){ |
|
128 |
return (this == Article || isPrintedUnit() || this == Generic); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Returns true if references of this type are publications (inheriting from |
|
133 |
* {@link IPublicationBase}) and therefore have a publisher and a publication place. |
|
134 |
*/ |
|
135 |
public boolean isPublication(){ |
|
136 |
return (this == CdDvd || this == Database || this == Generic |
|
137 |
|| this == Journal || isPrintedUnit() || this == PrintSeries |
|
138 |
|| this == Report || this == Thesis |
|
139 |
|| this == WebPage || this == Map); |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* Returns true if references of this type are printed units (inheriting from |
|
144 |
* {@link IPrintedUnitBase}) and therefore may have an editor, an in-series or an string |
|
145 |
* representing the series (seriesPart). |
|
146 |
*/ |
|
147 |
public boolean isPrintedUnit(){ |
|
148 |
return (this == Book || this == Proceedings); |
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
/** |
|
154 |
* Returns true if references of this type are parts of other references (inheriting from |
|
155 |
* {@link ISection}) and therefore may have an in-reference and pages. |
|
156 |
*/ |
|
157 |
public boolean isSection(){ |
|
158 |
// return (this == BookSection || this == InProceedings |
|
159 |
// || isPrintedUnit() || this == Article ); |
|
160 |
return this == Section || isKindOf(Section); |
|
161 |
} |
|
162 |
|
|
163 |
// *************************** DELEGATE **************************************/ |
|
164 |
|
|
165 |
private static EnumeratedTermVoc<ReferenceType> delegateVoc; |
|
166 |
private IEnumTerm<ReferenceType> delegateVocTerm; |
|
167 |
|
|
168 |
static { |
|
169 |
delegateVoc = EnumeratedTermVoc.getVoc(ReferenceType.class); |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public String getKey(){return delegateVocTerm.getKey();} |
|
174 |
|
|
175 |
@Override |
|
176 |
public String getMessage(){return delegateVocTerm.getMessage();} |
|
177 |
|
|
178 |
@Override |
|
179 |
public String getMessage(Language language){return delegateVocTerm.getMessage(language);} |
|
180 |
|
|
181 |
@Override |
|
182 |
public UUID getUuid() {return delegateVocTerm.getUuid();} |
|
183 |
|
|
184 |
@Override |
|
185 |
public ReferenceType getKindOf() {return delegateVocTerm.getKindOf();} |
|
186 |
|
|
187 |
@Override |
|
188 |
public Set<ReferenceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();} |
|
189 |
|
|
190 |
@Override |
|
191 |
public boolean isKindOf(ReferenceType ancestor) {return delegateVocTerm.isKindOf(ancestor); } |
|
192 |
|
|
193 |
@Override |
|
194 |
public Set<ReferenceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);} |
|
195 |
|
|
196 |
public static ReferenceType getByKey(String key){return delegateVoc.getByKey(key);} |
|
197 |
public static ReferenceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);} |
|
198 |
|
|
199 |
|
|
200 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategy.java | ||
---|---|---|
337 | 337 |
String referenceCache = null; |
338 | 338 |
if (ref != null){ |
339 | 339 |
Reference reference = HibernateProxyHelper.deproxy(ref, Reference.class); |
340 |
//FIXME #5833 not needed anymore |
|
341 |
reference.setCacheStrategy(reference.getType().getCacheStrategy()); |
|
342 | 340 |
referenceCache = reference.getNomenclaturalCitation(microReference); |
343 | 341 |
} |
344 | 342 |
//add to tags |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/old/SectionDefaultCacheStrategy.java | ||
---|---|---|
15 | 15 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
16 | 16 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
17 | 17 |
import eu.etaxonomy.cdm.model.reference.Reference; |
18 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
|
19 | 18 |
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceCacheStrategy; |
20 | 19 |
|
21 | 20 |
public class SectionDefaultCacheStrategy extends InRefDefaultCacheStrategyBase { |
... | ... | |
80 | 79 |
inRefStrategy= inRef.getCacheStrategy(); |
81 | 80 |
if (! (inRefStrategy instanceof NomRefDefaultCacheStrategyBase)){ |
82 | 81 |
logger.warn("Neither inReference nor inInReference is a nomenclatural reference. This is not correct or not handled yet. Generic Cache Strategy used instead"); |
83 |
inRefStrategy = ReferenceType.Generic.getCacheStrategy();
|
|
82 |
inRefStrategy = GenericDefaultCacheStrategy.NewInstance();
|
|
84 | 83 |
result = ((NomRefDefaultCacheStrategyBase)inRefStrategy).getTitleWithoutYearAndAuthor(inInRef, true); |
85 |
//FIXME: vol. etc., http://dev.e-taxonomy.eu/trac/ticket/2862 (comment taken from super.getTokenizedNomenclaturalTitel())
|
|
84 |
//FIXME: vol. etc., #5833 (comment taken from super.getTokenizedNomenclaturalTitel())
|
|
86 | 85 |
}else{ |
87 | 86 |
result = ((NomRefDefaultCacheStrategyBase)inRefStrategy).getTitleWithoutYearAndAuthor(inRef, true); |
88 | 87 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/NewDefaultReferenceCacheStrategyTest.java | ||
---|---|---|
90 | 90 |
public void setUp() throws Exception { |
91 | 91 |
//article |
92 | 92 |
article1 = ReferenceFactory.newArticle(); |
93 |
article1.setCacheStrategy(defaultStrategy); |
|
94 | 93 |
journal1 = ReferenceFactory.newJournal(); |
95 |
journal1.setCacheStrategy(defaultStrategy); |
|
96 | 94 |
articleTeam1 = Team.NewInstance(); |
97 | 95 |
articleTeam2 = Team.NewInstance(); |
98 | 96 |
articleTeam1.setTitleCache("Team1", true); |
... | ... | |
102 | 100 |
|
103 | 101 |
//book / section |
104 | 102 |
book1 = ReferenceFactory.newBook(); |
105 |
book1.setCacheStrategy(defaultStrategy); |
|
106 | 103 |
bookTeam1 = Team.NewTitledInstance("Book Author", "TT."); |
107 | 104 |
bookSection1 = ReferenceFactory.newBookSection(); |
108 | 105 |
bookSection1.setCacheStrategy(defaultStrategy); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/old/ArticleDefaultCacheStrategyTest.java | ||
---|---|---|
55 | 55 |
@Before |
56 | 56 |
public void setUp() throws Exception { |
57 | 57 |
article1 = ReferenceFactory.newArticle(); |
58 |
article1.setCacheStrategy(defaultStrategy); |
|
59 | 58 |
journal1 = ReferenceFactory.newJournal(); |
60 | 59 |
team1 = Team.NewInstance(); |
61 | 60 |
team2 = Team.NewInstance(); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/old/BookSectionDefaultCacheStrategyTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2009 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.strategy.cache.reference.old; |
11 | 11 |
|
12 | 12 |
|
13 |
import org.junit.Assert; |
|
14 |
|
|
15 | 13 |
import org.apache.log4j.Logger; |
14 |
import org.junit.Assert; |
|
16 | 15 |
import org.junit.Before; |
17 | 16 |
import org.junit.BeforeClass; |
18 | 17 |
import org.junit.Ignore; |
... | ... | |
32 | 31 |
public class BookSectionDefaultCacheStrategyTest { |
33 | 32 |
@SuppressWarnings("unused") |
34 | 33 |
private static final Logger logger = Logger.getLogger(BookSectionDefaultCacheStrategyTest.class); |
35 |
|
|
34 |
|
|
36 | 35 |
private static IBookSection bookSection1; |
37 | 36 |
private static IBook book1; |
38 | 37 |
private static Team sectionTeam1; |
39 | 38 |
private static Team bookTeam1; |
40 | 39 |
private static BookSectionDefaultCacheStrategy defaultStrategy; |
41 | 40 |
private static final String detail1 = "55"; |
42 |
|
|
41 |
|
|
43 | 42 |
/** |
44 | 43 |
* @throws java.lang.Exception |
45 | 44 |
*/ |
... | ... | |
54 | 53 |
@Before |
55 | 54 |
public void setUp() throws Exception { |
56 | 55 |
bookSection1 = ReferenceFactory.newBookSection(); |
57 |
bookSection1.setCacheStrategy(defaultStrategy); |
|
58 | 56 |
book1 = ReferenceFactory.newBook(); |
59 | 57 |
sectionTeam1 = Team.NewTitledInstance("Section Author", "T."); |
60 | 58 |
bookTeam1 = Team.NewTitledInstance("Book Author", "TT."); |
61 | 59 |
} |
62 |
|
|
60 |
|
|
63 | 61 |
//**************************** TESTS *********************************** |
64 | 62 |
|
65 |
|
|
63 |
|
|
66 | 64 |
@Test |
67 | 65 |
public void testGetTitleCache(){ |
68 | 66 |
book1.setTitle("My book"); |
... | ... | |
85 | 83 |
book1.setTitleCache(null, false); |
86 | 84 |
book1.setSeriesPart("2"); |
87 | 85 |
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache()); |
88 |
|
|
86 |
|
|
89 | 87 |
bookSection1.setInBook(null); |
90 | 88 |
bookSection1.setTitleCache(null, false); |
91 | 89 |
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in - undefined book -. 1976", bookSection1.getTitleCache()); |
92 |
|
|
90 |
|
|
93 | 91 |
} |
94 |
|
|
92 |
|
|
95 | 93 |
@Ignore |
96 | 94 |
@Test |
97 | 95 |
//This test is just to show that there is still the title cache bug which is not |
... | ... | |
109 | 107 |
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache()); |
110 | 108 |
book1.setDatePublished(TimePeriod.NewInstance(1977)); |
111 | 109 |
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache()); |
112 |
|
|
113 |
|
|
110 |
|
|
111 |
|
|
114 | 112 |
bookSection1.setInBook(null); |
115 | 113 |
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in - undefined book -. 1976", bookSection1.getTitleCache()); |
116 |
|
|
114 |
|
|
117 | 115 |
} |
118 | 116 |
|
119 |
|
|
117 |
|
|
120 | 118 |
@Test |
121 | 119 |
public void testGetNomenclaturalCitation(){ |
122 | 120 |
book1.setTitle("My book"); |
... | ... | |
128 | 126 |
//TODO still unclear which is correct |
129 | 127 |
// Assert.assertEquals("in Book Author, My book: 55. 1975", bookSection1.getNomenclaturalCitation(detail1)); |
130 | 128 |
Assert.assertEquals("in TT., My book: 55. 1975", bookSection1.getNomenclaturalCitation(detail1)); |
131 |
|
|
129 |
|
|
132 | 130 |
book1.setSeriesPart("2"); |
133 | 131 |
Assert.assertEquals("in TT., My book, ser. 2: 55. 1975", bookSection1.getNomenclaturalCitation(detail1)); |
134 | 132 |
} |
135 |
|
|
133 |
|
|
136 | 134 |
@Test |
137 | 135 |
public void testRealExample(){ |
138 | 136 |
Team bookTeam = Team.NewTitledInstance("Chaudhary S. A.(ed.)", "Chaudhary S. A.(ed.)"); |
... | ... | |
143 | 141 |
book.setPlacePublished("Riyadh"); |
144 | 142 |
book.setPublisher("National Herbarium"); |
145 | 143 |
book.setDatePublished(TimePeriod.NewInstance(2000)); |
146 |
|
|
144 |
|
|
147 | 145 |
Team sectionTeam = Team.NewTitledInstance("Chaudhary S. A.", "Chaudhary S. A."); |
148 | 146 |
IBookSection bookSection = ReferenceFactory.newBookSection(); |
149 | 147 |
bookSection.setTitle("73. Hedypnois - 87. Crepis"); |
... | ... | |
151 | 149 |
bookSection.setAuthorship(sectionTeam); |
152 | 150 |
bookSection.setPages("222-251"); |
153 | 151 |
Assert.assertEquals("Chaudhary S. A. - 73. Hedypnois - 87. Crepis in Chaudhary S. A.(ed.), Flora of the Kingdom of Saudi Arabia 2(3). 2000", bookSection.getTitleCache()); |
154 |
|
|
152 |
|
|
155 | 153 |
} |
156 |
|
|
154 |
|
|
157 | 155 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/old/GenericDefaultCacheStrategyTest.java | ||
---|---|---|
51 | 51 |
@Before |
52 | 52 |
public void setUp() throws Exception { |
53 | 53 |
generic1 = ReferenceFactory.newGeneric(); |
54 |
generic1.setCacheStrategy(defaultStrategy); |
|
55 | 54 |
team1 = Team.NewTitledInstance("Authorteam", "AT."); |
56 | 55 |
} |
57 | 56 |
|
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/old/WebPageDefaultCacheStrategyTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2009 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
27 | 27 |
/** |
28 | 28 |
* @author a.mueller |
29 | 29 |
* @date 16.06.2010 |
30 |
*
|
|
30 |
* |
|
31 | 31 |
* UNDER CONSTRUCTION |
32 | 32 |
* |
33 | 33 |
*/ |
34 | 34 |
public class WebPageDefaultCacheStrategyTest { |
35 | 35 |
@SuppressWarnings("unused") |
36 | 36 |
private static final Logger logger = Logger.getLogger(WebPageDefaultCacheStrategyTest.class); |
37 |
|
|
37 |
|
|
38 | 38 |
private static IWebPage webPage1; |
39 | 39 |
private static Team team1; |
40 | 40 |
private static WebPageDefaultCacheStrategy defaultStrategy; |
41 | 41 |
private static final String detail1 = "55"; |
42 |
|
|
42 |
|
|
43 | 43 |
/** |
44 | 44 |
* @throws java.lang.Exception |
45 | 45 |
*/ |
... | ... | |
54 | 54 |
@Before |
55 | 55 |
public void setUp() throws Exception { |
56 | 56 |
webPage1 = ReferenceFactory.newWebPage(); |
57 |
webPage1.setCacheStrategy(defaultStrategy); |
|
58 | 57 |
team1 = Team.NewTitledInstance("Authorteam, D.", "AT."); |
59 | 58 |
} |
60 |
|
|
59 |
|
|
61 | 60 |
//**************************** TESTS *********************************** |
62 | 61 |
|
63 |
|
|
62 |
|
|
64 | 63 |
@Test |
65 | 64 |
@Ignore //under development |
66 | 65 |
public void testGetTitleCache(){ |
... | ... | |
71 | 70 |
//taken from Berlin Model, may be modified in future |
72 | 71 |
Assert.assertEquals("Unexpected title cache.", "Authorteam, D. - Flora of Israel Online - http://flora.huji.ac.il [accessed in 2011]", webPage1.getTitleCache()); |
73 | 72 |
} |
74 |
|
|
73 |
|
|
75 | 74 |
// @Test |
76 | 75 |
// //WebPages should usually not be used as nomencl.reference, therefore this is less important |
77 | 76 |
// public void testGetAbbrevTitleCache(){ |
Also available in: Unified diff
Further clean up reference cache strategies #5833