Project

General

Profile

Download (1.96 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2014 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.config;
10

    
11
import org.apache.commons.lang3.StringUtils;
12

    
13
import eu.etaxonomy.cdm.common.CdmUtils;
14

    
15
/**
16
 * Abstract class representing the base CDM Source object.
17
 */
18
public abstract class CdmSource implements ICdmSource {
19

    
20
	private String name;
21
	protected String server;
22
	private int port;
23

    
24
	public static final int NULL_PORT = -1;
25

    
26
	public static final String DEFAULT_ENTRY = "-";
27

    
28
	/**
29
	 * Sets the CDM Source name
30
	 *
31
	 * @param name
32
	 */
33
	@Override
34
	public void setName(String name) {
35
		this.name = name;
36
	}
37

    
38
	/**
39
	 * Sets the CDM Source server
40
	 *
41
	 * @param server
42
	 */
43
	@Override
44
	public void setServer(String server) {
45
		this.server = server;
46
	}
47

    
48
	/**
49
	 * Sets the CDM Source port
50
	 *
51
	 * @param port
52
	 */
53
	@Override
54
	public void setPort(int port) {
55
		this.port = port;
56
	}
57

    
58
	@Override
59
	public String getName() {
60
		return this.name;
61
	}
62

    
63
	@Override
64
	public String getServer() {
65
		return this.server;
66
	}
67

    
68
	@Override
69
	public int getPort() {
70
		return this.port;
71
	}
72

    
73
	@Override
74
	public abstract String getDbSchemaVersion() throws CdmSourceException;
75

    
76
	@Override
77
	public abstract boolean isDbEmpty() throws CdmSourceException;
78

    
79
	@Override
80
	public abstract boolean checkConnection() throws CdmSourceException;
81

    
82
	@Override
83
	public abstract String getConnectionMessage();
84

    
85
	@Override
86
	public void closeOpenConnections() {
87
	}
88

    
89
    @Override
90
    public String toString() {
91
        if (StringUtils.isBlank(name)&& StringUtils.isBlank(server)){
92
            return super.toString();
93
        }else{
94
            String result = CdmUtils.concat("@", name, server);
95
            if (port > 0){
96
                result = CdmUtils.concat(":", result, String.valueOf(port));
97
            }
98
            return result;
99
        }
100
    }
101

    
102

    
103

    
104
}
(6-6/11)