Revision 4208745a
Added by Ben Clark over 15 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/Generic.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.model.reference; |
11 | 11 |
|
12 | 12 |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 | 13 |
import javax.persistence.Entity; |
17 |
import javax.persistence.FetchType; |
|
18 |
import javax.persistence.JoinColumn; |
|
19 |
import javax.persistence.OneToMany; |
|
20 | 14 |
import javax.persistence.Transient; |
21 | 15 |
import javax.xml.bind.annotation.XmlAccessType; |
22 | 16 |
import javax.xml.bind.annotation.XmlAccessorType; |
23 | 17 |
import javax.xml.bind.annotation.XmlElement; |
24 |
import javax.xml.bind.annotation.XmlElementRef; |
|
25 |
import javax.xml.bind.annotation.XmlElementWrapper; |
|
26 | 18 |
import javax.xml.bind.annotation.XmlRootElement; |
27 |
import javax.xml.bind.annotation.XmlTransient; |
|
28 | 19 |
import javax.xml.bind.annotation.XmlType; |
29 | 20 |
|
30 | 21 |
import org.apache.log4j.Logger; |
31 |
import org.hibernate.annotations.Cascade; |
|
32 |
import org.hibernate.annotations.CascadeType; |
|
33 |
import org.hibernate.annotations.IndexColumn; |
|
22 |
import org.hibernate.envers.Audited; |
|
23 |
import org.springframework.beans.factory.annotation.Configurable; |
|
34 | 24 |
|
35 | 25 |
import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy; |
26 |
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy; |
|
36 | 27 |
|
37 | 28 |
/** |
38 | 29 |
* This class represents all references which cannot be clearly assigned to a |
... | ... | |
63 | 54 |
}) |
64 | 55 |
@XmlRootElement(name = "Generic") |
65 | 56 |
@Entity |
66 |
public class Generic extends PublicationBase implements INomenclaturalReference, IVolumeReference, Cloneable { |
|
57 |
@Audited |
|
58 |
@Configurable |
|
59 |
public class Generic extends PublicationBase<INomenclaturalReferenceCacheStrategy<Generic>> implements INomenclaturalReference, IVolumeReference, Cloneable { |
|
67 | 60 |
private static final long serialVersionUID = -2547067957118035042L; |
68 | 61 |
private static final Logger logger = Logger.getLogger(Generic.class); |
69 | 62 |
|
... | ... | |
87 | 80 |
@XmlElement(name = "Pages") |
88 | 81 |
private String pages; |
89 | 82 |
|
90 |
@XmlTransient |
|
91 |
@Transient |
|
92 |
private NomenclaturalReferenceHelper nomRefBase = NomenclaturalReferenceHelper.NewInstance(this); |
|
83 |
// @XmlTransient
|
|
84 |
// @Transient
|
|
85 |
// private NomenclaturalReferenceHelper nomRefBase = NomenclaturalReferenceHelper.NewInstance(this);
|
|
93 | 86 |
|
94 | 87 |
|
95 | 88 |
/** |
... | ... | |
208 | 201 |
* @see #getNomenclaturalCitation(String) |
209 | 202 |
* @see StrictReferenceBase#getCitation() |
210 | 203 |
*/ |
211 |
@Override |
|
212 |
@Transient |
|
213 |
public String getCitation(){ |
|
214 |
return nomRefBase.getCitation(); |
|
215 |
} |
|
204 |
// @Override
|
|
205 |
// @Transient
|
|
206 |
// public String getCitation(){
|
|
207 |
// return nomRefBase.getCitation();
|
|
208 |
// }
|
|
216 | 209 |
|
217 | 210 |
/** |
218 | 211 |
* Returns a formatted string containing the entire citation used for |
... | ... | |
228 | 221 |
*/ |
229 | 222 |
@Transient |
230 | 223 |
public String getNomenclaturalCitation(String microReference) { |
231 |
return nomRefBase.getNomenclaturalCitation(microReference); |
|
224 |
if (cacheStrategy == null){ |
|
225 |
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid()); |
|
226 |
return null; |
|
227 |
}else{ |
|
228 |
return cacheStrategy.getNomenclaturalCitation(this,microReference); |
|
229 |
} |
|
232 | 230 |
} |
233 | 231 |
|
234 | 232 |
|
... | ... | |
248 | 246 |
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() |
249 | 247 |
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() |
250 | 248 |
*/ |
251 |
@Override |
|
252 |
public String generateTitle(){ |
|
253 |
return nomRefBase.generateTitle(); |
|
254 |
} |
|
249 |
// @Override
|
|
250 |
// public String generateTitle(){
|
|
251 |
// return nomRefBase.generateTitle();
|
|
252 |
// }
|
|
255 | 253 |
|
256 | 254 |
//*********** CLONE **********************************/ |
257 | 255 |
|
... | ... | |
269 | 267 |
@Override |
270 | 268 |
public Generic clone(){ |
271 | 269 |
Generic result = (Generic)super.clone(); |
272 |
result.nomRefBase = NomenclaturalReferenceHelper.NewInstance(result);
|
|
270 |
result.cacheStrategy = GenericDefaultCacheStrategy.NewInstance();
|
|
273 | 271 |
//no changes to: editor, pages, placePublished,publisher, series, volume |
274 | 272 |
return result; |
275 | 273 |
} |
Also available in: Unified diff
Lots of changes, but primarily:
Enabled the marshalling / unmarshalling of LSIDAuthority
Renamed the User table to UserAccount to avoid problems on SQLServer
Major refactoring of CacheStrategyGenerators so that the generic framework extends across all IIdentifiableEntities, allowing (but not requiring) the use of @Configurable and aop to inject custom cache strategy generators at runtime