Browse Source

REPORT-68607 数据连接配置操作放事务

security/10.0
rinoux 3 years ago
parent
commit
e9e97d907a
  1. 17
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

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

@ -20,6 +20,8 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
@ -163,18 +165,29 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
Map<String, Connection> updatedMap = new LinkedHashMap<>(); Map<String, Connection> updatedMap = new LinkedHashMap<>();
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<>();
Map<String, Connection> addedOrUpdatedConnections = new LinkedHashMap<>();
MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> {
switch (entryEventKind) { switch (entryEventKind) {
case REMOVED: case REMOVED:
connectionConfig.removeConnection(s); removedConnNames.add(s);
break; break;
case ADDED: case ADDED:
case UPDATED: case UPDATED:
connectionConfig.addConnection(s, connection); addedOrUpdatedConnections.put(s, connection);
default: default:
break; break;
} }
}); });
// 之前丢有可能是因为没有放事务里吧
Configurations.modify(new WorkerFacade(ConnectionConfig.class) {
@Override
public void run() {
removedConnNames.forEach(n -> ConnectionConfig.getInstance().removeConnection(n));
addedOrUpdatedConnections.forEach((name, conn) -> ConnectionConfig.getInstance().addConnection(name, conn));
}
});
} }
@Override @Override

Loading…
Cancel
Save