Browse Source

Pull request #8859: REPORT-71157 alphafine 高级搜索功能失效 && REPORT-67417 搜索历史/已读动态 加上持久化

Merge in DESIGN/design from ~HADES/design:release/11.0 to release/11.0

* commit '1a49e536029074c7204514d3e3054c0d17bbea46':
  REPORT-67417 搜索历史/已读动态 加上持久化
  REPORT-71157 alphafine 高级搜索功能失效
newui
Hades 3 years ago
parent
commit
9692b2f5f9
  1. 66
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  2. 29
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java

66
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -9,7 +9,7 @@ import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -99,7 +99,6 @@ public class AlphaFineConfigManager implements XMLable {
private String cacheBuildNO; private String cacheBuildNO;
// todo 暂不持久化 方便测试
/** /**
* key: 登录的bbs用户 * key: 登录的bbs用户
* value: alphaFine历史搜索记录 * value: alphaFine历史搜索记录
@ -154,6 +153,10 @@ public class AlphaFineConfigManager implements XMLable {
} else if (reader.isChildNode()) { } else if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) { if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
readActionSearchTextCacheXML(reader); readActionSearchTextCacheXML(reader);
} else if ("SearchHistory".equals(reader.getTagName())) {
readHistorySearch(reader);
} else if ("ReadSet".equals(reader.getTagName())) {
readReadSet(reader);
} }
} }
} }
@ -180,6 +183,47 @@ public class AlphaFineConfigManager implements XMLable {
}); });
} }
private void readHistorySearch(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader xmLableReader) {
if (ComparatorUtils.equals(reader.getTagName(), "history")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY);
Stack<String> stack = new SizedStack<>(3);
List<String> historyList = Arrays.asList(tmpVal.split(","));
for (String history : historyList) {
stack.add(history.trim());
}
historySearchMap.put(reader.getAttrAsString("user", StringUtils.EMPTY), stack);
}
}
}
});
}
private void readReadSet(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader xmLableReader) {
if (ComparatorUtils.equals(reader.getTagName(), "readId")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY);
String[] idArr = tmpVal.split(",");
Set<Long> setId = new HashSet<>();
for (String id : idArr) {
setId.add(Long.parseLong(id.trim()));
}
readSetMap.put(reader.getAttrAsString("user", StringUtils.EMPTY), setId);
}
}
}
});
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG("AlphaFineConfigManager"); writer.startTAG("AlphaFineConfigManager");
@ -198,6 +242,8 @@ public class AlphaFineConfigManager implements XMLable {
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()) .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService())
.attr("productDynamics", this.isProductDynamics()); .attr("productDynamics", this.isProductDynamics());
writeActionSearchTextCacheXML(writer); writeActionSearchTextCacheXML(writer);
writeSearchHistory(writer);
writeReadSet(writer);
writer.end(); writer.end();
} }
@ -212,6 +258,22 @@ public class AlphaFineConfigManager implements XMLable {
writer.end(); writer.end();
} }
private void writeSearchHistory(XMLPrintWriter writer) {
writer.startTAG("SearchHistory");
for (Map.Entry<String, Stack<String>> entry : historySearchMap.entrySet()) {
writer.startTAG("history").attr("user", entry.getKey()).textNode(entry.getValue().toString()).end();
}
writer.end();
}
private void writeReadSet(XMLPrintWriter writer) {
writer.startTAG("ReadSet");
for (Map.Entry<String, Set<Long>> entry : readSetMap.entrySet()) {
writer.startTAG("readId").attr("user", entry.getKey()).textNode(entry.getValue().toString()).end();
}
writer.end();
}
public boolean isSearchOnLine() { public boolean isSearchOnLine() {
return searchOnLine; return searchOnLine;
} }

29
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java

@ -77,6 +77,18 @@ import javax.swing.Timer;
public class AlphaFineFrame extends JFrame { public class AlphaFineFrame extends JFrame {
private static final String ADVANCED_SEARCH_MARK = "k:"; private static final String ADVANCED_SEARCH_MARK = "k:";
private static final String ACTION_MARK_SHORT = "k:1 ";
private static final String ACTION_MARK = "k:setting ";
private static final String DOCUMENT_MARK_SHORT = "k:2 ";
private static final String DOCUMENT_MARK = "k:help ";
private static final String FILE_MARK_SHORT = "k:3 ";
private static final String FILE_MARK = "k:reportlets ";
private static final String CPT_MARK = "k:cpt ";
private static final String FRM_MARK = "k:frm ";
private static final String DS_MARK = "k:ds ";
private static final String DS_NAME = "dsname=\"";
private static final String PLUGIN_MARK_SHORT = "k:4 ";
private static final String PLUGIN_MARK = "k:shop ";
private static final int TIMER_DELAY = 300; private static final int TIMER_DELAY = 300;
@ -663,7 +675,7 @@ public class AlphaFineFrame extends JFrame {
private void doSearch(String text) { private void doSearch(String text) {
initSearchLoadingPane(); initSearchLoadingPane();
SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult); SearchTextBean searchTextBean = generateSearchTextBean(text);
this.productNewsSearchWorkerManager.doSearch(searchTextBean); this.productNewsSearchWorkerManager.doSearch(searchTextBean);
this.settingSearchWorkerManager.doSearch(searchTextBean); this.settingSearchWorkerManager.doSearch(searchTextBean);
this.fileSearchWorkerManager.doSearch(searchTextBean); this.fileSearchWorkerManager.doSearch(searchTextBean);
@ -671,6 +683,21 @@ public class AlphaFineFrame extends JFrame {
this.pluginSearchWorkerManager.doSearch(searchTextBean); this.pluginSearchWorkerManager.doSearch(searchTextBean);
} }
private SearchTextBean generateSearchTextBean(String searchText) {
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)
|| searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) {
return new SearchTextBean(StringUtils.EMPTY, new String[]{getStoreText(searchText)});
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)
|| searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)
|| searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) {
return new SearchTextBean(getStoreText(searchText), new String[]{getStoreText(searchText)});
} else if (searchText.startsWith(DS_MARK)) {
return new SearchTextBean(getStoreText(searchText), new String[]{DS_NAME + getStoreText(searchText)});
} else {
return new SearchTextBean(searchText, segmentationResult);
}
}
/** /**
* 仅搜索依赖网络的搜索项 * 仅搜索依赖网络的搜索项
* *

Loading…
Cancel
Save