1 |
c2f269f9
|
Andreas Kohlbecker
|
// $Id$
|
2 |
2d993c6e
|
Andreas Müller
|
/**
|
3 |
c2f269f9
|
Andreas Kohlbecker
|
* Copyright (C) 2007 EDIT
|
4 |
|
|
* European Distributed Institute of Taxonomy
|
5 |
|
|
* http://www.e-taxonomy.eu
|
6 |
|
|
*
|
7 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9 |
|
|
*/
|
10 |
25663b56
|
Andreas Müller
|
|
11 |
2d993c6e
|
Andreas Müller
|
package eu.etaxonomy.cdm.api.service;
|
12 |
|
|
|
13 |
d561b336
|
Cherian Mathew
|
import java.util.Map;
|
14 |
|
|
|
15 |
0092a4a5
|
Cherian Mathew
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
16 |
f5f02f66
|
Cherian Mathew
|
import eu.etaxonomy.cdm.config.CdmSourceException;
|
17 |
130645df
|
Andreas Müller
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
18 |
b5b7a7b0
|
n.hoffmann
|
import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
|
19 |
2d993c6e
|
Andreas Müller
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
20 |
01c21ead
|
n.hoffmann
|
import eu.etaxonomy.cdm.database.H2Mode;
|
21 |
b5b7a7b0
|
n.hoffmann
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
22 |
003c33af
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;
|
23 |
d561b336
|
Cherian Mathew
|
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
|
24 |
01c21ead
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25 |
2d993c6e
|
Andreas Müller
|
|
26 |
|
|
/**
|
27 |
f5f02f66
|
Cherian Mathew
|
* Service interface which provides functionality to directly access database
|
28 |
|
|
* related information.
|
29 |
|
|
*
|
30 |
2d993c6e
|
Andreas Müller
|
* @author a.mueller
|
31 |
|
|
*
|
32 |
|
|
*/
|
33 |
d57c0df0
|
ben.clark
|
public interface IDatabaseService {
|
34 |
2d993c6e
|
Andreas Müller
|
|
35 |
|
|
/**
|
36 |
|
|
* Returns the database URL
|
37 |
|
|
* @return
|
38 |
|
|
*/
|
39 |
|
|
public String getUrl();
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* Returns the username.
|
43 |
|
|
* @return
|
44 |
|
|
*/
|
45 |
|
|
public String getUsername();
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* Connect to the database with the given parameters
|
49 |
|
|
* @param databaseTypeEnum
|
50 |
|
|
* @param url
|
51 |
|
|
* @param username
|
52 |
|
|
* @param password
|
53 |
|
|
* @param port
|
54 |
|
|
* @return returns true if successful
|
55 |
|
|
*/
|
56 |
01c21ead
|
n.hoffmann
|
public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server,
|
57 |
|
|
String database, String username, String password, int port, String filePath, H2Mode mode, NomenclaturalCode code) throws TermNotFoundException ;
|
58 |
2d993c6e
|
Andreas Müller
|
|
59 |
|
|
/**
|
60 |
|
|
* Connect to the database with the given parameters. Uses default port.
|
61 |
|
|
* @param databaseTypeEnum
|
62 |
|
|
* @param url
|
63 |
|
|
* @param username
|
64 |
|
|
* @param password
|
65 |
|
|
* @return returns true if successful
|
66 |
|
|
*/
|
67 |
003c33af
|
Andreas Müller
|
public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server, String database, String username, String password) throws TermNotFoundException;
|
68 |
2d993c6e
|
Andreas Müller
|
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Connect to the database with the given parameters. Uses default port.
|
72 |
|
|
* @param dataSource
|
73 |
|
|
* @return returns true if successful
|
74 |
|
|
*/
|
75 |
003c33af
|
Andreas Müller
|
public boolean connectToDatasource(CdmPersistentDataSource dataSource) throws TermNotFoundException;
|
76 |
2d993c6e
|
Andreas Müller
|
|
77 |
b5b7a7b0
|
n.hoffmann
|
/**
|
78 |
|
|
* Saves a new ICdmDatasource into the datasource config file.
|
79 |
|
|
*
|
80 |
|
|
* @param strDataSourceName
|
81 |
|
|
* @param dataSource
|
82 |
01c21ead
|
n.hoffmann
|
* @param code
|
83 |
b5b7a7b0
|
n.hoffmann
|
* @return
|
84 |
|
|
*/
|
85 |
89842e70
|
n.hoffmann
|
public CdmPersistentDataSource saveDataSource(String strDataSourceName, ICdmDataSource dataSource);
|
86 |
b5b7a7b0
|
n.hoffmann
|
|
87 |
|
|
/**
|
88 |
|
|
* Update an already saved datasource in datasource config file
|
89 |
|
|
* @param strDataSourceName
|
90 |
|
|
* the beanId under which the dataSource should be saved
|
91 |
|
|
* @param dataSource
|
92 |
|
|
* the dataSource to be saved
|
93 |
|
|
* @return
|
94 |
|
|
* the CdmDataSource, null if not successful
|
95 |
|
|
* @throws DataSourceNotFoundException
|
96 |
|
|
*/
|
97 |
89842e70
|
n.hoffmann
|
public CdmPersistentDataSource updateDataSource(String strDataSourceName, CdmPersistentDataSource dataSource) throws DataSourceNotFoundException;
|
98 |
01c21ead
|
n.hoffmann
|
|
99 |
f5f02f66
|
Cherian Mathew
|
/**
|
100 |
|
|
* @param cdmApplicationController
|
101 |
|
|
*/
|
102 |
0092a4a5
|
Cherian Mathew
|
public void setApplicationController(CdmApplicationController cdmApplicationController);
|
103 |
f5f02f66
|
Cherian Mathew
|
|
104 |
|
|
/**
|
105 |
|
|
* Returns the CDM model schema version number
|
106 |
|
|
*
|
107 |
|
|
* @return the CDM model schema version number
|
108 |
|
|
* @throws CdmSourceException , incase of an underlying SQL error
|
109 |
|
|
*/
|
110 |
|
|
public String getDbSchemaVersion() throws CdmSourceException;
|
111 |
|
|
|
112 |
|
|
/**
|
113 |
|
|
* Returns a boolean flag to indicate whether the database is empty
|
114 |
|
|
*
|
115 |
|
|
* @return boolean flag to indicate whether the database is empty
|
116 |
|
|
* @throws CdmSourceException , incase of an underlying SQL error
|
117 |
|
|
*/
|
118 |
|
|
public boolean isDbEmpty() throws CdmSourceException;
|
119 |
d561b336
|
Cherian Mathew
|
|
120 |
|
|
|
121 |
|
|
public Map<MetaDataPropertyName, String> getCdmMetadataMap() throws CdmSourceException;
|
122 |
|
|
|
123 |
2d993c6e
|
Andreas Müller
|
}
|