Project

General

Profile

Download (2.63 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2011 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.taxeditor.editor.view.uses;
10

    
11
import java.util.ArrayList;
12
import java.util.HashSet;
13
import java.util.List;
14
import java.util.Map;
15
import java.util.Set;
16

    
17
import eu.etaxonomy.cdm.model.common.Marker;
18
import eu.etaxonomy.cdm.model.common.MarkerType;
19
import eu.etaxonomy.cdm.model.description.DescriptionBase;
20
import eu.etaxonomy.cdm.model.description.IDescribable;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
23
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25
import eu.etaxonomy.taxeditor.store.UsageTermCollection;
26

    
27
/**
28
 * The class provides the required content to the Uses View
29
 * @author a.theys
30
 * @created mar 13, 2012
31
 */
32
public class UsesContentProvider extends DescriptiveContentProvider {
33

    
34
	Set<MarkerType> markerTypes = new HashSet<>();
35

    
36
	/**
37
	 * <p>Constructor for DescriptiveContentProvider.</p>
38
	 *
39
	 * @param featureNodeContainerCache a {@link java.util.Map} object.
40
	 */
41
	public UsesContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {
42
		super(featureNodeContainerCache);
43
		this.featureNodeContainerCache = featureNodeContainerCache;
44
	}
45

    
46
	/**
47
	 * Get all descriptions associated with the given TaxonEditorInput
48
	 *
49
	 * @param parentElement
50
	 * @return
51
	 */
52
	@Override
53
	protected List<DescriptionBase<?>> getDescriptions(IDescribable<?> parentElement) {
54
	    List<DescriptionBase<?>> descriptions = new ArrayList<>();
55
	    if(parentElement instanceof Taxon){
56
	        Taxon taxon = (Taxon) parentElement;
57
	        this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class));
58
	        for(DescriptionBase<?> description : taxon.getDescriptions()){
59
	            if(! description.isImageGallery()){
60
	            	Set<Marker> descriptionMarkers = description.getMarkers();
61
	                if(descriptionMarkers != null) {
62
	                    for (Marker marker: descriptionMarkers) {
63
	                        if(marker.getMarkerType() != null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
64
	                            descriptions.add(description);
65
	                        }
66
	                    }
67
	                }
68
	            }
69
	        }
70
	    }
71
		return descriptions;
72
	}
73
}
(1-1/2)