2 * Copyright (C) 2019 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
.cdm
.api
.service
.description
;
11 import java
.util
.ArrayList
;
12 import java
.util
.EnumSet
;
13 import java
.util
.HashSet
;
14 import java
.util
.List
;
17 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
18 import eu
.etaxonomy
.cdm
.model
.term
.IKeyTerm
;
20 public enum AggregationSourceMode
implements IKeyTerm
{
21 NONE("NO", "None", true , true, false, true, true ),
22 ALL("ALL", "All sources", true , true, true , true, false), //for now we do not support structured descriptions, may change in future
23 ALL_SAMEVALUE("ALSV", "All sources with highest status",
24 true , true, true , true, false), //does not make sense for struc. descriptions
25 DESCRIPTION("DESC","Link to underlying description",
26 true , true, false, true, true ), //probably not really supported for distributions yet, at least not for "within taxon"
27 TAXON("TAX","Link to child taxon",
28 false, true, false, true, true );
30 final private String key
;
31 final private String label
;
32 final private boolean supportsWithinTaxon
;
33 final private boolean supportsToParent
;
34 final private boolean supportsOriginalSourceType
;
35 final private EnumSet
<AggregationType
> supportedAggregationTypes
;
37 private AggregationSourceMode(String key
, String message
,
38 boolean supportsWithinTaxon
, boolean supportsToParent
,
39 boolean supportsOriginalSourceType
,
40 boolean supportsDistribution
, boolean supportsStructuredDescription
) {
44 this.supportsWithinTaxon
= supportsWithinTaxon
;
45 this.supportsToParent
= supportsToParent
;
46 this.supportsOriginalSourceType
= supportsOriginalSourceType
;
47 Set
<AggregationType
> aggTypes
= new HashSet
<>();
48 if (supportsDistribution
){
49 aggTypes
.add(AggregationType
.Distribution
);
51 if (supportsStructuredDescription
){
52 aggTypes
.add(AggregationType
.StructuredDescription
);
54 this.supportedAggregationTypes
= EnumSet
.copyOf(aggTypes
);
58 public String
getKey() {
63 public String
getLabel() {
68 public String
getLabel(Language language
) {
69 //TODO i18n not yet implemented for AggregationMode
73 public boolean isSupportsWithinTaxon() {
74 return supportsWithinTaxon
;
77 public boolean isSupportsToParent() {
78 return supportsToParent
;
81 public boolean isSupportsOriginalSourceType(){
82 return supportsOriginalSourceType
;
85 public boolean isNone(){
89 public boolean isTaxon(){
94 * Returns a list of {@link AggregationSourceMode}s available for the
95 * given {@link AggregationMode} and {@link AggregationType}
97 public static List
<AggregationSourceMode
> list(AggregationMode aggregationMode
, AggregationType type
){
98 List
<AggregationSourceMode
> result
= new ArrayList
<>();
99 for(AggregationSourceMode mode
: values()){
100 if (type
!= null && !mode
.supportedAggregationTypes
.contains(type
)){
103 if (aggregationMode
== AggregationMode
.WithinTaxon
&& mode
.supportsWithinTaxon
){
105 }else if (aggregationMode
== AggregationMode
.ToParent
&& mode
.supportsToParent
){