1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.app.service;
17
18 import java.util.List;
19
20 import javax.annotation.Resource;
21
22 import org.codelibs.core.beans.util.BeanUtil;
23 import org.codelibs.core.lang.StringUtil;
24 import org.codelibs.fess.Constants;
25 import org.codelibs.fess.app.pager.BoostDocPager;
26 import org.codelibs.fess.es.config.cbean.BoostDocumentRuleCB;
27 import org.codelibs.fess.es.config.exbhv.BoostDocumentRuleBhv;
28 import org.codelibs.fess.es.config.exentity.BoostDocumentRule;
29 import org.codelibs.fess.mylasta.direction.FessConfig;
30 import org.dbflute.cbean.result.PagingResultBean;
31 import org.dbflute.optional.OptionalEntity;
32
33 public class BoostDocumentRuleService extends FessAppService {
34
35 @Resource
36 protected BoostDocumentRuleBhv boostDocumentRuleBhv;
37
38 @Resource
39 protected FessConfig fessConfig;
40
41 public List<BoostDocumentRule> getBoostDocumentRuleList(final BoostDocPager boostDocumentRulePager) {
42
43 final PagingResultBean<BoostDocumentRule> boostDocumentRuleList = boostDocumentRuleBhv.selectPage(cb -> {
44 cb.paging(boostDocumentRulePager.getPageSize(), boostDocumentRulePager.getCurrentPageNumber());
45 setupListCondition(cb, boostDocumentRulePager);
46 });
47
48
49 BeanUtil.copyBeanToBean(boostDocumentRuleList, boostDocumentRulePager, option -> option.include(Constants.PAGER_CONVERSION_RULE));
50 boostDocumentRulePager.setPageNumberList(
51 boostDocumentRuleList.pageRange(op -> op.rangeSize(fessConfig.getPagingPageRangeSizeAsInteger())).createPageNumberList());
52
53 return boostDocumentRuleList;
54 }
55
56 public OptionalEntity<BoostDocumentRule> getBoostDocumentRule(final String id) {
57 return boostDocumentRuleBhv.selectByPK(id);
58 }
59
60 public void store(final BoostDocumentRule boostDocumentRule) {
61
62 boostDocumentRuleBhv.insertOrUpdate(boostDocumentRule, op -> op.setRefreshPolicy(Constants.TRUE));
63
64 }
65
66 public void delete(final BoostDocumentRule boostDocumentRule) {
67
68 boostDocumentRuleBhv.delete(boostDocumentRule, op -> op.setRefreshPolicy(Constants.TRUE));
69
70 }
71
72 protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocPager boostDocumentRulePager) {
73 if (StringUtil.isNotBlank(boostDocumentRulePager.urlExpr)) {
74 cb.query().setUrlExpr_Wildcard(wrapQuery(boostDocumentRulePager.urlExpr));
75 }
76 if (StringUtil.isNotBlank(boostDocumentRulePager.boostExpr)) {
77 cb.query().setBoostExpr_Wildcard(wrapQuery(boostDocumentRulePager.boostExpr));
78 }
79
80
81
82 cb.query().addOrderBy_SortOrder_Asc();
83 cb.query().addOrderBy_CreatedTime_Asc();
84
85
86
87 }
88
89 }