1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.api.service;
|
11
|
|
12
|
import java.util.Map;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
15
|
import eu.etaxonomy.cdm.config.CdmSourceException;
|
16
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
17
|
import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
|
18
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
19
|
import eu.etaxonomy.cdm.database.H2Mode;
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.model.metadata.CdmMetaDataPropertyName;
|
22
|
import eu.etaxonomy.cdm.model.term.init.TermNotFoundException;
|
23
|
|
24
|
/**
|
25
|
* Service interface which provides functionality to directly access database
|
26
|
* related information.
|
27
|
*
|
28
|
* @author a.mueller
|
29
|
*
|
30
|
*/
|
31
|
public interface IDatabaseService {
|
32
|
|
33
|
/**
|
34
|
* Returns the database URL
|
35
|
* @return
|
36
|
*/
|
37
|
public String getUrl();
|
38
|
|
39
|
/**
|
40
|
* Returns the username.
|
41
|
* @return
|
42
|
*/
|
43
|
public String getUsername();
|
44
|
|
45
|
/**
|
46
|
* Connect to the database with the given parameters
|
47
|
* @param databaseTypeEnum
|
48
|
* @param url
|
49
|
* @param username
|
50
|
* @param password
|
51
|
* @param port
|
52
|
* @return returns true if successful
|
53
|
*/
|
54
|
public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server,
|
55
|
String database, String username, String password, int port, String filePath, H2Mode mode) throws TermNotFoundException ;
|
56
|
|
57
|
/**
|
58
|
* Connect to the database with the given parameters. Uses default port.
|
59
|
* @param databaseTypeEnum
|
60
|
* @param url
|
61
|
* @param username
|
62
|
* @param password
|
63
|
* @return returns true if successful
|
64
|
*/
|
65
|
public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server, String database, String username, String password) throws TermNotFoundException;
|
66
|
|
67
|
|
68
|
/**
|
69
|
* Connect to the database with the given parameters. Uses default port.
|
70
|
* @param dataSource
|
71
|
* @return returns true if successful
|
72
|
*/
|
73
|
public boolean connectToDatasource(CdmPersistentDataSource dataSource) throws TermNotFoundException;
|
74
|
|
75
|
/**
|
76
|
* Saves a new ICdmDatasource into the datasource config file.
|
77
|
*
|
78
|
* @param strDataSourceName
|
79
|
* @param dataSource
|
80
|
* @param code
|
81
|
* @return
|
82
|
*/
|
83
|
public CdmPersistentDataSource saveDataSource(String strDataSourceName, ICdmDataSource dataSource);
|
84
|
|
85
|
/**
|
86
|
* Update an already saved datasource in datasource config file
|
87
|
* @param strDataSourceName
|
88
|
* the beanId under which the dataSource should be saved
|
89
|
* @param dataSource
|
90
|
* the dataSource to be saved
|
91
|
* @return
|
92
|
* the CdmDataSource, null if not successful
|
93
|
* @throws DataSourceNotFoundException
|
94
|
*/
|
95
|
public CdmPersistentDataSource updateDataSource(String strDataSourceName, CdmPersistentDataSource dataSource) throws DataSourceNotFoundException;
|
96
|
|
97
|
/**
|
98
|
* @param cdmApplicationController
|
99
|
*/
|
100
|
public void setApplicationController(CdmApplicationController cdmApplicationController);
|
101
|
|
102
|
/**
|
103
|
* Returns the CDM model schema version number
|
104
|
*
|
105
|
* @return the CDM model schema version number
|
106
|
* @throws CdmSourceException , incase of an underlying SQL error
|
107
|
*/
|
108
|
public String getDbSchemaVersion() throws CdmSourceException;
|
109
|
|
110
|
/**
|
111
|
* Returns a boolean flag to indicate whether the database is empty
|
112
|
*
|
113
|
* @return boolean flag to indicate whether the database is empty
|
114
|
* @throws CdmSourceException , incase of an underlying SQL error
|
115
|
*/
|
116
|
public boolean isDbEmpty() throws CdmSourceException;
|
117
|
|
118
|
|
119
|
public Map<CdmMetaDataPropertyName, String> getCdmMetadataMap() throws CdmSourceException;
|
120
|
|
121
|
}
|