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.CrawlingInfoParamDbm;
24 import org.codelibs.fess.opensearch.config.cbean.CrawlingInfoParamCB;
25 import org.codelibs.fess.opensearch.config.exentity.CrawlingInfoParam;
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 BsCrawlingInfoParamBhv extends EsAbstractBehavior<CrawlingInfoParam, CrawlingInfoParamCB> {
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.crawling_info_param";
55 }
56
57 @Override
58 public String asEsIndexType() {
59 return "crawling_info_param";
60 }
61
62 @Override
63 public String asEsSearchType() {
64 return "crawling_info_param";
65 }
66
67 @Override
68 public CrawlingInfoParamDbm asDBMeta() {
69 return CrawlingInfoParamDbm.getInstance();
70 }
71
72 @Override
73 protected <RESULT extends CrawlingInfoParam> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
74 try {
75 final RESULT result = entityType.newInstance();
76 result.setCrawlingInfoId(DfTypeUtil.toString(source.get("crawlingInfoId")));
77 result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime")));
78 result.setKey(DfTypeUtil.toString(source.get("key")));
79 result.setValue(DfTypeUtil.toString(source.get("value")));
80 return updateEntity(source, result);
81 } catch (InstantiationException | IllegalAccessException e) {
82 final String msg = "Cannot create a new instance: " + entityType.getName();
83 throw new IllegalBehaviorStateException(msg, e);
84 }
85 }
86
87 protected <RESULT extends CrawlingInfoParam> RESULT updateEntity(Map<String, Object> source, RESULT result) {
88 return result;
89 }
90
91
92
93
94 public int selectCount(CBCall<CrawlingInfoParamCB> cbLambda) {
95 return facadeSelectCount(createCB(cbLambda));
96 }
97
98 public OptionalEntity<CrawlingInfoParam> selectEntity(CBCall<CrawlingInfoParamCB> cbLambda) {
99 return facadeSelectEntity(createCB(cbLambda));
100 }
101
102 protected OptionalEntity<CrawlingInfoParam> facadeSelectEntity(CrawlingInfoParamCB cb) {
103 return doSelectOptionalEntity(cb, typeOfSelectedEntity());
104 }
105
106 protected <ENTITY extends CrawlingInfoParam> OptionalEntity<ENTITY> doSelectOptionalEntity(CrawlingInfoParamCB cb,
107 Class<? extends ENTITY> tp) {
108 return createOptionalEntity(doSelectEntity(cb, tp), cb);
109 }
110
111 @Override
112 public CrawlingInfoParamCB newConditionBean() {
113 return new CrawlingInfoParamCB();
114 }
115
116 @Override
117 protected Entity doReadEntity(ConditionBean cb) {
118 return facadeSelectEntity(downcast(cb)).orElse(null);
119 }
120
121 public CrawlingInfoParam selectEntityWithDeletedCheck(CBCall<CrawlingInfoParamCB> cbLambda) {
122 return facadeSelectEntityWithDeletedCheck(createCB(cbLambda));
123 }
124
125 public OptionalEntity<CrawlingInfoParam> selectByPK(String id) {
126 return facadeSelectByPK(id);
127 }
128
129 protected OptionalEntity<CrawlingInfoParam> facadeSelectByPK(String id) {
130 return doSelectOptionalByPK(id, typeOfSelectedEntity());
131 }
132
133 protected <ENTITY extends CrawlingInfoParam> ENTITY doSelectByPK(String id, Class<? extends ENTITY> tp) {
134 return doSelectEntity(xprepareCBAsPK(id), tp);
135 }
136
137 protected CrawlingInfoParamCB xprepareCBAsPK(String id) {
138 assertObjectNotNull("id", id);
139 return newConditionBean().acceptPK(id);
140 }
141
142 protected <ENTITY extends CrawlingInfoParam> OptionalEntity<ENTITY> doSelectOptionalByPK(String id, Class<? extends ENTITY> tp) {
143 return createOptionalEntity(doSelectByPK(id, tp), id);
144 }
145
146 @Override
147 protected Class<? extends CrawlingInfoParam> typeOfSelectedEntity() {
148 return CrawlingInfoParam.class;
149 }
150
151 @Override
152 protected Class<CrawlingInfoParam> typeOfHandlingEntity() {
153 return CrawlingInfoParam.class;
154 }
155
156 @Override
157 protected Class<CrawlingInfoParamCB> typeOfHandlingConditionBean() {
158 return CrawlingInfoParamCB.class;
159 }
160
161 public ListResultBean<CrawlingInfoParam> selectList(CBCall<CrawlingInfoParamCB> cbLambda) {
162 return facadeSelectList(createCB(cbLambda));
163 }
164
165 public PagingResultBean<CrawlingInfoParam> selectPage(CBCall<CrawlingInfoParamCB> cbLambda) {
166
167 return (PagingResultBean<CrawlingInfoParam>) facadeSelectList(createCB(cbLambda));
168 }
169
170 public void selectCursor(CBCall<CrawlingInfoParamCB> cbLambda, EntityRowHandler<CrawlingInfoParam> entityLambda) {
171 facadeSelectCursor(createCB(cbLambda), entityLambda);
172 }
173
174 public void selectBulk(CBCall<CrawlingInfoParamCB> cbLambda, EntityRowHandler<List<CrawlingInfoParam>> entityLambda) {
175 delegateSelectBulk(createCB(cbLambda), entityLambda, typeOfSelectedEntity());
176 }
177
178
179
180
181 public void insert(CrawlingInfoParam entity) {
182 doInsert(entity, null);
183 }
184
185 public void insert(CrawlingInfoParam entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
186 entity.asDocMeta().indexOption(opLambda);
187 doInsert(entity, null);
188 }
189
190 public void update(CrawlingInfoParam entity) {
191 doUpdate(entity, null);
192 }
193
194 public void update(CrawlingInfoParam entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
195 entity.asDocMeta().indexOption(opLambda);
196 doUpdate(entity, null);
197 }
198
199 public void insertOrUpdate(CrawlingInfoParam entity) {
200 doInsertOrUpdate(entity, null, null);
201 }
202
203 public void insertOrUpdate(CrawlingInfoParam entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
204 entity.asDocMeta().indexOption(opLambda);
205 doInsertOrUpdate(entity, null, null);
206 }
207
208 public void delete(CrawlingInfoParam entity) {
209 doDelete(entity, null);
210 }
211
212 public void delete(CrawlingInfoParam entity, RequestOptionCall<DeleteRequestBuilder> opLambda) {
213 entity.asDocMeta().deleteOption(opLambda);
214 doDelete(entity, null);
215 }
216
217 public int queryDelete(CBCall<CrawlingInfoParamCB> cbLambda) {
218 return doQueryDelete(createCB(cbLambda), null);
219 }
220
221 public int[] batchInsert(List<CrawlingInfoParam> list) {
222 return batchInsert(list, null, null);
223 }
224
225 public int[] batchInsert(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call) {
226 return batchInsert(list, call, null);
227 }
228
229 public int[] batchInsert(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call,
230 RequestOptionCall<IndexRequestBuilder> entityCall) {
231 return doBatchInsert(new BulkList<>(list, call, entityCall), null);
232 }
233
234 public int[] batchUpdate(List<CrawlingInfoParam> list) {
235 return batchUpdate(list, null, null);
236 }
237
238 public int[] batchUpdate(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call) {
239 return batchUpdate(list, call, null);
240 }
241
242 public int[] batchUpdate(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call,
243 RequestOptionCall<IndexRequestBuilder> entityCall) {
244 return doBatchUpdate(new BulkList<>(list, call, entityCall), null);
245 }
246
247 public int[] batchDelete(List<CrawlingInfoParam> list) {
248 return batchDelete(list, null, null);
249 }
250
251 public int[] batchDelete(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call) {
252 return batchDelete(list, call, null);
253 }
254
255 public int[] batchDelete(List<CrawlingInfoParam> list, RequestOptionCall<BulkRequestBuilder> call,
256 RequestOptionCall<IndexRequestBuilder> entityCall) {
257 return doBatchDelete(new BulkList<>(list, call, entityCall), null);
258 }
259
260
261 }