Browse Source
Merge in DESIGN/design from ~DESTINY.LIN/design:mss/2.0 to mss/2.0 * commit 'b78b95630d99915f0f7a3162afb367e9afbb4a49': REPORT-114391 【微服务适配】远程&本地设计器能够正常启动 REPORT-114391 【微服务适配】远程&本地设计器能够正常启动mss/2.0
Destiny.Lin-林锦龙
5 months ago
9 changed files with 150 additions and 63 deletions
@ -0,0 +1,67 @@ |
|||||||
|
package com.fr.design.data.datapane.connect; |
||||||
|
|
||||||
|
import com.fr.data.driver.DriverClassNotFoundException; |
||||||
|
import com.fr.data.impl.Connection; |
||||||
|
import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean; |
||||||
|
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.workspace.server.repository.connection.BaseConnectionSource; |
||||||
|
import java.sql.SQLException; |
||||||
|
|
||||||
|
/** |
||||||
|
* 本地Connection资源操作 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2024/5/29 |
||||||
|
*/ |
||||||
|
public class LocalConnectionSource extends BaseConnectionSource { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void add(ConnectionInfoBean bean) throws Exception { |
||||||
|
Connection connection = ConnectionProcessorFactory.createConnection(bean); |
||||||
|
validate(bean.getConnectionName(), connection); |
||||||
|
ConnectionProcessorFactory.addConnection(bean); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void delete(ConnectionInfoBean bean) throws Exception { |
||||||
|
ConnectionProcessorFactory.deleteConnection(bean.getConnectionName()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(ConnectionInfoBean bean) throws Exception { |
||||||
|
Connection connection = ConnectionProcessorFactory.createConnection(bean); |
||||||
|
validate(bean.getConnectionName(), connection); |
||||||
|
ConnectionProcessorFactory.updateConnection(bean.getConnectionName(), bean); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean lock(String str) { |
||||||
|
// 本地默认锁定成功,让其执行后续动作
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean unlock(String str) { |
||||||
|
// 本地默认解锁成功
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isLock(String str) { |
||||||
|
// 本地默认未锁定
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
private void validate(String name, Connection connection) throws SQLException { |
||||||
|
try { |
||||||
|
connection.validateSettings(); |
||||||
|
} catch (DriverClassNotFoundException e) { |
||||||
|
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||||
|
} catch (Exception e) { |
||||||
|
throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", name) + ", " + e.getMessage(), e.getCause()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue