1 /*******************************************************************************
2 * Copyright (c) 2017 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com
.hangum
.tadpole
.engine
.query
.sql
;
13 import java
.sql
.Connection
;
14 import java
.sql
.SQLException
;
15 import java
.util
.List
;
17 import org
.apache
.log4j
.Logger
;
19 import com
.hangum
.tadpole
.commons
.exception
.TadpoleSQLManagerException
;
20 import com
.hangum
.tadpole
.engine
.initialize
.TadpoleEngineUserDB
;
21 import com
.hangum
.tadpole
.engine
.manager
.TadpoleSQLManager
;
22 import com
.hangum
.tadpole
.engine
.query
.dao
.gateway
.ExtensionDBDAO
;
23 import com
.hangum
.tadpole
.session
.manager
.SessionManager
;
24 import com
.ibatis
.sqlmap
.client
.SqlMapClient
;
25 import com
.ibatis
.sqlmap
.client
.SqlMapSession
;
33 public class TadpoleSystem_ExtensionDB
{
35 * Logger for this class
37 private static final Logger logger
= Logger
.getLogger(TadpoleSystem_ExtensionDB
.class);
46 public static List
<ExtensionDBDAO
> getExtensionInfo(String searchKey
) throws Exception
{
47 SqlMapClient sqlClient
= TadpoleSQLManager
.getInstance(TadpoleEngineUserDB
.getUserDB());
48 return sqlClient
.queryForList("findExtensionDB", searchKey
); //$NON-NLS-1$
52 * 접근이 허락된 디비 리스트를 가져온다.
58 public static List
<ExtensionDBDAO
> getUserDBs(String userId
) throws Exception
{
59 SqlMapClient sqlClient
= TadpoleSQLManager
.getInstance(TadpoleEngineUserDB
.getUserDB());
60 return sqlClient
.queryForList("findUserExtensionDB", userId
); //$NON-NLS-1$
64 * 접근이 허락된 디비 리스트를 가져온다.
70 public static List
<ExtensionDBDAO
> getUserDBTerm(String userId
) throws Exception
{
71 SqlMapClient sqlClient
= TadpoleSQLManager
.getInstance(TadpoleEngineUserDB
.getUserDB());
72 return sqlClient
.queryForList("findUserExtensionDBTerm", userId
); //$NON-NLS-1$
78 * @throws TadpoleSQLManagerException
79 * @throws SQLException
81 public static void deleteExtensionDB() throws TadpoleSQLManagerException
, SQLException
{
82 SqlMapClient sqlClient
= TadpoleSQLManager
.getInstance(TadpoleEngineUserDB
.getUserDB());
83 sqlClient
.delete("deleteExtensionDB"); //$NON-NLS-1$
87 * insertExtension data
89 * @param listExtensionDB
90 * @throws TadpoleSQLManagerException, SQLException
92 public static void insertExtensionDB(List
<ExtensionDBDAO
> listExtensionDB
) throws TadpoleSQLManagerException
, SQLException
{
93 SqlMapClient sqlClient
= TadpoleSQLManager
.getInstance(TadpoleEngineUserDB
.getUserDB());
94 Connection connection
= sqlClient
.getDataSource().getConnection();
95 connection
.setAutoCommit(false);
96 SqlMapSession session
= sqlClient
.openSession(connection
);
98 if(logger
.isDebugEnabled()) logger
.debug(" deleted before gateway data");
100 session
.delete("deleteExtensionDB"); //$NON-NLS-1$
101 for (ExtensionDBDAO extensionDBDAO
: listExtensionDB
) {
102 session
.insert("saveExtensionDB", extensionDBDAO
); //$NON-NLS-1$
106 } catch(Exception sqle
) {
107 logger
.error("extension db list", sqle
);
108 connection
.rollback();
109 throw new SQLException(sqle
.getMessage());
111 try { if(session
!= null) session
.close(); } catch(Exception e
) {}
112 try { if(connection
!= null) connection
.close(); } catch(Exception e
) {}