Browse Source

Pull request #14186: REPORT-114391 - 【微服务适配】远程&本地设计器能够正常启动 支持数据连接修改

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp-1.0 to fbp-1.0

* commit 'd633216fbc4d0a149c72add07b5b8492e6690b39':
  REPORT-114391 - 【微服务适配】远程&本地设计器能够正常启动 支持数据连接修改
fbp-1.0
Destiny.Lin-林锦龙 5 months ago
parent
commit
a69a95077e
  1. 33
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

33
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -4,7 +4,6 @@ import com.fanruan.config.impl.data.ConnectionConfigProviderFactory;
import com.fr.config.remote.RemoteConfigEvent; import com.fr.config.remote.RemoteConfigEvent;
import com.fr.data.driver.DriverClassNotFoundException; import com.fr.data.driver.DriverClassNotFoundException;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.ConnectionBean;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.metric.utils.DatabaseConnectionMetricHandler; import com.fr.data.metric.utils.DatabaseConnectionMetricHandler;
@ -31,6 +30,8 @@ import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.database.DataBaseTypeOperator; import com.fr.workspace.server.database.DataBaseTypeOperator;
import com.fr.workspace.server.entity.connection.BatchConnectionModifyBean;
import com.fr.workspace.server.entity.connection.ConnectionBean;
import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.connection.ConnectionRepository;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -217,19 +218,25 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> updatedMap.put(no.getName(), (Connection) no.getObject())); Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> updatedMap.put(no.getName(), (Connection) no.getObject()));
List<String> removedConnNames = new ArrayList<>(); List<String> removedConnNames = new ArrayList<>();
List<ConnectionBean> addedOrUpdatedConnections = new ArrayList<>(); List<ConnectionBean> addConnections = new ArrayList<>();
List<ConnectionBean> updateConnection = new ArrayList<>();
MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> {
switch (entryEventKind) { switch (entryEventKind) {
case REMOVED: case REMOVED:
removedConnNames.add(s); removedConnNames.add(s);
break; break;
case ADDED: case ADDED:
addConnections.add(new ConnectionBean(connection, s));
if (connection instanceof JDBCDatabaseConnection) {
DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null);
}
break;
case UPDATED: case UPDATED:
addedOrUpdatedConnections.add(new ConnectionBean(s, StringUtils.EMPTY, connection)); updateConnection.add(new ConnectionBean(connection, s));
if (connection instanceof JDBCDatabaseConnection) { if (connection instanceof JDBCDatabaseConnection) {
DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null); DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null);
} }
break;
default: default:
break; break;
} }
@ -261,9 +268,12 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
}); });
this.validateDatabaseType(addedOrUpdatedConnections); List<ConnectionBean> validateBeans = new ArrayList<>();
this.validateConnections(addedOrUpdatedConnections); validateBeans.addAll(addConnections);
this.alterConnections(removedConnNames, addedOrUpdatedConnections); validateBeans.addAll(updateConnection);
this.validateDatabaseType(validateBeans);
this.validateConnections(validateBeans);
this.alterConnections(new BatchConnectionModifyBean(addConnections, removedConnNames, updateConnection));
} }
/** /**
@ -326,15 +336,10 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
private void alterConnections(List<String> removedConnNames, List<ConnectionBean> addedOrUpdatedConnections) { private void alterConnections(BatchConnectionModifyBean bean) {
try { try {
ConnectionRepository.getInstance().save(bean);
/// 数据连接要改为单个修改的形式(考虑配合newUI)
ConnectionRepository.getInstance().add(new com.fr.workspace.server.entity.connection.ConnectionBean(addedOrUpdatedConnections.get(0).getConnection(), "FRDemo"));
//WorkContext.getCurrent().get(ConnectionOperator.class, exceptionInfo -> saveByOldWay(removedConnNames, addedOrUpdatedConnections))
// .saveConnection(removedConnNames, addedOrUpdatedConnections);
// hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效 // hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig"); EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig");

Loading…
Cancel
Save