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.Collection;
19 import java.util.List;
20
21 import javax.annotation.Resource;
22
23 import org.codelibs.core.beans.util.BeanUtil;
24 import org.codelibs.fess.Constants;
25 import org.codelibs.fess.app.pager.PathMapPager;
26 import org.codelibs.fess.es.config.cbean.PathMappingCB;
27 import org.codelibs.fess.es.config.exbhv.PathMappingBhv;
28 import org.codelibs.fess.es.config.exentity.PathMapping;
29 import org.codelibs.fess.mylasta.direction.FessConfig;
30 import org.codelibs.fess.util.ComponentUtil;
31 import org.dbflute.cbean.result.PagingResultBean;
32 import org.dbflute.optional.OptionalEntity;
33
34 public class PathMappingService {
35
36 @Resource
37 protected PathMappingBhv pathMappingBhv;
38
39 @Resource
40 protected FessConfig fessConfig;
41
42 public List<PathMapping> getPathMappingList(final PathMapPager pathMappingPager) {
43
44 final PagingResultBean<PathMapping> pathMappingList = pathMappingBhv.selectPage(cb -> {
45 cb.paging(pathMappingPager.getPageSize(), pathMappingPager.getCurrentPageNumber());
46 setupListCondition(cb, pathMappingPager);
47 });
48
49
50 BeanUtil.copyBeanToBean(pathMappingList, pathMappingPager, option -> option.include(Constants.PAGER_CONVERSION_RULE));
51 pathMappingPager.setPageNumberList(pathMappingList.pageRange(op -> {
52 op.rangeSize(fessConfig.getPagingPageRangeSizeAsInteger());
53 }).createPageNumberList());
54
55 return pathMappingList;
56 }
57
58 public OptionalEntity<PathMapping> getPathMapping(final String id) {
59 return pathMappingBhv.selectByPK(id);
60 }
61
62 public void store(final PathMapping pathMapping) {
63
64 pathMappingBhv.insertOrUpdate(pathMapping, op -> {
65 op.setRefreshPolicy(Constants.TRUE);
66 });
67
68 ComponentUtil.getPathMappingHelper().init();
69 }
70
71 public void delete(final PathMapping pathMapping) {
72
73 pathMappingBhv.delete(pathMapping, op -> {
74 op.setRefreshPolicy(Constants.TRUE);
75 });
76
77 ComponentUtil.getPathMappingHelper().init();
78 }
79
80 public List<PathMapping> getPathMappingList(final Collection<String> processTypeList) {
81
82 return pathMappingBhv.selectList(cb -> {
83 cb.query().addOrderBy_SortOrder_Asc();
84 cb.query().setProcessType_InScope(processTypeList);
85 cb.fetchFirst(fessConfig.getPagePathMappingMaxFetchSizeAsInteger());
86 });
87 }
88
89 protected void setupListCondition(final PathMappingCB cb, final PathMapPager pathMappingPager) {
90 if (pathMappingPager.id != null) {
91 cb.query().docMeta().setId_Equal(pathMappingPager.id);
92 }
93
94
95
96 cb.query().addOrderBy_SortOrder_Asc();
97 cb.query().addOrderBy_CreatedTime_Asc();
98
99
100
101 }
102
103 }