1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.es.config.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.config.allcommon.EsAbstractConditionBean;
25 import org.codelibs.fess.es.config.bsentity.dbmeta.AccessTokenDbm;
26 import org.codelibs.fess.es.config.cbean.AccessTokenCB;
27 import org.codelibs.fess.es.config.cbean.ca.AccessTokenCA;
28 import org.codelibs.fess.es.config.cbean.ca.bs.BsAccessTokenCA;
29 import org.codelibs.fess.es.config.cbean.cq.AccessTokenCQ;
30 import org.codelibs.fess.es.config.cbean.cq.bs.BsAccessTokenCQ;
31 import org.dbflute.cbean.ConditionQuery;
32
33
34
35
36 public class BsAccessTokenCB extends EsAbstractConditionBean {
37
38
39
40
41 protected BsAccessTokenCQ _conditionQuery;
42 protected BsAccessTokenCA _conditionAggregation;
43 protected HpSpecification _specification;
44
45
46
47
48 @Override
49 public AccessTokenDbm asDBMeta() {
50 return AccessTokenDbm.getInstance();
51 }
52
53 @Override
54 public String asTableDbName() {
55 return "access_token";
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 AccessTokenCB acceptPK(String id) {
72 assertObjectNotNull("id", id);
73 BsAccessTokenCB cb = this;
74 cb.query().docMeta().setId_Equal(id);
75 return (AccessTokenCB) 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 BsAccessTokenCQ query() {
114 assertQueryPurpose();
115 return doGetConditionQuery();
116 }
117
118 protected BsAccessTokenCQ doGetConditionQuery() {
119 if (_conditionQuery == null) {
120 _conditionQuery = createLocalCQ();
121 }
122 return _conditionQuery;
123 }
124
125 protected BsAccessTokenCQ createLocalCQ() {
126 return new AccessTokenCQ();
127 }
128
129
130
131
132 public BsAccessTokenCA aggregation() {
133 assertAggregationPurpose();
134 return doGetConditionAggregation();
135 }
136
137 protected BsAccessTokenCA doGetConditionAggregation() {
138 if (_conditionAggregation == null) {
139 _conditionAggregation = createLocalCA();
140 }
141 return _conditionAggregation;
142 }
143
144 protected BsAccessTokenCA createLocalCA() {
145 return new AccessTokenCA();
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 columnCreatedBy() {
180 doColumn("createdBy");
181 }
182
183 public void columnCreatedTime() {
184 doColumn("createdTime");
185 }
186
187 public void columnExpiredTime() {
188 doColumn("expiredTime");
189 }
190
191 public void columnName() {
192 doColumn("name");
193 }
194
195 public void columnParameterName() {
196 doColumn("parameter_name");
197 }
198
199 public void columnPermissions() {
200 doColumn("permissions");
201 }
202
203 public void columnToken() {
204 doColumn("token");
205 }
206
207 public void columnUpdatedBy() {
208 doColumn("updatedBy");
209 }
210
211 public void columnUpdatedTime() {
212 doColumn("updatedTime");
213 }
214 }
215 }