|
|
@ -231,7 +231,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh |
|
|
|
List<String> removedConnNames = new ArrayList<>(); |
|
|
|
List<String> removedConnNames = new ArrayList<>(); |
|
|
|
List<ConnectionInfoBean> addConnections = new ArrayList<>(); |
|
|
|
List<ConnectionInfoBean> addConnections = new ArrayList<>(); |
|
|
|
List<ConnectionInfoBean> updateConnection = new ArrayList<>(); |
|
|
|
List<ConnectionInfoBean> updateConnection = new ArrayList<>(); |
|
|
|
List<Connection> validConnection = new ArrayList<>(); |
|
|
|
Map<String, Connection> validConnection = new HashMap<>(); |
|
|
|
MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { |
|
|
|
MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
switch (entryEventKind) { |
|
|
|
switch (entryEventKind) { |
|
|
@ -242,7 +242,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh |
|
|
|
ConnectionInfoBean add = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true); |
|
|
|
ConnectionInfoBean add = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true); |
|
|
|
if (StringUtils.isNotEmpty(add.getConnectionData())) { |
|
|
|
if (StringUtils.isNotEmpty(add.getConnectionData())) { |
|
|
|
addConnections.add(add); |
|
|
|
addConnections.add(add); |
|
|
|
validConnection.add(connection); |
|
|
|
validConnection.put(s, connection); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass()); |
|
|
|
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass()); |
|
|
|
} |
|
|
|
} |
|
|
@ -251,7 +251,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh |
|
|
|
ConnectionInfoBean update = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true); |
|
|
|
ConnectionInfoBean update = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true); |
|
|
|
if (StringUtils.isNotEmpty(update.getConnectionData())) { |
|
|
|
if (StringUtils.isNotEmpty(update.getConnectionData())) { |
|
|
|
updateConnection.add(update); |
|
|
|
updateConnection.add(update); |
|
|
|
validConnection.add(connection); |
|
|
|
validConnection.put(s, connection); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass()); |
|
|
|
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass()); |
|
|
|
} |
|
|
|
} |
|
|
@ -297,7 +297,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh |
|
|
|
}); |
|
|
|
}); |
|
|
|
/// 先不管
|
|
|
|
/// 先不管
|
|
|
|
//this.validateDatabaseType(validConnection);
|
|
|
|
//this.validateDatabaseType(validConnection);
|
|
|
|
this.alterConnections(addConnections, removedConnNames, updateConnection); |
|
|
|
this.alterConnections(addConnections, removedConnNames, updateConnection, validConnection); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -344,26 +344,30 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection) throws Exception { |
|
|
|
private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection, Map<String, Connection> validConnection) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
for (ConnectionInfoBean bean : addConnections) { |
|
|
|
for (ConnectionInfoBean bean : addConnections) { |
|
|
|
ConnectionRepository.getInstance().add(bean); |
|
|
|
ConnectionRepository.getInstance().add(bean); |
|
|
|
|
|
|
|
populatedConnectionsSnapshot.put(bean.getConnectionName(), validConnection.get(bean.getConnectionName())); |
|
|
|
} |
|
|
|
} |
|
|
|
for (ConnectionInfoBean bean : updateConnection) { |
|
|
|
for (ConnectionInfoBean bean : updateConnection) { |
|
|
|
ConnectionRepository.getInstance().update(bean); |
|
|
|
ConnectionRepository.getInstance().update(bean); |
|
|
|
|
|
|
|
populatedConnectionsSnapshot.put(bean.getConnectionName(), validConnection.get(bean.getConnectionName())); |
|
|
|
} |
|
|
|
} |
|
|
|
for (String name : removedConnNames) { |
|
|
|
for (String name : removedConnNames) { |
|
|
|
ConnectionRepository.getInstance().delete(new ConnectionInfoBean(name)); |
|
|
|
ConnectionRepository.getInstance().delete(new ConnectionInfoBean(name)); |
|
|
|
|
|
|
|
populatedConnectionsSnapshot.remove(name); |
|
|
|
} |
|
|
|
} |
|
|
|
// hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效
|
|
|
|
// hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效
|
|
|
|
if (!WorkContext.getCurrent().isLocal()) { |
|
|
|
if (!WorkContext.getCurrent().isLocal()) { |
|
|
|
EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig"); |
|
|
|
EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig"); |
|
|
|
} |
|
|
|
} |
|
|
|
ConnectionRepository.getInstance().invalidCache(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
ConnectionRepository.getInstance().invalidCache(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|