Revision bd4c6676
Added by Andreas Müller almost 3 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivedUnit.java | ||
---|---|---|
41 | 41 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
42 | 42 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
43 | 43 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
44 |
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
|
|
44 |
import eu.etaxonomy.cdm.strategy.cache.occurrence.DerivedUnitDefaultCacheStrategy;
|
|
45 | 45 |
|
46 | 46 |
/** |
47 | 47 |
* A derived unit is regarded as derived from a field unit, |
... | ... | |
231 | 231 |
field.setGatheringEvent(gatheringEvent); |
232 | 232 |
} |
233 | 233 |
|
234 |
private static final String facadeStrategyClassName = "eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy"; |
|
235 | 234 |
/** |
236 | 235 |
* Sets the default cache strategy |
237 | 236 |
*/ |
238 | 237 |
@Override |
239 | 238 |
protected void initDefaultCacheStrategy() { |
240 |
try { |
|
241 |
String facadeClassName = facadeStrategyClassName; |
|
242 |
Class<?> facadeClass = Class.forName(facadeClassName); |
|
243 |
try { |
|
244 |
this.cacheStrategy = (IIdentifiableEntityCacheStrategy)facadeClass.newInstance(); |
|
245 |
} catch (InstantiationException | IllegalAccessException e) { |
|
246 |
throw new RuntimeException("Cache strategy for DerivedUnit could not be instantiated", e); |
|
247 |
} |
|
248 |
} catch (ClassNotFoundException e) { |
|
249 |
this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<>(); |
|
239 |
this.cacheStrategy = new DerivedUnitDefaultCacheStrategy(); |
|
240 |
} |
|
241 |
|
|
242 |
@Override |
|
243 |
public String getTitleCache() { |
|
244 |
//specimen are complex and changes in other objects often, therefore we compute titleCache each time from scratch |
|
245 |
if (!this.protectedTitleCache){ |
|
246 |
this.titleCache = null; |
|
250 | 247 |
} |
248 |
return super.getTitleCache(); |
|
251 | 249 |
} |
252 | 250 |
|
253 | 251 |
// ******************** GETTER / SETTER *************************************/ |
Also available in: Unified diff
ref #9678 implement cache strategies for field unit and derived unti within cdmlib model