Browse Source

Merge pull request #12998 in DESIGN/design from bugfix/11.0 to feature/x

* commit '8fd2ffb10fe1c133a1a79ea0917ae0f4b71b9e84':
  REPORT-107992 移动下单测位置
  REPORT-107992 改一下实现 & 格式优化
  REPORT-107992 【日志记录数据连接操作】设计器修改数据连接和数据集名称后操作日志会记录大片不好区分
  REPORT-101549 【版本管理二期】迁移失败直接进入版本管理没有更新提示,二次进入就有了
  REPORT-102182 【版本管理三期】版本详情,批量删除,部分失败的场景,页面不会实时刷新
feature/x
superman 1 year ago
parent
commit
f4466565fb
  1. 93
      designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java
  2. 31
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  4. 14
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsProcessFailedWrapper.java
  5. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java
  6. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java
  7. 57
      designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java

93
designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java

@ -1,93 +0,0 @@
package com.fr.design.data;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2022/3/28
*/
public final class MapCompareUtils {
/**
* 对比两个map 查找出相比origother中有哪些是新增的删除的或者被修改的并分别进行处理
*
* 对比时默认用equals方法来判断是否为 EntryEventKind#UPDATED
*
* @param orig 原始map
* @param other 参考的新map
* @param eventHandler 有区别时的事件处理器
* @param <K> K
* @param <V> V
*/
public static <K, V> void contrastMapEntries(@NotNull Map<K, V> orig, @NotNull Map<K, V> other, @NotNull EventHandler<K, V> eventHandler) {
contrastMapEntries(orig, other, eventHandler, UpdateRule.DEFAULT);
}
/**
* 对比两个map 查找出相比origother中有哪些是新增的删除的或者被修改的并分别进行处理
*
* 对比时用自定义的规则来判断是否为 EntryEventKind#UPDATED
*
* @param orig 原始map
* @param other 参考的新map
* @param eventHandler 有区别时的事件处理器
* @param updateRule 自定义的Update事件判定规则
* @param <K>
* @param <V>
*/
public static <K, V> void contrastMapEntries(@NotNull Map<K, V> orig, @NotNull Map<K, V> other, @NotNull EventHandler<K, V> eventHandler, @NotNull UpdateRule<K, V> updateRule) {
Map<K, V> copiedOrig = new LinkedHashMap<>(orig);
other.forEach((k, v) -> {
V existedV = copiedOrig.remove(k);
if (existedV != null) {
if (updateRule.needUpdate(existedV, v)) {
eventHandler.on(EntryEventKind.UPDATED, k, v);
}
} else {
eventHandler.on(EntryEventKind.ADDED, k, v);
}
});
copiedOrig.forEach((k, v) -> eventHandler.on(EntryEventKind.REMOVED, k, v));
}
/**
* 事件处理器对应比较后的三种结果的事件处理
* @param <K>
* @param <V>
*/
public interface EventHandler<K, V> {
void on(EntryEventKind entryEventKind, K k, V v);
}
/**
* 数据被修改(EntryEventKind.UPDATED) 的判定规则
* @param <K>
* @param <V>
*/
public interface UpdateRule<K, V> {
EntryEventKind eventKind = EntryEventKind.UPDATED;
UpdateRule DEFAULT = new UpdateRule() {};
default boolean needUpdate(V origin, V v) {
return !v.equals(origin);
}
}
public enum EntryEventKind {
ADDED,
REMOVED,
UPDATED;
}
}

