1
|
/**
|
2
|
* Copyright (C) 2009 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.agent;
|
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.agent.Institution;
|
17
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
18
|
import eu.etaxonomy.cdm.strategy.StrategyBase;
|
19
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
20
|
|
21
|
/**
|
22
|
* A default cache strategy for institutions.
|
23
|
* TODO This is a preliminary implementation to have at least one default cache strategy.
|
24
|
* Maybe it will need improvement later on.
|
25
|
* @author a.mueller
|
26
|
* @date 07.04.2010
|
27
|
*
|
28
|
*/
|
29
|
public class InstitutionDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<Institution> {
|
30
|
private static final long serialVersionUID = 4586884860596045736L;
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(Collection.class);
|
33
|
|
34
|
public static UUID uuid = UUID.fromString("20a61a6f-aac9-422e-a95f-20dfacd35b65");
|
35
|
|
36
|
|
37
|
/* (non-Javadoc)
|
38
|
* @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
|
39
|
*/
|
40
|
@Override
|
41
|
protected UUID getUuid() {
|
42
|
return uuid;
|
43
|
}
|
44
|
|
45
|
/* (non-Javadoc)
|
46
|
* @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.IdentifiableEntity)
|
47
|
*/
|
48
|
public String getTitleCache(Institution institution) {
|
49
|
if (institution == null){
|
50
|
return null;
|
51
|
}else{
|
52
|
String result = "";
|
53
|
result = CdmUtils.concat("", result, institution.getName());
|
54
|
//add code if it exists
|
55
|
if (CdmUtils.isNotEmpty(institution.getCode())){
|
56
|
if (CdmUtils.isNotEmpty(result)){
|
57
|
result += " (" + institution.getCode() +")";
|
58
|
}else{
|
59
|
result = institution.getCode();
|
60
|
}
|
61
|
}
|
62
|
//return
|
63
|
return result;
|
64
|
}
|
65
|
}
|
66
|
|
67
|
}
|