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