2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.api
.cache
;
11 import java
.util
.UUID
;
13 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
14 import org
.springframework
.stereotype
.Component
;
16 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
17 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
18 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
21 * CDM Entity Cacher class which handles the caching of Defined Terms.
26 public class CdmTermCacher
extends CdmCacherBase
{
29 private ITermService termService
;
32 protected void setup() {
33 DefinedTermBase
.setCacher(this);
37 protected CdmBase
findByUuid(UUID uuid
) {
38 return termService
.findWithoutFlush(uuid
);
42 public boolean isCachable(CdmBase cdmEntity
) {
43 if(cdmEntity
!= null && cdmEntity
instanceof DefinedTermBase
) {
50 public <T
extends CdmBase
> T
load(T cdmEntity
) {
52 T cachedCdmEntity
= getFromCache(cdmEntity
);
53 if(cachedCdmEntity
== null && isCachable(cdmEntity
)) {
54 putToCache(cdmEntity
);
55 cachedCdmEntity
= cdmEntity
;
57 return cachedCdmEntity
;