2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
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
;
25 * Service interface which provides functionality to directly access database
26 * related information.
31 public interface IDatabaseService
{
34 * Returns the database URL
37 public String
getUrl();
40 * Returns the username.
43 public String
getUsername();
46 * Connect to the database with the given parameters
47 * @param databaseTypeEnum
52 * @return returns true if successful
54 public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum
, String server
,
55 String database
, String username
, String password
, int port
, String filePath
, H2Mode mode
) throws TermNotFoundException
;
58 * Connect to the database with the given parameters. Uses default port.
59 * @param databaseTypeEnum
63 * @return returns true if successful
65 public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum
, String server
, String database
, String username
, String password
) throws TermNotFoundException
;
69 * Connect to the database with the given parameters. Uses default port.
71 * @return returns true if successful
73 public boolean connectToDatasource(CdmPersistentDataSource dataSource
) throws TermNotFoundException
;
76 * Saves a new ICdmDatasource into the datasource config file.
78 * @param strDataSourceName
83 public CdmPersistentDataSource
saveDataSource(String strDataSourceName
, ICdmDataSource dataSource
);
86 * Update an already saved datasource in datasource config file
87 * @param strDataSourceName
88 * the beanId under which the dataSource should be saved
90 * the dataSource to be saved
92 * the CdmDataSource, null if not successful
93 * @throws DataSourceNotFoundException
95 public CdmPersistentDataSource
updateDataSource(String strDataSourceName
, CdmPersistentDataSource dataSource
) throws DataSourceNotFoundException
;
98 * @param cdmApplicationController
100 public void setApplicationController(CdmApplicationController cdmApplicationController
);
103 * Returns the CDM model schema version number
105 * @return the CDM model schema version number
106 * @throws CdmSourceException , incase of an underlying SQL error
108 public String
getDbSchemaVersion() throws CdmSourceException
;
111 * Returns a boolean flag to indicate whether the database is empty
113 * @return boolean flag to indicate whether the database is empty
114 * @throws CdmSourceException , incase of an underlying SQL error
116 public boolean isDbEmpty() throws CdmSourceException
;
119 public Map
<CdmMetaDataPropertyName
, String
> getCdmMetadataMap() throws CdmSourceException
;