1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.es.user.cbean.bs;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.codelibs.fesen.action.search.SearchRequestBuilder;
23 import org.codelibs.fesen.index.query.QueryBuilder;
24 import org.codelibs.fess.es.user.allcommon.EsAbstractConditionBean;
25 import org.codelibs.fess.es.user.bsentity.dbmeta.RoleDbm;
26 import org.codelibs.fess.es.user.cbean.RoleCB;
27 import org.codelibs.fess.es.user.cbean.ca.RoleCA;
28 import org.codelibs.fess.es.user.cbean.ca.bs.BsRoleCA;
29 import org.codelibs.fess.es.user.cbean.cq.RoleCQ;
30 import org.codelibs.fess.es.user.cbean.cq.bs.BsRoleCQ;
31 import org.dbflute.cbean.ConditionQuery;
32
33
34
35
36 public class BsRoleCB extends EsAbstractConditionBean {
37
38
39
40
41 protected BsRoleCQ _conditionQuery;
42 protected BsRoleCA _conditionAggregation;
43 protected HpSpecification _specification;
44
45
46
47
48 @Override
49 public RoleDbm asDBMeta() {
50 return RoleDbm.getInstance();
51 }
52
53 @Override
54 public String asTableDbName() {
55 return "role";
56 }
57
58 @Override
59 public boolean hasSpecifiedColumn() {
60 return _specification != null;
61 }
62
63 @Override
64 public ConditionQuery localCQ() {
65 return doGetConditionQuery();
66 }
67
68
69
70
71 public RoleCB acceptPK(String id) {
72 assertObjectNotNull("id", id);
73 BsRoleCB cb = this;
74 cb.query().docMeta().setId_Equal(id);
75 return (RoleCB) this;
76 }
77
78 @Override
79 public void acceptPrimaryKeyMap(Map<String, ? extends Object> primaryKeyMap) {
80 acceptPK((String) primaryKeyMap.get("_id"));
81 }
82
83
84
85
86
87 @Override
88 public SearchRequestBuilder build(SearchRequestBuilder builder) {
89 if (_conditionQuery != null) {
90 QueryBuilder queryBuilder = _conditionQuery.getQuery();
91 if (queryBuilder != null) {
92 builder.setQuery(queryBuilder);
93 }
94 _conditionQuery.getFieldSortBuilderList().forEach(sort -> {
95 builder.addSort(sort);
96 });
97 }
98
99 if (_conditionAggregation != null) {
100 _conditionAggregation.getAggregationBuilderList().forEach(builder::addAggregation);
101 }
102
103 if (_specification != null) {
104 builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null);
105 }
106
107 return builder;
108 }
109
110
111
112
113 public BsRoleCQ query() {
114 assertQueryPurpose();
115 return doGetConditionQuery();
116 }
117
118 protected BsRoleCQ doGetConditionQuery() {
119 if (_conditionQuery == null) {
120 _conditionQuery = createLocalCQ();
121 }
122 return _conditionQuery;
123 }
124
125 protected BsRoleCQ createLocalCQ() {
126 return new RoleCQ();
127 }
128
129
130
131
132 public BsRoleCA aggregation() {
133 assertAggregationPurpose();
134 return doGetConditionAggregation();
135 }
136
137 protected BsRoleCA doGetConditionAggregation() {
138 if (_conditionAggregation == null) {
139 _conditionAggregation = createLocalCA();
140 }
141 return _conditionAggregation;
142 }
143
144 protected BsRoleCA createLocalCA() {
145 return new RoleCA();
146 }
147
148
149
150
151 public HpSpecification specify() {
152 assertSpecifyPurpose();
153 if (_specification == null) {
154 _specification = new HpSpecification();
155 }
156 return _specification;
157 }
158
159 protected void assertQueryPurpose() {
160 }
161
162 protected void assertAggregationPurpose() {
163 }
164
165 protected void assertSpecifyPurpose() {
166 }
167
168 public static class HpSpecification {
169 protected List<String> columnList = new ArrayList<>();
170
171 private void doColumn(String name) {
172 columnList.add(name);
173 }
174
175 public void columnId() {
176 doColumn("_id");
177 }
178
179 public void columnName() {
180 doColumn("name");
181 }
182 }
183 }