Project

General

Profile

Download (2.72 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.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
    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

    
24
    final private String key;
25
    final private String label;
26
    final private boolean supportsWithinTaxon;
27
    final private boolean supportsToParent;
28
    final private boolean supportsOriginalSourceType;
29

    
30
    private AggregationSourceMode(String key, String message, boolean supportsWithinTaxon,
31
            boolean supportsToParent, boolean supportsOriginalSourceType) {
32
        this.key = key;
33
        this.label = message;
34
        this.supportsWithinTaxon = supportsWithinTaxon;
35
        this.supportsToParent = supportsToParent;
36
        this.supportsOriginalSourceType = supportsOriginalSourceType;
37
    }
38

    
39
    @Override
40
    public String getKey() {
41
        return key;
42
    }
43

    
44
    @Override
45
    public String getLabel() {
46
        return label;
47
    }
48

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

    
55
    public boolean isSupportsWithinTaxon() {
56
        return supportsWithinTaxon;
57
    }
58

    
59
    public boolean isSupportsToParent() {
60
        return supportsToParent;
61
    }
62

    
63
    public boolean isSupportsOriginalSourceType(){
64
        return supportsOriginalSourceType;
65
    }
66

    
67
    /**
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
            if (aggregationMode == AggregationMode.WithinTaxon && mode.supportsWithinTaxon){
76
                result.add(mode);
77
            }else if (aggregationMode == AggregationMode.ToParent && mode.supportsToParent){
78
                result.add(mode);
79
            }
80
        }
81
        return result;
82
    }
83
 }
(2-2/11)