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
|
|
10
|
package eu.etaxonomy.cdm.strategy.cache.description;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
15
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
16
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
17
|
import eu.etaxonomy.cdm.strategy.StrategyBase;
|
18
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
19
|
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
|
20
|
|
21
|
public class PolytomousKeyDefaultCacheStrategy extends StrategyBase implements IIdentifiableEntityCacheStrategy<PolytomousKey> {
|
22
|
private static final long serialVersionUID = 4371087085809422025L;
|
23
|
final static UUID uuid = UUID.fromString("876c4247-bfc4-4303-b631-b2c1c4435571");
|
24
|
|
25
|
public static PolytomousKeyDefaultCacheStrategy NewInstance(){
|
26
|
return new PolytomousKeyDefaultCacheStrategy();
|
27
|
}
|
28
|
|
29
|
private PolytomousKeyDefaultCacheStrategy(){
|
30
|
}
|
31
|
|
32
|
@Override
|
33
|
protected UUID getUuid() {
|
34
|
return uuid;
|
35
|
}
|
36
|
|
37
|
public String getTitleCache(PolytomousKey key) {
|
38
|
String title;
|
39
|
if (key.getTaxonomicScope().size()>0){
|
40
|
String taxa = "";
|
41
|
for (Taxon taxon : key.getTaxonomicScope()){
|
42
|
taxa = CdmUtils.concat(",", taxa, taxon.getName().getTitleCache());
|
43
|
}
|
44
|
title = "Key for %s";
|
45
|
title = String.format(title, taxa);
|
46
|
}else{
|
47
|
title = new IdentifiableEntityDefaultCacheStrategy().getTitleCache(key);
|
48
|
}
|
49
|
return title;
|
50
|
}
|
51
|
|
52
|
// private String getFirstPart(TaxonDescription taxonDescription){
|
53
|
// if (taxonDescription.isImageGallery()){
|
54
|
// return "Image gallery for " ;
|
55
|
// }else {
|
56
|
// return "Taxon description for ";
|
57
|
// }
|
58
|
// }
|
59
|
}
|