Project

General

Profile

Download (2.71 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
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
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.List;
14

    
15
import eu.etaxonomy.cdm.model.common.Language;
16
import eu.etaxonomy.cdm.model.term.IKeyTerm;
17

    
18
public enum AggregationMode implements IKeyTerm{
19
        WithinTaxon("INTAX", "Within taxon", true, true),
20
        ToParent("TOPAR", "From children to this taxon", true, true);
21
//        public boolean isByRank() {
22
//           return this==byRanks || this == byAreasAndRanks;
23
//        }
24
//        public boolean isByArea() {
25
//            return this==byAreas || this == byAreasAndRanks;
26
//         }
27

    
28
    private String key;
29
    private String label;
30
    private boolean supportsDistribution;
31
    private boolean supportsDescriptiveData;
32

    
33
    private AggregationMode(String key, String message,
34
            boolean supportsDistribution, boolean supportsDescriptiveData) {
35

    
36
        this.key = key;
37
        this.label = message;
38
        this.supportsDistribution = supportsDistribution;
39
        this.supportsDescriptiveData = supportsDescriptiveData;
40
    }
41

    
42
    @Override
43
    public String getKey() {
44
        return key;
45
    }
46

    
47
    @Override
48
    public String getLabel() {
49
        return label;
50
    }
51

    
52
    @Override
53
    public String getLabel(Language language) {
54
        //TODO i18n not yet implemented for AggregationMode
55
        return label;
56
    }
57

    
58
    public boolean isSupportsDistribution() {
59
        return supportsDistribution;
60
    }
61

    
62
    public boolean isSupportsDescriptiveData() {
63
        return supportsDescriptiveData;
64
    }
65

    
66
    public static List<AggregationMode> list(AggregationType type){
67
        List<AggregationMode> result = new ArrayList<>();
68
        for(AggregationMode mode : values()){
69
            if (type == AggregationType.Distribution && mode.supportsDistribution){
70
                result.add(mode);
71
            }else if (type == AggregationType.StructuredDescription && mode.supportsDescriptiveData){
72
                result.add(mode);
73
            }
74
        }
75
        return result;
76
    }
77

    
78
    public static List<AggregationMode> byWithinTaxonAndToParent(){
79
        return Arrays.asList(new AggregationMode[]{AggregationMode.WithinTaxon, AggregationMode.ToParent});
80
    }
81
    public static List<AggregationMode> byWithinTaxon(){
82
        return Arrays.asList(new AggregationMode[]{AggregationMode.WithinTaxon});
83
    }
84
    public static List<AggregationMode> byToParent(){
85
        return Arrays.asList(new AggregationMode[]{AggregationMode.ToParent});
86
    }
87

    
88
}
(2-2/12)