2 * Copyright (C) 2009 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
.strategy
.cache
.common
;
11 import java
.util
.UUID
;
13 import org
.apache
.commons
.lang
.StringUtils
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
17 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
18 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
25 public class TermDefaultCacheStrategy
<T
extends TermBase
> extends IdentifiableEntityDefaultCacheStrategy
<T
> implements IIdentifiableEntityCacheStrategy
<T
> {
29 private static final long serialVersionUID
= 7687293307791110547L;
31 @SuppressWarnings("unused")
32 private static final Logger logger
= Logger
.getLogger(TermDefaultCacheStrategy
.class);
34 final static UUID uuid
= UUID
.fromString("9cdf52c1-bac4-4b6c-a7f9-1a87401bd8f9");
37 protected UUID
getUuid() {
42 public String
getTitleCache(T term
) {
44 if (term
.getRepresentations().size() > 0) {
45 //use default representation (or if not exist any other)
46 Representation representation
= term
.getRepresentation(Language
.DEFAULT());
47 if (representation
== null){
48 representation
= term
.getRepresentations().iterator().next();
50 //return label, or if not exists abbreviated label, of if not exists description
51 result
= representation
.getLabel();
52 if (StringUtils
.isBlank(result
)){
53 result
= representation
.getAbbreviatedLabel();
55 if (StringUtils
.isBlank(result
)){
56 result
= representation
.getText();
57 representation
.getDescription();
60 //if still empty return toString
61 if (StringUtils
.isBlank(result
)){
62 result
= term
.getClass().getSimpleName() + "<" + term
.getUuid() + ">";