Project

General

Profile

Download (3.82 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * 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

    
11
package eu.etaxonomy.cdm.api.service;
12

    
13
import java.util.Map;
14

    
15
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
16
import eu.etaxonomy.cdm.config.CdmSourceException;
17
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
18
import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
19
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
20
import eu.etaxonomy.cdm.database.H2Mode;
21
import eu.etaxonomy.cdm.database.ICdmDataSource;
22
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;
23
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
24
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
25

    
26
/**
27
 * Service interface which provides functionality to directly access database 
28
 * related information.
29
 * 
30
 * @author a.mueller
31
 *
32
 */
33
public interface IDatabaseService {
34
	
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
	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

    
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
	public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server, String database, String username, String password)  throws TermNotFoundException;
68
	
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
	public boolean connectToDatasource(CdmPersistentDataSource dataSource) throws TermNotFoundException;
76

    
77
	/**
78
	 * Saves a new ICdmDatasource into the datasource config file.
79
	 * 
80
	 * @param strDataSourceName
81
	 * @param dataSource
82
	 * @param code
83
	 * @return
84
	 */
85
	public CdmPersistentDataSource saveDataSource(String strDataSourceName, ICdmDataSource dataSource);
86
	
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
	public CdmPersistentDataSource updateDataSource(String strDataSourceName, CdmPersistentDataSource dataSource) throws DataSourceNotFoundException;
98

    
99
	/**
100
	 * @param cdmApplicationController
101
	 */
102
	public void setApplicationController(CdmApplicationController cdmApplicationController);
103
	
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
	
120
	
121
	public Map<MetaDataPropertyName, String> getCdmMetadataMap() throws CdmSourceException;
122

    
123
}
(33-33/98)