Browse Source

REPORT-68727 【迭代】【数据集管理优化】搜索数据列未加载的数据集,该数据集未被搜索

【问题原因】测试用sleep来模拟取数慢,在取列名的时候会造成一些奇怪的错误
【改动思路】1.因为计算列名里做了异常处理,所以跟产品沟通后确定逻辑为列名为空时,就不展示整个数据集节点了;2.产品让把最大搜索时间的限制去掉
【review建议】无
feature/x
Yvan 3 years ago
parent
commit
7a61b9b28d
  1. 11
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java
  2. 6
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java
  3. 64
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java
  4. 22
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java

11
designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java

@ -1,7 +1,6 @@
package com.fr.design.data.datapane.management.search;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.TableDataTree;
import com.fr.design.data.datapane.TableDataTreePane;
@ -10,11 +9,7 @@ import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChang
import com.fr.design.data.datapane.management.search.searcher.TableDataSearchMode;
import com.fr.design.data.datapane.management.search.searcher.TableDataTreeSearcher;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.data.datapane.management.search.time.TableDataSearchTimer;
import com.fr.design.data.datapane.management.search.view.TreeSearchRendererHelper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.general.NameObject;
import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities;
@ -137,8 +132,6 @@ public class TableDataTreeSearchManager {
setTreeSearchStatus(TreeSearchStatus.SEARCHING);
rendererHelper.replaceTreeRenderer(getCurrentTableDataTree(), searchText);
count = new AtomicInteger(treeSearcher.getAllWrappersSize());
// 计时开始
TableDataSearchTimer.getInstance().startClock();
treeSearcher.startSearch(searchText);
}
@ -176,7 +169,6 @@ public class TableDataTreeSearchManager {
*/
public void stopSearch() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_STOPPED);
TableDataSearchTimer.getInstance().stopClock();
count = null;
treeSearcher.stopSearch();
}
@ -186,7 +178,6 @@ public class TableDataTreeSearchManager {
*/
public void completeSearch() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_COMPLETED);
TableDataSearchTimer.getInstance().stopClock();
count = null;
treeSearcher.completeSearch();
}
@ -196,7 +187,6 @@ public class TableDataTreeSearchManager {
*/
public void restoreToolBarAndTreePane() {
setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE);
TableDataSearchTimer.getInstance().stopClock();
if (treeSearcher != null) {
treeSearcher.afterSearch();
}
@ -211,7 +201,6 @@ public class TableDataTreeSearchManager {
*/
public void restoreTreePane() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN);
TableDataSearchTimer.getInstance().stopClock();
lastSearchText = null;
if (rendererHelper != null) {
rendererHelper.restore(getCurrentTableDataTree());

6
designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java

@ -1,10 +1,8 @@
package com.fr.design.data.datapane.management.search.control.common;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.control.TreeSearchCallback;
import com.fr.design.data.datapane.management.search.control.TreeSearchResult;
import com.fr.design.data.datapane.management.search.control.TreeSearchTask;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.log.FineLoggerFactory;
@ -70,6 +68,10 @@ public class TableDataSearchTask implements TreeSearchTask {
String tableDataName = tableDataWrapper.getTableDataName();
boolean isTableDataNameMatch = isMatchSearch(tableDataName, searchText);
List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
// 没取到列名的话,代表取数那边出错了,就不添加数据集了
if (columnNameList.size() == 0) {
return new TableDataSearchResult.Builder().buildSuccess(false).build();
}
boolean isColumnMatch = columnNameList.stream().anyMatch(columnName -> isMatchSearch(columnName, searchText));
return new TableDataSearchResult.Builder()
.buildSuccess(true)

64
designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java

@ -1,64 +0,0 @@
package com.fr.design.data.datapane.management.search.time;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.general.ComparatorUtils;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 搜索任务定时器
*
* @author Yvan
*/
public class TableDataSearchTimer {
/**
* 定时器
*/
private static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(TableDataSearchTimer.class));
/**
* 定时任务
*/
private TableDataSearchTimerTask timeTask;
/**
* 最大单次startSearch的时间
*/
public static final long MAX_SEARCH_TIME = 5000;
private TableDataSearchTimer() {
}
private static class Holder {
private static final TableDataSearchTimer INSTANCE = new TableDataSearchTimer();
}
public static TableDataSearchTimer getInstance() {
return Holder.INSTANCE;
}
public void startClock() {
this.timeTask = new TableDataSearchTimerTask();
scheduler.schedule(timeTask, MAX_SEARCH_TIME, TimeUnit.MILLISECONDS);
}
public void stopClock() {
this.timeTask = null;
}
public void shutdown() {
scheduler.shutdown();
}
/**
* 判断是不是当前的Timer中的task为了避免shutdownNow()之后原task仍在执行可能会
* @param task
* @return
*/
public boolean isCurrentTask(TableDataSearchTimerTask task) {
return ComparatorUtils.equals(this.timeTask, task);
}
}

22
designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java

@ -1,22 +0,0 @@
package com.fr.design.data.datapane.management.search.time;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
/**
* @author Yvan
*/
public class TableDataSearchTimerTask implements Runnable {
public TableDataSearchTimerTask() {
}
@Override
public void run() {
// 最大单次搜索时间过后,将结束搜索
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING &&
TableDataSearchTimer.getInstance().isCurrentTask(this)) {
TableDataTreeSearchManager.getInstance().completeSearch();
}
}
}
Loading…
Cancel
Save