1 package eu
.etaxonomy
.cdm
.api
.service
.util
;
3 import org
.apache
.log4j
.Logger
;
5 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
6 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
7 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
8 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
9 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
10 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
11 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
12 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
13 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
16 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
17 import eu
.etaxonomy
.cdm
.model
.term
.FeatureTree
;
18 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
19 import eu
.etaxonomy
.cdm
.strategy
.cache
.taxon
.TaxonBaseShortSecCacheStrategy
;
22 public class CacheUpdaterWithNewCacheStrategy
extends CacheUpdater
{
24 private static final long serialVersionUID
= 7667521864001167289L;
25 private static final Logger logger
= Logger
.getLogger(CacheUpdaterWithNewCacheStrategy
.class);
28 private boolean handleSingleTableClass(Class
<?
extends IdentifiableEntity
> clazz
) {
29 logger
.warn("Updating class " + clazz
.getSimpleName() + " ...");
32 if (DefinedTermBase
.class.isAssignableFrom(clazz
)){
33 termService
.updateCaches((Class
) clazz
, null, null, null);
34 }else if (FeatureTree
.class.isAssignableFrom(clazz
)){
35 featureTreeService
.updateCaches((Class
) clazz
, null, null, null);
36 }else if (TermVocabulary
.class.isAssignableFrom(clazz
)){
37 vocabularyService
.updateCaches((Class
) clazz
, null, null, null);
40 else if (DescriptionBase
.class.isAssignableFrom(clazz
)){
41 descriptionService
.updateCaches((Class
) clazz
, null, null, null);
44 else if (Media
.class.isAssignableFrom(clazz
)){
45 mediaService
.updateCaches((Class
) clazz
, null, null, null);
47 else if (TaxonBase
.class.isAssignableFrom(clazz
)){
48 TaxonBaseShortSecCacheStrategy
<TaxonBase
> cacheStrategy
= new TaxonBaseShortSecCacheStrategy
<TaxonBase
>();
49 taxonService
.updateCaches((Class
) clazz
, null,cacheStrategy
, null);
51 //IdentifiableMediaEntity
52 else if (AgentBase
.class.isAssignableFrom(clazz
)){
53 agentService
.updateCaches((Class
) clazz
, null, null, null);
54 }else if (Collection
.class.isAssignableFrom(clazz
)){
55 collectionService
.updateCaches((Class
) clazz
, null, null, null);
56 }else if (Reference
.class.isAssignableFrom(clazz
)){
57 referenceService
.updateCaches((Class
) clazz
, null, null, null);
58 }else if (SpecimenOrObservationBase
.class.isAssignableFrom(clazz
)){
59 occurrenceService
.updateCaches((Class
) clazz
, null, null, null);
63 else if (Sequence
.class.isAssignableFrom(clazz
)){
64 //TODO misuse TaxonServic for sequence update, use sequence service when it exists
65 taxonService
.updateCaches((Class
) clazz
, null, null, null);
68 else if (TaxonName
.class.isAssignableFrom(clazz
)){
69 nameService
.updateCaches((Class
) clazz
, null, null, null);
72 else if (Classification
.class.isAssignableFrom(clazz
)){
73 classificationService
.updateCaches((Class
) clazz
, null, null, null);
77 String warning
= "Unknown identifable entity subclass + " + clazz
.getName();
78 logger
.error(warning
);
80 //getTaxonService().updateTitleCache((Class) clazz);
83 } catch (Exception e
) {
84 String warning
= "Exception occurred when trying to update class + " + clazz
.getName();
85 warning
+= " Exception was: " + e
.getMessage();
86 logger
.error(warning
);