Project

General

Profile

Download (2.35 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.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
	DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION", 0),
19
	TERMS_VERSION("Term Version","TERM_VERSION", 1),
20
	DB_CREATE_DATE("Created","CREATED", 2),
21
	DB_CREATE_NOTE("Create Note","CREATE_NOTE", 3),
22
	INSTANCE_NAME("CDM Instance Name","INST_NAME", 4),
23
	INSTANCE_ID("CDM Instance ID","INST_ID", 5);
24

    
25
	// **************** END ENUM **********************/
26

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

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

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

    
40
//**************** METHODS ****************************/
41

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

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

    
58

    
59

    
60
    /**
61
     * {@inheritDoc}
62
     */
63
    @Override
64
    public String getKey() {
65
        return key;
66
    }
67

    
68
    /**
69
     * {@inheritDoc}
70
     */
71
    @Override
72
    public String getMessage() {
73
        return getMessage(Language.DEFAULT());
74
    }
75

    
76
    /**
77
     * {@inheritDoc}
78
     */
79
    @Override
80
    public String getMessage(Language language) {
81
        //TODO i18n
82
        return label;
83
    }
84

    
85
    public static CdmMetaDataPropertyName getByKey(String key) {
86
        for (CdmMetaDataPropertyName term : values()){
87
            if (term.getKey().equals(key)){
88
                return term;
89
            }
90
        }
91
        return null;
92
    }
93

    
94

    
95
}
(2-2/13)