1 |
5ee7595c
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2019 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.api.service.description;
|
10 |
|
|
|
11 |
47992818
|
Andreas Müller
|
import java.util.ArrayList;
|
12 |
|
|
import java.util.List;
|
13 |
|
|
|
14 |
|
|
import eu.etaxonomy.cdm.model.common.Language;
|
15 |
|
|
import eu.etaxonomy.cdm.model.term.IKeyTerm;
|
16 |
|
|
|
17 |
|
|
public enum AggregationSourceMode implements IKeyTerm{
|
18 |
acd4e30a
|
Andreas Müller
|
NONE("NO", "None", true, true, false),
|
19 |
|
|
ALL("ALL", "All sources", true, true, true),
|
20 |
|
|
ALL_SAMEVALUE("ALSV", "All sources with highest status", true, true, true),
|
21 |
|
|
DESCRIPTION("DESC","Link to underlying description", true, true, false),
|
22 |
|
|
TAXON("TAX","Link to child taxon", false, true, false);
|
23 |
47992818
|
Andreas Müller
|
|
24 |
acd4e30a
|
Andreas Müller
|
final private String key;
|
25 |
18620ac6
|
Andreas Müller
|
final private String label;
|
26 |
acd4e30a
|
Andreas Müller
|
final private boolean supportsWithinTaxon;
|
27 |
|
|
final private boolean supportsToParent;
|
28 |
|
|
final private boolean supportsOriginalSourceType;
|
29 |
47992818
|
Andreas Müller
|
|
30 |
acd4e30a
|
Andreas Müller
|
private AggregationSourceMode(String key, String message, boolean supportsWithinTaxon,
|
31 |
|
|
boolean supportsToParent, boolean supportsOriginalSourceType) {
|
32 |
47992818
|
Andreas Müller
|
this.key = key;
|
33 |
18620ac6
|
Andreas Müller
|
this.label = message;
|
34 |
19739293
|
Andreas Müller
|
this.supportsWithinTaxon = supportsWithinTaxon;
|
35 |
|
|
this.supportsToParent = supportsToParent;
|
36 |
acd4e30a
|
Andreas Müller
|
this.supportsOriginalSourceType = supportsOriginalSourceType;
|
37 |
47992818
|
Andreas Müller
|
}
|
38 |
|
|
|
39 |
|
|
@Override
|
40 |
|
|
public String getKey() {
|
41 |
|
|
return key;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
@Override
|
45 |
18620ac6
|
Andreas Müller
|
public String getLabel() {
|
46 |
|
|
return label;
|
47 |
47992818
|
Andreas Müller
|
}
|
48 |
|
|
|
49 |
|
|
@Override
|
50 |
18620ac6
|
Andreas Müller
|
public String getLabel(Language language) {
|
51 |
47992818
|
Andreas Müller
|
//TODO i18n not yet implemented for AggregationMode
|
52 |
18620ac6
|
Andreas Müller
|
return label;
|
53 |
47992818
|
Andreas Müller
|
}
|
54 |
|
|
|
55 |
19739293
|
Andreas Müller
|
public boolean isSupportsWithinTaxon() {
|
56 |
|
|
return supportsWithinTaxon;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
public boolean isSupportsToParent() {
|
60 |
|
|
return supportsToParent;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
acd4e30a
|
Andreas Müller
|
public boolean isSupportsOriginalSourceType(){
|
64 |
|
|
return supportsOriginalSourceType;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
47992818
|
Andreas Müller
|
/**
|
68 |
|
|
* Returns a list of {@link AggregationSourceMode}s available for the
|
69 |
|
|
* given {@link AggregationMode} and {@link AggregationType}
|
70 |
|
|
*/
|
71 |
|
|
public static List<AggregationSourceMode> list(AggregationMode aggregationMode, AggregationType type){
|
72 |
|
|
//TODO currently aggType is not yet used as all source modes are available for all aggTypes
|
73 |
|
|
List<AggregationSourceMode> result = new ArrayList<>();
|
74 |
|
|
for(AggregationSourceMode mode : values()){
|
75 |
19739293
|
Andreas Müller
|
if (aggregationMode == AggregationMode.WithinTaxon && mode.supportsWithinTaxon){
|
76 |
47992818
|
Andreas Müller
|
result.add(mode);
|
77 |
19739293
|
Andreas Müller
|
}else if (aggregationMode == AggregationMode.ToParent && mode.supportsToParent){
|
78 |
47992818
|
Andreas Müller
|
result.add(mode);
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
return result;
|
82 |
|
|
}
|
83 |
5ee7595c
|
Andreas Müller
|
}
|