View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.database;
17  
18  import java.sql.Connection;
19  import java.sql.SQLException;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.seasar.tuigwaa.database.util.DatafileLoader;
24  import org.seasar.tuigwaa.system.TgwServiceException;
25  
26  
27  /***
28   * @author someda
29   */
30  public interface BasicDatabaseService {
31  
32  	//[Start] ------ Handling External Database ------
33  	
34  	public void loadExternalDatabase();
35  
36  	public void addExternalDatabase(String databaseName, String driver,
37  			String user, String password, String url);
38  
39  	public void deleteExternalDatabase(String databaseName);
40  
41  	public void setExternalDatabaseMapping(String domainName, String databaseName,
42  			String schemaName) throws TgwServiceException;
43  	
44  	public void removeExternalDatabaseMapping(String domainName);
45  	
46  	//[End] ------ Handling External Database ------
47  	
48  	public String getDriver(String domainName);
49  
50  	public boolean hasDomain(String databaseName);
51  	
52  	public Connection getConnection(String domainName) throws SQLException;
53  
54  	public DatabaseInfo getBaseDatabaseInfo();
55  
56  	public DatabaseInfo getDatabaseInfo(String domainName) throws SQLException;
57  
58  	public boolean existTable(String domainName, String tableName);
59  
60  	public boolean existSchema(String schema);
61  
62  	public List getExternalDatabaseInfoList();
63  
64  	public String[] getExternalDatabaseNames();
65  
66  	public List getTableNames(String schema);
67  	
68  	/***
69  	 * Backup table data into CSV file resided in given target directory.
70  	 * if tableNames not null, only the contents of given tableNames are saved,
71  	 * otherwise, full backup will be taken. This method skip byte[] column data.
72  	 * 
73  	 * The periodical backup using the utility of the database itself
74  	 * is strongly recommended.
75  	 */	
76  	public void backup(String dbName, String schema, String[] tableNames, String targetdir) throws TgwServiceException;
77  	
78  	/***
79  	 * Restore table data from CSV file resided in source directory.
80  	 */
81  	public void restore(String dbName, String schema, String[] tableNames, String srcdir) throws TgwServiceException;
82  		
83  	public void insertOnDelete(String dbName, String schema, String table, DatafileLoader loader, String[] columns, String[] types)
84  	throws TgwServiceException;
85  		
86  	public void insert(String dbName, String schema, String table, DatafileLoader loader, String[] columns, String[] types)
87  	throws TgwServiceException;	
88  	
89  	public void delete(String dbName, String schema, String table) throws TgwServiceException;
90  		
91  	public String getSchemaName(String domainName);
92  
93  	public Map createEntityMap(String domainName) throws SQLException;
94  
95  	public boolean useBaseDatabase(String domainName);
96  }