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