Project

General

Profile

Download (3.81 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.reference.old;
10

    
11
import java.util.UUID;
12

    
13
import org.apache.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.model.common.CdmBase;
16
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
17
import eu.etaxonomy.cdm.model.reference.Reference;
18
import eu.etaxonomy.cdm.model.reference.ReferenceType;
19
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceCacheStrategy;
20

    
21
public class SectionDefaultCacheStrategy extends InRefDefaultCacheStrategyBase {
22
	private static final long serialVersionUID = -4534389083526558368L;
23
	private static final Logger logger = Logger.getLogger(SectionDefaultCacheStrategy.class);
24

    
25
	final static UUID uuid = UUID.fromString("a7150cd3-107b-4169-ac84-71ffe3219152");
26

    
27
	private static final String inRefTypeStr = "in reference";
28

    
29
	private static final boolean inRefIsObligatory = true;
30

    
31
	@Override
32
	protected UUID getUuid() {
33
		return uuid;
34
	}
35

    
36
	@Override
37
	protected String getInRefType() {
38
		return inRefTypeStr;
39
	}
40

    
41
	/**
42
	 * Factory method
43
	 * @return
44
	 */
45
	public static SectionDefaultCacheStrategy NewInstance(){
46
		return new SectionDefaultCacheStrategy();
47
	}
48

    
49
	/**
50
	 * Constructor
51
	 */
52
	private SectionDefaultCacheStrategy(){
53
		super();
54
	}
55

    
56
	@Override
57
	protected String getTitleWithoutYearAndAuthor(Reference reference, boolean isAbbrev) {
58
		// not needed in Section
59
		logger.warn("Questionable procedure call. Procedure not implemented because not needed. ");
60
		return null;
61
	}
62

    
63
	@Override
64
	public String getTokenizedNomenclaturalTitel(Reference section) {
65
		//generic == null
66
		if (section == null /* || generic.getInReference() == null */){
67
			return null;
68
		}
69
		Reference inRef = CdmBase.deproxy(section.getInReference(), Reference.class);
70
		if (inRef != null && inRef.getInReference() == null){
71
			//this is a simple inRef (not an in-in-Ref) which can be handled by InRefDefaultCacheStrategy
72
			return super.getTokenizedNomenclaturalTitel(section, inRefIsObligatory);
73
		}
74

    
75
		Reference inInRef = CdmBase.deproxy(inRef.getInReference(), Reference.class);
76
		String result;
77

    
78
		IReferenceCacheStrategy inRefStrategy = inInRef.getCacheStrategy();
79
		if (! (inRefStrategy instanceof NomRefDefaultCacheStrategyBase)){
80
			inRefStrategy= inRef.getCacheStrategy();
81
			if (! (inRefStrategy instanceof NomRefDefaultCacheStrategyBase)){
82
				logger.warn("Neither inReference nor inInReference is a nomenclatural reference. This is not correct or not handled yet. Generic Cache Strategy used instead");
83
				inRefStrategy = ReferenceType.Generic.getCacheStrategy();
84
				result = ((NomRefDefaultCacheStrategyBase)inRefStrategy).getTitleWithoutYearAndAuthor(inInRef, true);
85
				//FIXME: vol. etc., http://dev.e-taxonomy.eu/trac/ticket/2862  (comment taken from super.getTokenizedNomenclaturalTitel())
86
			}else{
87
				result = ((NomRefDefaultCacheStrategyBase)inRefStrategy).getTitleWithoutYearAndAuthor(inRef, true);
88
			}
89
		}else{
90
			result = ((NomRefDefaultCacheStrategyBase)inRefStrategy).getTitleWithoutYearAndAuthor(inInRef, true);
91
		}
92
		result += INomenclaturalReference.MICRO_REFERENCE_TOKEN;
93

    
94
		Reference dataReference = (section.hasDatePublished() ? section : inRef.hasDatePublished() ? inRef : inInRef);
95

    
96
		result = addYear(result, dataReference, true);
97

    
98
		result = getInRefAuthorPart(inInRef, afterInRefAuthor) + result;
99
		if (! result.startsWith("in ")){
100
			result = "in " +  result;
101
		}
102
		return result;
103
	}
104

    
105
	@Override
106
	public String getTitleCache(Reference thisRef) {
107
		return super.getTitleCache(thisRef, inRefIsObligatory, false);
108
	}
109

    
110
	@Override
111
	public String getFullAbbrevTitleString(Reference thisRef) {
112
		return super.getTitleCache(thisRef, inRefIsObligatory, true);
113
	}
114

    
115

    
116
}
(10-10/12)