1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.strategy.cache.occurrence;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
|
15
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
16
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
17
|
import eu.etaxonomy.cdm.strategy.StrategyBase;
|
18
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
19
|
|
20
|
/**
|
21
|
* A default cache strategy for collections.
|
22
|
* TODO This is a preliminary implementation to have at least one default cache strategy.
|
23
|
* Maybe it will need improvement later on.
|
24
|
|
25
|
* @author a.mueller
|
26
|
* @since 07.04.2010
|
27
|
*
|
28
|
*/
|
29
|
public class CollectionDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<Collection>{
|
30
|
private static final long serialVersionUID = 457142779236428472L;
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(CollectionDefaultCacheStrategy.class);
|
33
|
|
34
|
private static final UUID uuid = UUID.fromString("42834de1-698c-4d43-a31a-1c5617a708d6");
|
35
|
|
36
|
@Override
|
37
|
protected UUID getUuid() {
|
38
|
return uuid;
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public String getTitleCache(Collection collection) {
|
43
|
if (collection == null){
|
44
|
return null;
|
45
|
}else{
|
46
|
String result = "";
|
47
|
result = CdmUtils.concat("", result, collection.getName());
|
48
|
//add code if it exists
|
49
|
if (isNotBlank(collection.getCode())){
|
50
|
if (isNotBlank(result)){
|
51
|
result += " (" + collection.getCode() +")";
|
52
|
}else{
|
53
|
result = collection.getCode();
|
54
|
}
|
55
|
}
|
56
|
//return
|
57
|
return result;
|
58
|
}
|
59
|
}
|
60
|
}
|