Project

General

Profile

Download (2.29 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
12

    
13
import eu.etaxonomy.cdm.model.common.Language;
14
import eu.etaxonomy.cdm.model.term.IKeyTerm;
15
import eu.etaxonomy.cdm.model.term.TermType;
16

    
17
public enum CdmMetaDataPropertyName implements IKeyTerm{
18

    
19
    DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION", 0),
20
	TERMS_VERSION("Term Version","TERM_VERSION", 1),
21
	DB_CREATE_DATE("Created","CREATED", 2),
22
	DB_CREATE_NOTE("Create Note","CREATE_NOTE", 3),
23
	INSTANCE_NAME("CDM Instance Name","INST_NAME", 4),
24
	INSTANCE_ID("CDM Instance ID","INST_ID", 5);
25

    
26
	// **************** END ENUM **********************/
27

    
28
    private String label;
29
    private String key;
30
    private int oldPropertyId;
31

    
32
    @SuppressWarnings("unused")
33
    private static final Logger logger = LogManager.getLogger(TermType.class);
34

    
35
    private CdmMetaDataPropertyName(String label, String key, int oldPropertyId){
36
        this.label = label;
37
        this.key = key;
38
        this.oldPropertyId = oldPropertyId;
39
    }
40

    
41
//**************** METHODS ****************************/
42

    
43
    public String getSqlQuery(){
44
        return String.format(
45
                "SELECT value FROM CdmMetaData WHERE propertyname='%s'",
46
                this.key);
47
    }
48

    
49
    /**
50
     * SQL query with propertyName still being an int attribute
51
     * @return
52
     */
53
    public String getSqlQueryOld(){
54
        return String.format(
55
                "SELECT value FROM CdmMetaData WHERE propertyname=%d",
56
                this.oldPropertyId);
57
    }
58

    
59
    @Override
60
    public String getKey() {
61
        return key;
62
    }
63

    
64
    @Override
65
    public String getLabel() {
66
        return getLabel(Language.DEFAULT());
67
    }
68

    
69
    @Override
70
    public String getLabel(Language language) {
71
        //TODO i18n
72
        return label;
73
    }
74

    
75
    public static CdmMetaDataPropertyName getByKey(String key) {
76
        for (CdmMetaDataPropertyName term : values()){
77
            if (term.getKey().equals(key)){
78
                return term;
79
            }
80
        }
81
        return null;
82
    }
83
}
(2-2/19)