Project

General

Profile

Download (3.54 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

    
10
package eu.etaxonomy.cdm.strategy.cache.name;
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.INomenclaturalAuthor;
18
import eu.etaxonomy.cdm.model.name.NonViralName;
19
import eu.etaxonomy.cdm.model.name.ZoologicalName;
20

    
21
public class ZooNameDefaultCacheStrategy <T extends ZoologicalName> extends NonViralNameDefaultCacheStrategy<T> implements  INonViralNameCacheStrategy<T> {
22
	@SuppressWarnings("unused")
23
	private static final Logger logger = Logger.getLogger(ZooNameDefaultCacheStrategy.class);
24
	
25
	final static UUID uuid = UUID.fromString("950c4236-8156-4675-b866-785df33bc4d9");
26

    
27
	protected String AuthorYearSeperator = ", ";
28
	
29
	@Override
30
	public UUID getUuid(){
31
		return uuid;
32
	}
33
	
34
	
35
	/**
36
	 * Factory method
37
	 * @return
38
	 */
39
	public static ZooNameDefaultCacheStrategy NewInstance(){
40
		return new ZooNameDefaultCacheStrategy();
41
	}
42
	
43
	/**
44
	 * Constructor
45
	 */
46
	private ZooNameDefaultCacheStrategy(){
47
		super();
48
	}
49

    
50
	
51

    
52
	/* (non-Javadoc)
53
	 * @see eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getNonCacheAuthorshipCache(eu.etaxonomy.cdm.model.name.NonViralName)
54
	 */
55
	@Override
56
	protected String getNonCacheAuthorshipCache(T nonViralName) {
57
		if (nonViralName == null){
58
			return null;
59
		}
60
		String result = "";
61
		INomenclaturalAuthor combinationAuthor = nonViralName.getCombinationAuthorTeam();
62
		INomenclaturalAuthor exCombinationAuthor = nonViralName.getExCombinationAuthorTeam();
63
		INomenclaturalAuthor basionymAuthor = nonViralName.getBasionymAuthorTeam();
64
		INomenclaturalAuthor exBasionymAuthor = nonViralName.getExBasionymAuthorTeam();
65
		Integer publicationYear = nonViralName.getPublicationYear();
66
		Integer originalPublicationYear = nonViralName.getOriginalPublicationYear();
67

    
68
		String basionymPart = "";
69
		String authorPart = "";
70
		//basionym
71
		if (basionymAuthor != null || exBasionymAuthor != null || originalPublicationYear != null ){
72
			String authorAndEx = getAuthorAndExAuthor(basionymAuthor, exBasionymAuthor);
73
			String originalPublicationYearString = originalPublicationYear == null ? null : String.valueOf(originalPublicationYear);
74
			String authorAndExAndYear = CdmUtils.concat(", ", authorAndEx, originalPublicationYearString );
75
			basionymPart = BasionymStart + authorAndExAndYear +BasionymEnd;
76
		}
77
		if (combinationAuthor != null || exCombinationAuthor != null){
78
			String authorAndEx = getAuthorAndExAuthor(combinationAuthor, exCombinationAuthor);
79
			String publicationYearString = publicationYear == null ? null : String.valueOf(publicationYear);
80
			authorPart = CdmUtils.concat(", ", authorAndEx, publicationYearString);
81
		}
82
		result = CdmUtils.concat(BasionymAuthorCombinationAuthorSeperator, basionymPart, authorPart);
83
		return result;
84
	}
85
	
86

    
87
	/**
88
	 * @return Strings that separates the author part and the year part
89
	 * @return
90
	 */
91
	public String getAuthorYearSeperator() {
92
		return AuthorYearSeperator;
93
	}
94

    
95

    
96
	public void setAuthorYearSeperator(String authorYearSeperator) {
97
		AuthorYearSeperator = authorYearSeperator;
98
	}
99
	
100
	protected String getInfraSpeciesNameCache(NonViralName nonViralName){
101
		boolean includeMarker = ! (nonViralName.isAutonym());
102
		return getInfraSpeciesNameCache(nonViralName, includeMarker);
103
	}
104

    
105
}
(8-8/8)