Project

General

Profile

Download (2.05 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.strategy.cache.agent;
11

    
12
import java.util.UUID;
13

    
14
import org.apache.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.common.CdmUtils;
17
import eu.etaxonomy.cdm.model.agent.Institution;
18
import eu.etaxonomy.cdm.model.occurrence.Collection;
19
import eu.etaxonomy.cdm.strategy.StrategyBase;
20
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
21

    
22
/**
23
 * A default cache strategy for institutions.
24
 * TODO This is a preliminary implementation to have at least one default cache strategy.
25
 * Maybe it will need improvement later on. 
26
 * @author a.mueller
27
 * @date 07.04.2010
28
 *
29
 */
30
public class InstitutionDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<Institution> {
31
	private static final long serialVersionUID = 4586884860596045736L;
32
	@SuppressWarnings("unused")
33
	private static final Logger logger = Logger.getLogger(Collection.class);
34
	
35
	public static UUID uuid = UUID.fromString("20a61a6f-aac9-422e-a95f-20dfacd35b65");
36
	
37
	
38
	/* (non-Javadoc)
39
	 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
40
	 */
41
	@Override
42
	protected UUID getUuid() {
43
		return uuid;
44
	}
45

    
46
	/* (non-Javadoc)
47
	 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.IdentifiableEntity)
48
	 */
49
	public String getTitleCache(Institution institution) {
50
		if (institution == null){
51
			return null;
52
		}else{
53
			String result = "";
54
			result = CdmUtils.concat("", result, institution.getName());
55
			//add code if it exists
56
			if (CdmUtils.isNotEmpty(institution.getCode())){
57
				if (CdmUtils.isNotEmpty(result)){
58
					result += " (" + institution.getCode() +")";
59
				}else{
60
					result = institution.getCode();
61
				}
62
			}
63
			//return
64
			return result;
65
		}
66
	}
67

    
68
}
(2-2/4)