3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.api
.service
;
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
;
27 * Service interface which provides functionality to directly access database
28 * related information.
33 public interface IDatabaseService
{
36 * Returns the database URL
39 public String
getUrl();
42 * Returns the username.
45 public String
getUsername();
48 * Connect to the database with the given parameters
49 * @param databaseTypeEnum
54 * @return returns true if successful
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
;
60 * Connect to the database with the given parameters. Uses default port.
61 * @param databaseTypeEnum
65 * @return returns true if successful
67 public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum
, String server
, String database
, String username
, String password
) throws TermNotFoundException
;
71 * Connect to the database with the given parameters. Uses default port.
73 * @return returns true if successful
75 public boolean connectToDatasource(CdmPersistentDataSource dataSource
) throws TermNotFoundException
;
78 * Saves a new ICdmDatasource into the datasource config file.
80 * @param strDataSourceName
85 public CdmPersistentDataSource
saveDataSource(String strDataSourceName
, ICdmDataSource dataSource
);
88 * Update an already saved datasource in datasource config file
89 * @param strDataSourceName
90 * the beanId under which the dataSource should be saved
92 * the dataSource to be saved
94 * the CdmDataSource, null if not successful
95 * @throws DataSourceNotFoundException
97 public CdmPersistentDataSource
updateDataSource(String strDataSourceName
, CdmPersistentDataSource dataSource
) throws DataSourceNotFoundException
;
100 * @param cdmApplicationController
102 public void setApplicationController(CdmApplicationController cdmApplicationController
);
105 * Returns the CDM model schema version number
107 * @return the CDM model schema version number
108 * @throws CdmSourceException , incase of an underlying SQL error
110 public String
getDbSchemaVersion() throws CdmSourceException
;
113 * Returns a boolean flag to indicate whether the database is empty
115 * @return boolean flag to indicate whether the database is empty
116 * @throws CdmSourceException , incase of an underlying SQL error
118 public boolean isDbEmpty() throws CdmSourceException
;
121 public Map
<MetaDataPropertyName
, String
> getCdmMetadataMap() throws CdmSourceException
;