1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.opensearch.config.bsbhv;
17
18 import java.util.List;
19 import java.util.Map;
20
21 import org.codelibs.fess.opensearch.config.allcommon.EsAbstractBehavior;
22 import org.codelibs.fess.opensearch.config.allcommon.EsAbstractEntity.RequestOptionCall;
23 import org.codelibs.fess.opensearch.config.bsentity.dbmeta.WebAuthenticationDbm;
24 import org.codelibs.fess.opensearch.config.cbean.WebAuthenticationCB;
25 import org.codelibs.fess.opensearch.config.exentity.WebAuthentication;
26 import org.dbflute.Entity;
27 import org.dbflute.bhv.readable.CBCall;
28 import org.dbflute.bhv.readable.EntityRowHandler;
29 import org.dbflute.cbean.ConditionBean;
30 import org.dbflute.cbean.result.ListResultBean;
31 import org.dbflute.cbean.result.PagingResultBean;
32 import org.dbflute.exception.IllegalBehaviorStateException;
33 import org.dbflute.optional.OptionalEntity;
34 import org.dbflute.util.DfTypeUtil;
35 import org.opensearch.action.bulk.BulkRequestBuilder;
36 import org.opensearch.action.delete.DeleteRequestBuilder;
37 import org.opensearch.action.index.IndexRequestBuilder;
38
39
40
41
42 public abstract class BsWebAuthenticationBhv extends EsAbstractBehavior<WebAuthentication, WebAuthenticationCB> {
43
44
45
46
47 @Override
48 public String asTableDbName() {
49 return asEsIndexType();
50 }
51
52 @Override
53 protected String asEsIndex() {
54 return "fess_config.web_authentication";
55 }
56
57 @Override
58 public String asEsIndexType() {
59 return "web_authentication";
60 }
61
62 @Override
63 public String asEsSearchType() {
64 return "web_authentication";
65 }
66
67 @Override
68 public WebAuthenticationDbm asDBMeta() {
69 return WebAuthenticationDbm.getInstance();
70 }
71
72 @Override
73 protected <RESULT extends WebAuthentication> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
74 try {
75 final RESULT result = entityType.newInstance();
76 result.setAuthRealm(DfTypeUtil.toString(source.get("authRealm")));
77 result.setCreatedBy(DfTypeUtil.toString(source.get("createdBy")));
78 result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime")));
79 result.setHostname(DfTypeUtil.toString(source.get("hostname")));
80 result.setParameters(DfTypeUtil.toString(source.get("parameters")));
81 result.setPassword(DfTypeUtil.toString(source.get("password")));
82 result.setPort(DfTypeUtil.toInteger(source.get("port")));
83 result.setProtocolScheme(DfTypeUtil.toString(source.get("protocolScheme")));
84 result.setUpdatedBy(DfTypeUtil.toString(source.get("updatedBy")));
85 result.setUpdatedTime(DfTypeUtil.toLong(source.get("updatedTime")));
86 result.setUsername(DfTypeUtil.toString(source.get("username")));
87 result.setWebConfigId(DfTypeUtil.toString(source.get("webConfigId")));
88 return updateEntity(source, result);
89 } catch (InstantiationException | IllegalAccessException e) {
90 final String msg = "Cannot create a new instance: " + entityType.getName();
91 throw new IllegalBehaviorStateException(msg, e);
92 }
93 }
94
95 protected <RESULT extends WebAuthentication> RESULT updateEntity(Map<String, Object> source, RESULT result) {
96 return result;
97 }
98
99
100
101
102 public int selectCount(CBCall<WebAuthenticationCB> cbLambda) {
103 return facadeSelectCount(createCB(cbLambda));
104 }
105
106 public OptionalEntity<WebAuthentication> selectEntity(CBCall<WebAuthenticationCB> cbLambda) {
107 return facadeSelectEntity(createCB(cbLambda));
108 }
109
110 protected OptionalEntity<WebAuthentication> facadeSelectEntity(WebAuthenticationCB cb) {
111 return doSelectOptionalEntity(cb, typeOfSelectedEntity());
112 }
113
114 protected <ENTITY extends WebAuthentication> OptionalEntity<ENTITY> doSelectOptionalEntity(WebAuthenticationCB cb,
115 Class<? extends ENTITY> tp) {
116 return createOptionalEntity(doSelectEntity(cb, tp), cb);
117 }
118
119 @Override
120 public WebAuthenticationCB newConditionBean() {
121 return new WebAuthenticationCB();
122 }
123
124 @Override
125 protected Entity doReadEntity(ConditionBean cb) {
126 return facadeSelectEntity(downcast(cb)).orElse(null);
127 }
128
129 public WebAuthentication selectEntityWithDeletedCheck(CBCall<WebAuthenticationCB> cbLambda) {
130 return facadeSelectEntityWithDeletedCheck(createCB(cbLambda));
131 }
132
133 public OptionalEntity<WebAuthentication> selectByPK(String id) {
134 return facadeSelectByPK(id);
135 }
136
137 protected OptionalEntity<WebAuthentication> facadeSelectByPK(String id) {
138 return doSelectOptionalByPK(id, typeOfSelectedEntity());
139 }
140
141 protected <ENTITY extends WebAuthentication> ENTITY doSelectByPK(String id, Class<? extends ENTITY> tp) {
142 return doSelectEntity(xprepareCBAsPK(id), tp);
143 }
144
145 protected WebAuthenticationCB xprepareCBAsPK(String id) {
146 assertObjectNotNull("id", id);
147 return newConditionBean().acceptPK(id);
148 }
149
150 protected <ENTITY extends WebAuthentication> OptionalEntity<ENTITY> doSelectOptionalByPK(String id, Class<? extends ENTITY> tp) {
151 return createOptionalEntity(doSelectByPK(id, tp), id);
152 }
153
154 @Override
155 protected Class<? extends WebAuthentication> typeOfSelectedEntity() {
156 return WebAuthentication.class;
157 }
158
159 @Override
160 protected Class<WebAuthentication> typeOfHandlingEntity() {
161 return WebAuthentication.class;
162 }
163
164 @Override
165 protected Class<WebAuthenticationCB> typeOfHandlingConditionBean() {
166 return WebAuthenticationCB.class;
167 }
168
169 public ListResultBean<WebAuthentication> selectList(CBCall<WebAuthenticationCB> cbLambda) {
170 return facadeSelectList(createCB(cbLambda));
171 }
172
173 public PagingResultBean<WebAuthentication> selectPage(CBCall<WebAuthenticationCB> cbLambda) {
174
175 return (PagingResultBean<WebAuthentication>) facadeSelectList(createCB(cbLambda));
176 }
177
178 public void selectCursor(CBCall<WebAuthenticationCB> cbLambda, EntityRowHandler<WebAuthentication> entityLambda) {
179 facadeSelectCursor(createCB(cbLambda), entityLambda);
180 }
181
182 public void selectBulk(CBCall<WebAuthenticationCB> cbLambda, EntityRowHandler<List<WebAuthentication>> entityLambda) {
183 delegateSelectBulk(createCB(cbLambda), entityLambda, typeOfSelectedEntity());
184 }
185
186
187
188
189 public void insert(WebAuthentication entity) {
190 doInsert(entity, null);
191 }
192
193 public void insert(WebAuthentication entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
194 entity.asDocMeta().indexOption(opLambda);
195 doInsert(entity, null);
196 }
197
198 public void update(WebAuthentication entity) {
199 doUpdate(entity, null);
200 }
201
202 public void update(WebAuthentication entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
203 entity.asDocMeta().indexOption(opLambda);
204 doUpdate(entity, null);
205 }
206
207 public void insertOrUpdate(WebAuthentication entity) {
208 doInsertOrUpdate(entity, null, null);
209 }
210
211 public void insertOrUpdate(WebAuthentication entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
212 entity.asDocMeta().indexOption(opLambda);
213 doInsertOrUpdate(entity, null, null);
214 }
215
216 public void delete(WebAuthentication entity) {
217 doDelete(entity, null);
218 }
219
220 public void delete(WebAuthentication entity, RequestOptionCall<DeleteRequestBuilder> opLambda) {
221 entity.asDocMeta().deleteOption(opLambda);
222 doDelete(entity, null);
223 }
224
225 public int queryDelete(CBCall<WebAuthenticationCB> cbLambda) {
226 return doQueryDelete(createCB(cbLambda), null);
227 }
228
229 public int[] batchInsert(List<WebAuthentication> list) {
230 return batchInsert(list, null, null);
231 }
232
233 public int[] batchInsert(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call) {
234 return batchInsert(list, call, null);
235 }
236
237 public int[] batchInsert(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call,
238 RequestOptionCall<IndexRequestBuilder> entityCall) {
239 return doBatchInsert(new BulkList<>(list, call, entityCall), null);
240 }
241
242 public int[] batchUpdate(List<WebAuthentication> list) {
243 return batchUpdate(list, null, null);
244 }
245
246 public int[] batchUpdate(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call) {
247 return batchUpdate(list, call, null);
248 }
249
250 public int[] batchUpdate(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call,
251 RequestOptionCall<IndexRequestBuilder> entityCall) {
252 return doBatchUpdate(new BulkList<>(list, call, entityCall), null);
253 }
254
255 public int[] batchDelete(List<WebAuthentication> list) {
256 return batchDelete(list, null, null);
257 }
258
259 public int[] batchDelete(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call) {
260 return batchDelete(list, call, null);
261 }
262
263 public int[] batchDelete(List<WebAuthentication> list, RequestOptionCall<BulkRequestBuilder> call,
264 RequestOptionCall<IndexRequestBuilder> entityCall) {
265 return doBatchDelete(new BulkList<>(list, call, entityCall), null);
266 }
267
268
269 }