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 org.codelibs.core.beans.util.BeanUtil;
21 import org.codelibs.core.lang.StringUtil;
22 import org.codelibs.fess.Constants;
23 import org.codelibs.fess.app.pager.BoostDocPager;
24 import org.codelibs.fess.mylasta.direction.FessConfig;
25 import org.codelibs.fess.opensearch.config.cbean.BoostDocumentRuleCB;
26 import org.codelibs.fess.opensearch.config.exbhv.BoostDocumentRuleBhv;
27 import org.codelibs.fess.opensearch.config.exentity.BoostDocumentRule;
28 import org.dbflute.cbean.result.PagingResultBean;
29 import org.dbflute.optional.OptionalEntity;
30
31 import jakarta.annotation.Resource;
32
33
34
35
36
37 public class BoostDocumentRuleService extends FessAppService {
38
39
40
41 public BoostDocumentRuleService() {
42 super();
43 }
44
45
46 @Resource
47 protected BoostDocumentRuleBhv boostDocumentRuleBhv;
48
49
50 @Resource
51 protected FessConfig fessConfig;
52
53
54
55
56
57
58 public List<BoostDocumentRule> getBoostDocumentRuleList(final BoostDocPager boostDocumentRulePager) {
59
60 final PagingResultBean<BoostDocumentRule> boostDocumentRuleList = boostDocumentRuleBhv.selectPage(cb -> {
61 cb.paging(boostDocumentRulePager.getPageSize(), boostDocumentRulePager.getCurrentPageNumber());
62 setupListCondition(cb, boostDocumentRulePager);
63 });
64
65
66 BeanUtil.copyBeanToBean(boostDocumentRuleList, boostDocumentRulePager, option -> option.include(Constants.PAGER_CONVERSION_RULE));
67 boostDocumentRulePager.setPageNumberList(
68 boostDocumentRuleList.pageRange(op -> op.rangeSize(fessConfig.getPagingPageRangeSizeAsInteger())).createPageNumberList());
69
70 return boostDocumentRuleList;
71 }
72
73
74
75
76
77
78 public OptionalEntity<BoostDocumentRule> getBoostDocumentRule(final String id) {
79 return boostDocumentRuleBhv.selectByPK(id);
80 }
81
82
83
84
85
86 public void store(final BoostDocumentRule boostDocumentRule) {
87
88 boostDocumentRuleBhv.insertOrUpdate(boostDocumentRule, op -> op.setRefreshPolicy(Constants.TRUE));
89
90 }
91
92
93
94
95
96 public void delete(final BoostDocumentRule boostDocumentRule) {
97
98 boostDocumentRuleBhv.delete(boostDocumentRule, op -> op.setRefreshPolicy(Constants.TRUE));
99
100 }
101
102
103
104
105
106
107 protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocPager boostDocumentRulePager) {
108 if (StringUtil.isNotBlank(boostDocumentRulePager.urlExpr)) {
109 cb.query().setUrlExpr_Wildcard(wrapQuery(boostDocumentRulePager.urlExpr));
110 }
111 if (StringUtil.isNotBlank(boostDocumentRulePager.boostExpr)) {
112 cb.query().setBoostExpr_Wildcard(wrapQuery(boostDocumentRulePager.boostExpr));
113 }
114
115
116
117 cb.query().addOrderBy_SortOrder_Asc();
118 cb.query().addOrderBy_CreatedTime_Asc();
119
120
121
122 }
123
124 }