use of com.kyj.fx.voeditor.visual.framework.RealtimeSearchVO in project Gargoyle by callakrsos.
the class NrchRealtimeSrchFlowComposite method defineService.
private void defineService() {
/*
* 비동기 실시간 검색어 조회 처리가 기술.
*/
service = new Service<List<RealtimeSearchVO>>() {
@Override
protected Task<List<RealtimeSearchVO>> createTask() {
return new Task<List<RealtimeSearchVO>>() {
@Override
protected List<RealtimeSearchVO> call() throws Exception {
List<RealtimeSearchVO> meta = Collections.emptyList();
try {
meta = NaverRealtimeSrchSupplier.getInstance().getMeta();
} catch (Exception e) {
DialogUtil.showExceptionDailog(e);
}
return meta;
}
};
}
};
service.setOnCancelled(stat -> {
if (State.CANCELLED == stat.getSource().getState()) {
LOGGER.debug("Cancel Requested");
}
});
service.setOnSucceeded(stat -> {
applyResponseTime(DateUtil.getCurrentDateString());
FlowCardComposite value = new FlowCardComposite();
flowCardComposite.set(value);
this.getParent().setCenter(flowCardComposite.get());
FlowCardComposite tmp = flowCardComposite.get();
ObservableList<Node> flowChildrens = tmp.getFlowChildrens();
tmp.setLimitColumn(20);
data.setAll((List<RealtimeSearchVO>) stat.getSource().getValue());
List<VBox> collect = data.stream().map(nodeConverter::apply).flatMap(v -> v.stream()).collect(Collectors.toList());
flowChildrens.setAll(collect);
if (isRecycle.get()) {
WaitThread waitThread = new WaitThread(THREAD_RUNNER_GROUP, choWaitItems.getValue()) {
@Override
public boolean isContinue() {
return isRecycle.get();
}
@Override
public void execute() {
Platform.runLater(() -> {
if (isContinue())
service.restart();
});
}
@Override
public boolean isRecycle() {
return isRecycle.get();
}
};
waitThread.setDaemon(true);
waitThread.start();
}
});
}
use of com.kyj.fx.voeditor.visual.framework.RealtimeSearchVO in project Gargoyle by callakrsos.
the class NaverRealtimeSearchFactory method parse.
public List<RealtimeSearchVO> parse(String htmlBody) {
Document doc = Jsoup.parse(htmlBody);
Elements r = doc.select("[class*='realtime_srch']");
Elements select = r.select(".lst_realtime_srch");
List<RealtimeSearchVO> realtimeSearchItems = select.stream().map(e -> {
RealtimeSearchVO realtimeSearchVO = null;
Element previousElementSibling = e.previousElementSibling();
if (previousElementSibling != null) {
realtimeSearchVO = new RealtimeSearchVO();
String text = previousElementSibling.text();
if (text.length() >= 15) {
realtimeSearchVO.setTitle(text.substring(0, 15) + "...");
} else {
realtimeSearchVO.setTitle(text);
}
Elements liTags = e.getElementsByTag("li");
List<RealtimeSearchItemVO> items = liTags.stream().map(li -> {
RealtimeSearchItemVO item = new RealtimeSearchItemVO();
Element aTag = li.getElementsByTag("a").first();
Elements elementsByAttribute = aTag.getElementsByAttribute("href");
String url = elementsByAttribute.attr("href");
Element numElement = li.getElementsByClass("num").first();
String num = numElement.text();
Element titElement = li.getElementsByClass("tit").first();
String title = titElement.text();
item.setRank(Integer.parseInt(num, 10));
item.setKeyword(title);
item.setLink(url);
LOGGER.debug("title [{}] num [{}] url : [{}] , toString : {}", title, num, url, li.toString());
return item;
}).collect(Collectors.toList());
realtimeSearchVO.setItems(items);
}
return realtimeSearchVO;
}).filter(v -> v != null).collect(Collectors.toList());
return realtimeSearchItems;
}
Aggregations