Project

General

Profile

Download (1.98 KB) Statistics
| Branch: | Tag: | Revision:
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.Set;
13
import java.util.UUID;
14

    
15
import eu.etaxonomy.cdm.model.common.Marker;
16
import eu.etaxonomy.cdm.model.common.MarkerType;
17
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
18
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
19
import eu.etaxonomy.cdm.strategy.StrategyBase;
20
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
21

    
22
public class SpecimenDescriptionDefaultCacheStrategy extends StrategyBase implements
23
		IIdentifiableEntityCacheStrategy<SpecimenDescription> {
24

    
25
	final static UUID uuid = UUID.fromString("73c03fc4-0429-4ca1-b2cb-b9a56aad4d22");
26
	
27
	@Override
28
	protected UUID getUuid() {
29
		return uuid;
30
	}
31

    
32
	public String getTitleCache(SpecimenDescription specimenDescription) {
33
		String title;
34
		SpecimenOrObservationBase specimen = specimenDescription.getDescribedSpecimenOrObservation(); 
35
		if (specimen == null){
36
			title = getFirstPart(specimenDescription);
37
			title = title.replace(" for ", "");
38
		}else{
39
			title = specimen.getTitleCache();
40
			title = getFirstPart(specimenDescription) + title;
41
		}
42
		return title;
43
	}
44
	
45
	private String getFirstPart(SpecimenDescription specimenDescription){
46
		Set<Marker> markers = specimenDescription.getMarkers();
47
		MarkerType markerType = MarkerType.USE();
48
		Boolean isUseDescription = false;
49
		for (Marker marker : markers) {
50
			if(marker.getMarkerType().equals(markerType)) {
51
				isUseDescription = true;
52
			}
53
		} 
54
		if (specimenDescription.isImageGallery()){
55
			return "Image gallery for " ;
56
		} else if (isUseDescription) {
57
			return "Use description for  ";
58
		} else {
59
			return "Specimen description for ";
60
		}
61
	}
62
}
(2-2/3)