Revision a5e64d94
Added by Andreas Müller almost 7 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/CollectionDefaultCacheStrategy.java | ||
---|---|---|
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 |
* @date 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 |
/* (non-Javadoc) |
|
37 |
* @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid() |
|
38 |
*/ |
|
39 |
@Override |
|
40 |
protected UUID getUuid() { |
|
41 |
return uuid; |
|
42 |
} |
|
43 |
|
|
44 |
/* (non-Javadoc) |
|
45 |
* @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.IdentifiableEntity) |
|
46 |
*/ |
|
47 |
public String getTitleCache(Collection collection) { |
|
48 |
if (collection == null){ |
|
49 |
return null; |
|
50 |
}else{ |
|
51 |
String result = ""; |
|
52 |
result = CdmUtils.concat("", result, collection.getName()); |
|
53 |
//add code if it exists |
|
54 |
if (CdmUtils.isNotEmpty(collection.getCode())){ |
|
55 |
if (CdmUtils.isNotEmpty(result)){ |
|
56 |
result += " (" + collection.getCode() +")"; |
|
57 |
}else{ |
|
58 |
result = collection.getCode(); |
|
59 |
} |
|
60 |
} |
|
61 |
//return |
|
62 |
return result; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
} |
|
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 |
|
|
62 |
|
|
63 |
|
|
64 |
} |
Also available in: Unified diff
cleanup