Project

General

Profile

Revision 1000779d

ID1000779d5758719a62a64693b6d113e6abc7248e
Parent 0be51620
Child 48e5bbde

Added by Katja Luther 2 months ago

ref #8045: add Interface for Preference Enums

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/IKeyLabel.java
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.model.metadata;
10

  
11
/**
12
 * @author k.luther
13
 * @since 06.05.2019
14
 *
15
 */
16
public interface IKeyLabel {
17

  
18
    public String getLabel();
19

  
20
    public String getKey();
21
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/NodeOrderEnum.java
14 14
 * @since 19.11.2018
15 15
 *
16 16
 */
17
public enum NodeOrderEnum {
17
public enum NodeOrderEnum implements IKeyLabel{
18 18
    AlphabeticalOrder("AlphabeticalOrder", "Alphabetical"), //$NON-NLS-1$
19 19
    NaturalOrder("NaturalOrder", "Natural"), //$NON-NLS-1$
20 20
    RankAndNameOrder("RankAndNameOrder", "Rank and Name"); //$NON-NLS-1$
......
28 28
        this.key = key;
29 29
    }
30 30

  
31
    @Override
31 32
    public String getLabel(){
32 33
        return label;
33 34
    }
34 35

  
36
    @Override
35 37
    public String getKey(){
36 38
        return key;
37 39
    }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/PreferencePredicate.java
37 37
    //vaadin + distribution editor
38 38
	AvailableDistributionStatus(UUID.fromString("6721599e-686b-460e-9d57-cfd364f4b626"), "Available Distribution Status", "distribution.status.term", null),
39 39
	AvailableDistributionAreaVocabularies(UUID.fromString("dd1f35d5-dbf3-426b-9ed3-8b5992cb2e27"), "Available Distribution Area Vocabularies", "distribution.area.voc", null),
40
	AvailableDistributionPerAreaStatus(UUID.fromString("b2f0c066-d5a4-4a91-9e19-0e58ec2849aa"), "Available Distribution Status Per Area", "distribution.status.term.area", null),
40

  
41 41

  
42 42

  
43 43
    //common name area vocabularies
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/PublishEnum.java
13 13
 * @since 19.11.2018
14 14
 *
15 15
 */
16
public enum PublishEnum {
16
public enum PublishEnum implements IKeyLabel{
17 17

  
18 18
    Publish("Publish", "Publish"),
19 19
    NotPublish("NotPublish", "Not Publish"),
......
28 28
        this.key = key;
29 29
    }
30 30

  
31
    @Override
31 32
    public String getLabel(){
32 33
        return label;
33 34
    }
34 35

  
36
    @Override
35 37
    public String getKey(){
36 38
        return key;
37 39
    }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/TermDisplayEnum.java
13 13
 * @since 09.01.2019
14 14
 *
15 15
 */
16
public enum TermDisplayEnum {
16
public enum TermDisplayEnum implements IKeyLabel{
17 17
    IdInVocabulary("IdInVocabulary", "ID in Vocabulary"),
18 18
    Symbol1("Symbol1", "Symbol 1"),
19 19
    Symbol2("Symbol2", "Symbol 2"),
......
27 27
        this.key = key;
28 28
    }
29 29

  
30
    @Override
30 31
    public String getLabel(){
31 32
        return label;
32 33
    }
33 34

  
35
    @Override
34 36
    public String getKey(){
35 37
        return key;
36 38
    }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/TermOrder.java
13 13
 * @since 6 Feb 2019
14 14
 *
15 15
 */
16
public enum TermOrder {
16
public enum TermOrder implements IKeyLabel{
17 17

  
18 18
    IdInVoc("IdInVoc", "Id in Vocabulary"),
19 19
    Title("Title", "Title"),
......
28 28
        this.key = key;
29 29
    }
30 30

  
31
    @Override
31 32
    public String getLabel(){
32 33
        return label;
33 34
    }
34 35

  
36
    @Override
35 37
    public String getKey(){
36 38
        return key;
37 39
    }
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/metadata/CdmPreferenceTest.java
127 127
        }
128 128

  
129 129
        try {
130
            subject2 = "/NamedArea[111bdf38-7a32-440a-9808-8af1c9e54b51]/";
131
            prefs = new CdmPreference(subject2, predicate, value);
132
            Assert.assertEquals(subject2, prefs.getSubjectString());
133
            Assert.assertEquals(predicate, prefs.getPredicate());
134
            Assert.assertEquals(value, prefs.getValue());
135
        } catch (Exception e) {
136
            Assert.fail();
137
        }
138

  
139
        try {
130 140
            subject2 = "/Taxon3Node[#t1#18681#6392#5358#9#2#]";
131 141
            prefs = new CdmPreference(subject2, predicate, value);
132 142
            Assert.fail("Syntax for " + subject2 + " should fail");
133 143
        } catch (Exception e) {
134
            //ok
144
           //ok
135 145
        }
136 146

  
137 147
        try {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)