2 * Copyright (C) 2011 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
;
11 import java
.util
.ArrayList
;
12 import java
.util
.HashSet
;
13 import java
.util
.List
;
17 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
18 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
19 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.IDescribable
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.editor
.UsageTermCollection
;
24 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.DescriptiveContentProvider
;
25 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainerTree
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * The class provides the required content to the Uses View
31 * @created mar 13, 2012
34 public class UsesContentProvider
extends DescriptiveContentProvider
{
36 Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
39 * <p>Constructor for DescriptiveContentProvider.</p>
41 * @param featureNodeContainerCache a {@link java.util.Map} object.
43 public UsesContentProvider(Map
<DescriptionBase
<?
>, FeatureNodeContainerTree
> featureNodeContainerCache
) {
44 super(featureNodeContainerCache
);
45 this.featureNodeContainerCache
= featureNodeContainerCache
;
49 * Get all descriptions associated with the given TaxonEditorInput
51 * @param parentElement
55 protected List
<DescriptionBase
> getDescriptions(IDescribable
<?
> parentElement
) {
56 List
<DescriptionBase
> descriptions
= new ArrayList
<DescriptionBase
>();
57 if(parentElement
instanceof Taxon
){
58 Taxon taxon
= (Taxon
) parentElement
;
59 this.markerTypes
.addAll(CdmStore
.getTermManager().getPreferredTerms(MarkerType
.class));
60 for(DescriptionBase description
: taxon
.getDescriptions()){
61 if(! description
.isImageGallery()){
62 MarkerType useMarkertype
= (MarkerType
) CdmStore
.getService(ITermService
.class).find(UsageTermCollection
.uuidUseMarkerType
);
63 Set
<Marker
> descriptionMarkers
= description
.getMarkers();
64 if(descriptionMarkers
!= null) {
65 for (Marker marker
: descriptionMarkers
) {
66 if(marker
.getMarkerType().equals(useMarkertype
)) {
67 descriptions
.add(description
);