Project

General

Profile

Download (1.76 KB) Statistics
| Branch: | Tag: | Revision:
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.commons.lang.StringUtils;
14
import org.apache.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.common.CdmUtils;
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 collections.
23
 * TODO This is a preliminary implementation to have at least one default cache strategy.
24
 * Maybe it will need improvement later on.
25

    
26
 * @author a.mueller
27
 * @date 07.04.2010
28
 *
29
 */
30
public class CollectionDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<Collection>{
31
	private static final long serialVersionUID = 457142779236428472L;
32
	@SuppressWarnings("unused")
33
	private static final Logger logger = Logger.getLogger(CollectionDefaultCacheStrategy.class);
34

    
35
	private static final UUID uuid = UUID.fromString("42834de1-698c-4d43-a31a-1c5617a708d6");
36

    
37
	@Override
38
	protected UUID getUuid() {
39
		return uuid;
40
	}
41

    
42
	@Override
43
    public String getTitleCache(Collection collection) {
44
		if (collection == null){
45
			return null;
46
		}else{
47
			String result = "";
48
			result = CdmUtils.concat("", result, collection.getName());
49
			//add code if it exists
50
			if (StringUtils.isNotBlank(collection.getCode())){
51
				if (StringUtils.isNotBlank(result)){
52
					result += " (" + collection.getCode() +")";
53
				}else{
54
					result = collection.getCode();
55
				}
56
			}
57
			//return
58
			return result;
59
		}
60
	}
61
}
    (1-1/1)