31
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -236,17 +236,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override @Override
public void update(TableDataConfig tableDataConfig) { public void update(TableDataConfig tableDataConfig) {
Nameable[] tableDataArray = this.update(); List<TableDataBean> tableDataBeans = getUpdateTableDataBeans();
List<TableDataBean> tableDataBeans = new ArrayList<>();
Map<String, String> map = MapUtils.invertMap(getDsNameChangedMap());
for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i];
String oldName = map.get(nameObject.getName());
if (oldName == null) {
oldName = StringUtils.EMPTY;
}
tableDataBeans.add(new TableDataBean(nameObject.getName(), oldName, (TableData) nameObject.getObject()));
}
try { try {
WorkContext.getCurrent().get(TableDataOperator.class, new ExceptionHandler() { WorkContext.getCurrent().get(TableDataOperator.class, new ExceptionHandler() {
@Override @Override
@ -263,6 +253,25 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
} }
} }
/**
* 获取更新时的数据集快照
*
* @return 快照
*/
private List<TableDataBean> getUpdateTableDataBeans() {
Nameable[] tableDataArray = this.update();
List<TableDataBean> tableDataBeans = new ArrayList<>();
Map<String, String> map = MapUtils.invertMap(getDsNameChangedMap());
for (Nameable nameable : tableDataArray) {
NameObject nameObject = (NameObject) nameable;
String oldName = map.get(nameObject.getName());
if (oldName == null) {
oldName = StringUtils.EMPTY;
}
tableDataBeans.add(new TableDataBean(nameObject.getName(), oldName, (TableData) nameObject.getObject()));
}
return tableDataBeans;
}
private boolean saveByOldWay(List<TableDataBean> tableDataBean) { private boolean saveByOldWay(List<TableDataBean> tableDataBean) {
try { try {
return TableDataOperatorImpl.getInstance().saveTableData(tableDataBean); return TableDataOperatorImpl.getInstance().saveTableData(tableDataBean);

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

@ -9,7 +9,7 @@ import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.metric.utils.DatabaseConnectionMetricHandler; import com.fr.data.metric.utils.DatabaseConnectionMetricHandler;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.MapCompareUtils; import com.fr.general.MapCompareUtils;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.fun.ConnectionProvider; import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;

14
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsProcessFailedWrapper.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.vcs; package com.fr.design.mainframe.vcs;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -51,6 +52,19 @@ public class VcsProcessFailedWrapper {
return detailList; return detailList;
} }
/**
* 是否失败
*/
public boolean isFalse(VcsTableEntity entity) {
for (VcsEntity vcsEntity : failedList) {
if (StringUtils.equals(vcsEntity.getFilename(), entity.getFilename())
&& vcsEntity.getVersion() == entity.getEntity().getVersion()) {
return true;
}
}
return false;
}
/** /**
* 处理是否全部成功 * 处理是否全部成功
*/ */

2
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java

@ -232,7 +232,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
} }
private void updateVcsUI(VcsProcessFailedWrapper wrapper) { private void updateVcsUI(VcsProcessFailedWrapper wrapper) {
tableEntities = model.getList().stream().filter(tableEntity -> !tableEntity.isSelect() || wrapper.getFailedNameList().contains(tableEntity.getFilename())).collect(Collectors.toList()); tableEntities = model.getList().stream().filter(tableEntity -> !tableEntity.isSelect() || wrapper.isFalse(tableEntity)).collect(Collectors.toList());
model.setList(new ArrayList<>(tableEntities)); model.setList(new ArrayList<>(tableEntities));
model.fireTableDataChanged(); model.fireTableDataChanged();
fireVcsListener(model.getList()); fireVcsListener(model.getList());

2
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java

@ -371,7 +371,7 @@ public class VcsMovePanel extends BasicPane {
private void doAfterMove() { private void doAfterMove() {
visible = !VcsHelper.getInstance().isLegacyMode(); visible = !VcsHelper.getInstance().isLegacyMode();
initVcsLabel(updatePane); initVcsLabel(updatePane);
updatePane.setVisible(visible); updatePane.setVisible(!visible);
callBack.doCallBack(visible); callBack.doCallBack(visible);
parentCard.show(parentPane, SETTING); parentCard.show(parentPane, SETTING);
} }

57
designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java

@ -1,57 +0,0 @@
package com.fr.design.data;
import org.junit.Assert;
import org.junit.Test;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2022/3/28
*/
public class MapCompareUtilsTest {
@Test
public void contrastMapEntries() {
Map<String, String> orig = new LinkedHashMap<>();
orig.put("aaa", "aaa");
orig.put("bbb", "bbb");
orig.put("ccc", "ccc");
orig.put("ddd", "ddd");
Map<String, String> other = new LinkedHashMap<>();
other.put("aaa", "111");
other.put("bbb", "bbb");
other.put("ccc", "ccc");
other.put("eee", "eee");
MapCompareUtils.contrastMapEntries(orig, other, new MapCompareUtils.EventHandler<String, String>() {
@Override
public void on(MapCompareUtils.EntryEventKind entryEventKind, String s, String s2) {
switch (entryEventKind) {
case UPDATED:
Assert.assertEquals(s, "aaa");
Assert.assertEquals(s2, "111");
break;
case REMOVED:
Assert.assertEquals(s, "ddd");
break;
case ADDED:
Assert.assertEquals(s, "eee");
Assert.assertEquals(s2, "eee");
break;
default:
Assert.fail();
}
}
});
}
}
Loading…
Cancel
Save