Browse Source

REPORT-67417 搜索历史/已读动态 加上持久化

release/11.0
hades 2 years ago
parent
commit
1a49e53602
  1. 66
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.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.XMLable;
import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@ -99,7 +99,6 @@ public class AlphaFineConfigManager implements XMLable {
private String cacheBuildNO;
// todo 暂不持久化 方便测试
/**
* key: 登录的bbs用户
* value: alphaFine历史搜索记录
@ -154,6 +153,10 @@ public class AlphaFineConfigManager implements XMLable {
} else if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
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
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("AlphaFineConfigManager");
@ -198,6 +242,8 @@ public class AlphaFineConfigManager implements XMLable {
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService())
.attr("productDynamics", this.isProductDynamics());
writeActionSearchTextCacheXML(writer);
writeSearchHistory(writer);
writeReadSet(writer);
writer.end();
}
@ -212,6 +258,22 @@ public class AlphaFineConfigManager implements XMLable {
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() {
return searchOnLine;
}

Loading…
Cancel
Save