View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.opensearch.log.cbean.cq.bs;
17  
18  import java.time.LocalDateTime;
19  import java.util.ArrayList;
20  import java.util.Collection;
21  
22  import org.codelibs.fess.opensearch.log.allcommon.EsAbstractConditionQuery;
23  import org.codelibs.fess.opensearch.log.cbean.cq.UserInfoCQ;
24  import org.dbflute.cbean.ckey.ConditionKey;
25  import org.opensearch.index.query.BoolQueryBuilder;
26  import org.opensearch.index.query.CommonTermsQueryBuilder;
27  import org.opensearch.index.query.ExistsQueryBuilder;
28  import org.opensearch.index.query.IdsQueryBuilder;
29  import org.opensearch.index.query.MatchPhrasePrefixQueryBuilder;
30  import org.opensearch.index.query.MatchPhraseQueryBuilder;
31  import org.opensearch.index.query.MatchQueryBuilder;
32  import org.opensearch.index.query.RangeQueryBuilder;
33  import org.opensearch.index.query.TermQueryBuilder;
34  import org.opensearch.index.query.TermsQueryBuilder;
35  import org.opensearch.index.query.functionscore.FunctionScoreQueryBuilder;
36  import org.opensearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder;
37  
38  /**
39   * @author ESFlute (using FreeGen)
40   */
41  public abstract class BsUserInfoCQ extends EsAbstractConditionQuery {
42  
43      protected static final Class<?> suppressUnusedImportLocalDateTime = LocalDateTime.class;
44  
45      // ===================================================================================
46      //                                                                       Name Override
47      //                                                                       =============
48      @Override
49      public String asTableDbName() {
50          return "user_info";
51      }
52  
53      @Override
54      public String xgetAliasName() {
55          return "user_info";
56      }
57  
58      // ===================================================================================
59      //                                                                       Query Control
60      //                                                                       =============
61      public void functionScore(OperatorCall<UserInfoCQ> queryLambda, ScoreFunctionCall<ScoreFunctionCreator<UserInfoCQ>> functionsLambda,
62              final ConditionOptionCall<FunctionScoreQueryBuilder> opLambda) {
63          UserInfoCQ cq = new UserInfoCQ();
64          queryLambda.callback(cq);
65          final Collection<FilterFunctionBuilder> list = new ArrayList<>();
66          if (functionsLambda != null) {
67              functionsLambda.callback((cqLambda, scoreFunctionBuilder) -> {
68                  UserInfoCQ cf = new UserInfoCQ();
69                  cqLambda.callback(cf);
70                  list.add(new FilterFunctionBuilder(cf.getQuery(), scoreFunctionBuilder));
71              });
72          }
73          final FunctionScoreQueryBuilder builder = regFunctionScoreQ(cq.getQuery(), list);
74          if (opLambda != null) {
75              opLambda.callback(builder);
76          }
77      }
78  
79      public void filtered(FilteredCall<UserInfoCQ, UserInfoCQ> filteredLambda) {
80          filtered(filteredLambda, null);
81      }
82  
83      public void filtered(FilteredCall<UserInfoCQ, UserInfoCQ> filteredLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
84          bool((must, should, mustNot, filter) -> {
85              filteredLambda.callback(must, filter);
86          }, opLambda);
87      }
88  
89      public void not(OperatorCall<UserInfoCQ> notLambda) {
90          not(notLambda, null);
91      }
92  
93      public void not(final OperatorCall<UserInfoCQ> notLambda, final ConditionOptionCall<BoolQueryBuilder> opLambda) {
94          bool((must, should, mustNot, filter) -> notLambda.callback(mustNot), opLambda);
95      }
96  
97      public void bool(BoolCall<UserInfoCQ> boolLambda) {
98          bool(boolLambda, null);
99      }
100 
101     public void bool(BoolCall<UserInfoCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
102         UserInfoCQ mustQuery = new UserInfoCQ();
103         UserInfoCQ shouldQuery = new UserInfoCQ();
104         UserInfoCQ mustNotQuery = new UserInfoCQ();
105         UserInfoCQ filterQuery = new UserInfoCQ();
106         boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery);
107         if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) {
108             BoolQueryBuilder builder = regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(),
109                     mustNotQuery.getQueryBuilderList(), filterQuery.getQueryBuilderList());
110             if (opLambda != null) {
111                 opLambda.callback(builder);
112             }
113         }
114     }
115 
116     // ===================================================================================
117     //                                                                           Query Set
118     //                                                                           =========
119     public void setId_Equal(String id) {
120         setId_Term(id, null);
121     }
122 
123     public void setId_Equal(String id, ConditionOptionCall<TermQueryBuilder> opLambda) {
124         setId_Term(id, opLambda);
125     }
126 
127     public void setId_Term(String id) {
128         setId_Term(id, null);
129     }
130 
131     public void setId_Term(String id, ConditionOptionCall<TermQueryBuilder> opLambda) {
132         TermQueryBuilder builder = regTermQ("_id", id);
133         if (opLambda != null) {
134             opLambda.callback(builder);
135         }
136     }
137 
138     public void setId_NotEqual(String id) {
139         setId_NotTerm(id, null);
140     }
141 
142     public void setId_NotTerm(String id) {
143         setId_NotTerm(id, null);
144     }
145 
146     public void setId_NotEqual(String id, ConditionOptionCall<BoolQueryBuilder> opLambda) {
147         setId_NotTerm(id, opLambda);
148     }
149 
150     public void setId_NotTerm(String id, ConditionOptionCall<BoolQueryBuilder> opLambda) {
151         not(not -> not.setId_Term(id), opLambda);
152     }
153 
154     public void setId_Terms(Collection<String> idList) {
155         setId_Terms(idList, null);
156     }
157 
158     public void setId_Terms(Collection<String> idList, ConditionOptionCall<IdsQueryBuilder> opLambda) {
159         IdsQueryBuilder builder = regIdsQ(idList);
160         if (opLambda != null) {
161             opLambda.callback(builder);
162         }
163     }
164 
165     public void setId_InScope(Collection<String> idList) {
166         setId_Terms(idList, null);
167     }
168 
169     public void setId_InScope(Collection<String> idList, ConditionOptionCall<IdsQueryBuilder> opLambda) {
170         setId_Terms(idList, opLambda);
171     }
172 
173     @Deprecated
174     public BsUserInfoCQ addOrderBy_Id_Asc() {
175         regOBA("_id");
176         return this;
177     }
178 
179     @Deprecated
180     public BsUserInfoCQ addOrderBy_Id_Desc() {
181         regOBD("_id");
182         return this;
183     }
184 
185     public void setCreatedAt_Equal(LocalDateTime createdAt) {
186         setCreatedAt_Term(createdAt, null);
187     }
188 
189     public void setCreatedAt_Equal(LocalDateTime createdAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
190         setCreatedAt_Term(createdAt, opLambda);
191     }
192 
193     public void setCreatedAt_Term(LocalDateTime createdAt) {
194         setCreatedAt_Term(createdAt, null);
195     }
196 
197     public void setCreatedAt_Term(LocalDateTime createdAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
198         TermQueryBuilder builder = regTermQ("createdAt", createdAt);
199         if (opLambda != null) {
200             opLambda.callback(builder);
201         }
202     }
203 
204     public void setCreatedAt_NotEqual(LocalDateTime createdAt) {
205         setCreatedAt_NotTerm(createdAt, null);
206     }
207 
208     public void setCreatedAt_NotTerm(LocalDateTime createdAt) {
209         setCreatedAt_NotTerm(createdAt, null);
210     }
211 
212     public void setCreatedAt_NotEqual(LocalDateTime createdAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
213         setCreatedAt_NotTerm(createdAt, opLambda);
214     }
215 
216     public void setCreatedAt_NotTerm(LocalDateTime createdAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
217         not(not -> not.setCreatedAt_Term(createdAt), opLambda);
218     }
219 
220     public void setCreatedAt_Terms(Collection<LocalDateTime> createdAtList) {
221         setCreatedAt_Terms(createdAtList, null);
222     }
223 
224     public void setCreatedAt_Terms(Collection<LocalDateTime> createdAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
225         TermsQueryBuilder builder = regTermsQ("createdAt", createdAtList);
226         if (opLambda != null) {
227             opLambda.callback(builder);
228         }
229     }
230 
231     public void setCreatedAt_InScope(Collection<LocalDateTime> createdAtList) {
232         setCreatedAt_Terms(createdAtList, null);
233     }
234 
235     public void setCreatedAt_InScope(Collection<LocalDateTime> createdAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
236         setCreatedAt_Terms(createdAtList, opLambda);
237     }
238 
239     public void setCreatedAt_Match(LocalDateTime createdAt) {
240         setCreatedAt_Match(createdAt, null);
241     }
242 
243     public void setCreatedAt_Match(LocalDateTime createdAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
244         MatchQueryBuilder builder = regMatchQ("createdAt", createdAt);
245         if (opLambda != null) {
246             opLambda.callback(builder);
247         }
248     }
249 
250     public void setCreatedAt_MatchPhrase(LocalDateTime createdAt) {
251         setCreatedAt_MatchPhrase(createdAt, null);
252     }
253 
254     public void setCreatedAt_MatchPhrase(LocalDateTime createdAt, ConditionOptionCall<MatchPhraseQueryBuilder> opLambda) {
255         MatchPhraseQueryBuilder builder = regMatchPhraseQ("createdAt", createdAt);
256         if (opLambda != null) {
257             opLambda.callback(builder);
258         }
259     }
260 
261     public void setCreatedAt_MatchPhrasePrefix(LocalDateTime createdAt) {
262         setCreatedAt_MatchPhrasePrefix(createdAt, null);
263     }
264 
265     public void setCreatedAt_MatchPhrasePrefix(LocalDateTime createdAt, ConditionOptionCall<MatchPhrasePrefixQueryBuilder> opLambda) {
266         MatchPhrasePrefixQueryBuilder builder = regMatchPhrasePrefixQ("createdAt", createdAt);
267         if (opLambda != null) {
268             opLambda.callback(builder);
269         }
270     }
271 
272     public void setCreatedAt_Fuzzy(LocalDateTime createdAt) {
273         setCreatedAt_Fuzzy(createdAt, null);
274     }
275 
276     public void setCreatedAt_Fuzzy(LocalDateTime createdAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
277         MatchQueryBuilder builder = regFuzzyQ("createdAt", createdAt);
278         if (opLambda != null) {
279             opLambda.callback(builder);
280         }
281     }
282 
283     public void setCreatedAt_GreaterThan(LocalDateTime createdAt) {
284         setCreatedAt_GreaterThan(createdAt, null);
285     }
286 
287     public void setCreatedAt_GreaterThan(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
288         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
289         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_GREATER_THAN, _value);
290         if (opLambda != null) {
291             opLambda.callback(builder);
292         }
293     }
294 
295     public void setCreatedAt_LessThan(LocalDateTime createdAt) {
296         setCreatedAt_LessThan(createdAt, null);
297     }
298 
299     public void setCreatedAt_LessThan(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
300         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
301         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_LESS_THAN, _value);
302         if (opLambda != null) {
303             opLambda.callback(builder);
304         }
305     }
306 
307     public void setCreatedAt_GreaterEqual(LocalDateTime createdAt) {
308         setCreatedAt_GreaterEqual(createdAt, null);
309     }
310 
311     public void setCreatedAt_GreaterEqual(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
312         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
313         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_GREATER_EQUAL, _value);
314         if (opLambda != null) {
315             opLambda.callback(builder);
316         }
317     }
318 
319     public void setCreatedAt_LessEqual(LocalDateTime createdAt) {
320         setCreatedAt_LessEqual(createdAt, null);
321     }
322 
323     public void setCreatedAt_LessEqual(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
324         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
325         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_LESS_EQUAL, _value);
326         if (opLambda != null) {
327             opLambda.callback(builder);
328         }
329     }
330 
331     public void setCreatedAt_Exists() {
332         setCreatedAt_Exists(null);
333     }
334 
335     public void setCreatedAt_Exists(ConditionOptionCall<ExistsQueryBuilder> opLambda) {
336         ExistsQueryBuilder builder = regExistsQ("createdAt");
337         if (opLambda != null) {
338             opLambda.callback(builder);
339         }
340     }
341 
342     @Deprecated
343     public void setCreatedAt_CommonTerms(LocalDateTime createdAt) {
344         setCreatedAt_CommonTerms(createdAt, null);
345     }
346 
347     @Deprecated
348     public void setCreatedAt_CommonTerms(LocalDateTime createdAt, ConditionOptionCall<CommonTermsQueryBuilder> opLambda) {
349         CommonTermsQueryBuilder builder = regCommonTermsQ("createdAt", createdAt);
350         if (opLambda != null) {
351             opLambda.callback(builder);
352         }
353     }
354 
355     public BsUserInfoCQ addOrderBy_CreatedAt_Asc() {
356         regOBA("createdAt");
357         return this;
358     }
359 
360     public BsUserInfoCQ addOrderBy_CreatedAt_Desc() {
361         regOBD("createdAt");
362         return this;
363     }
364 
365     public void setUpdatedAt_Equal(LocalDateTime updatedAt) {
366         setUpdatedAt_Term(updatedAt, null);
367     }
368 
369     public void setUpdatedAt_Equal(LocalDateTime updatedAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
370         setUpdatedAt_Term(updatedAt, opLambda);
371     }
372 
373     public void setUpdatedAt_Term(LocalDateTime updatedAt) {
374         setUpdatedAt_Term(updatedAt, null);
375     }
376 
377     public void setUpdatedAt_Term(LocalDateTime updatedAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
378         TermQueryBuilder builder = regTermQ("updatedAt", updatedAt);
379         if (opLambda != null) {
380             opLambda.callback(builder);
381         }
382     }
383 
384     public void setUpdatedAt_NotEqual(LocalDateTime updatedAt) {
385         setUpdatedAt_NotTerm(updatedAt, null);
386     }
387 
388     public void setUpdatedAt_NotTerm(LocalDateTime updatedAt) {
389         setUpdatedAt_NotTerm(updatedAt, null);
390     }
391 
392     public void setUpdatedAt_NotEqual(LocalDateTime updatedAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
393         setUpdatedAt_NotTerm(updatedAt, opLambda);
394     }
395 
396     public void setUpdatedAt_NotTerm(LocalDateTime updatedAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
397         not(not -> not.setUpdatedAt_Term(updatedAt), opLambda);
398     }
399 
400     public void setUpdatedAt_Terms(Collection<LocalDateTime> updatedAtList) {
401         setUpdatedAt_Terms(updatedAtList, null);
402     }
403 
404     public void setUpdatedAt_Terms(Collection<LocalDateTime> updatedAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
405         TermsQueryBuilder builder = regTermsQ("updatedAt", updatedAtList);
406         if (opLambda != null) {
407             opLambda.callback(builder);
408         }
409     }
410 
411     public void setUpdatedAt_InScope(Collection<LocalDateTime> updatedAtList) {
412         setUpdatedAt_Terms(updatedAtList, null);
413     }
414 
415     public void setUpdatedAt_InScope(Collection<LocalDateTime> updatedAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
416         setUpdatedAt_Terms(updatedAtList, opLambda);
417     }
418 
419     public void setUpdatedAt_Match(LocalDateTime updatedAt) {
420         setUpdatedAt_Match(updatedAt, null);
421     }
422 
423     public void setUpdatedAt_Match(LocalDateTime updatedAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
424         MatchQueryBuilder builder = regMatchQ("updatedAt", updatedAt);
425         if (opLambda != null) {
426             opLambda.callback(builder);
427         }
428     }
429 
430     public void setUpdatedAt_MatchPhrase(LocalDateTime updatedAt) {
431         setUpdatedAt_MatchPhrase(updatedAt, null);
432     }
433 
434     public void setUpdatedAt_MatchPhrase(LocalDateTime updatedAt, ConditionOptionCall<MatchPhraseQueryBuilder> opLambda) {
435         MatchPhraseQueryBuilder builder = regMatchPhraseQ("updatedAt", updatedAt);
436         if (opLambda != null) {
437             opLambda.callback(builder);
438         }
439     }
440 
441     public void setUpdatedAt_MatchPhrasePrefix(LocalDateTime updatedAt) {
442         setUpdatedAt_MatchPhrasePrefix(updatedAt, null);
443     }
444 
445     public void setUpdatedAt_MatchPhrasePrefix(LocalDateTime updatedAt, ConditionOptionCall<MatchPhrasePrefixQueryBuilder> opLambda) {
446         MatchPhrasePrefixQueryBuilder builder = regMatchPhrasePrefixQ("updatedAt", updatedAt);
447         if (opLambda != null) {
448             opLambda.callback(builder);
449         }
450     }
451 
452     public void setUpdatedAt_Fuzzy(LocalDateTime updatedAt) {
453         setUpdatedAt_Fuzzy(updatedAt, null);
454     }
455 
456     public void setUpdatedAt_Fuzzy(LocalDateTime updatedAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
457         MatchQueryBuilder builder = regFuzzyQ("updatedAt", updatedAt);
458         if (opLambda != null) {
459             opLambda.callback(builder);
460         }
461     }
462 
463     public void setUpdatedAt_GreaterThan(LocalDateTime updatedAt) {
464         setUpdatedAt_GreaterThan(updatedAt, null);
465     }
466 
467     public void setUpdatedAt_GreaterThan(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
468         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
469         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_GREATER_THAN, _value);
470         if (opLambda != null) {
471             opLambda.callback(builder);
472         }
473     }
474 
475     public void setUpdatedAt_LessThan(LocalDateTime updatedAt) {
476         setUpdatedAt_LessThan(updatedAt, null);
477     }
478 
479     public void setUpdatedAt_LessThan(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
480         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
481         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_LESS_THAN, _value);
482         if (opLambda != null) {
483             opLambda.callback(builder);
484         }
485     }
486 
487     public void setUpdatedAt_GreaterEqual(LocalDateTime updatedAt) {
488         setUpdatedAt_GreaterEqual(updatedAt, null);
489     }
490 
491     public void setUpdatedAt_GreaterEqual(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
492         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
493         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_GREATER_EQUAL, _value);
494         if (opLambda != null) {
495             opLambda.callback(builder);
496         }
497     }
498 
499     public void setUpdatedAt_LessEqual(LocalDateTime updatedAt) {
500         setUpdatedAt_LessEqual(updatedAt, null);
501     }
502 
503     public void setUpdatedAt_LessEqual(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
504         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
505         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_LESS_EQUAL, _value);
506         if (opLambda != null) {
507             opLambda.callback(builder);
508         }
509     }
510 
511     public void setUpdatedAt_Exists() {
512         setUpdatedAt_Exists(null);
513     }
514 
515     public void setUpdatedAt_Exists(ConditionOptionCall<ExistsQueryBuilder> opLambda) {
516         ExistsQueryBuilder builder = regExistsQ("updatedAt");
517         if (opLambda != null) {
518             opLambda.callback(builder);
519         }
520     }
521 
522     @Deprecated
523     public void setUpdatedAt_CommonTerms(LocalDateTime updatedAt) {
524         setUpdatedAt_CommonTerms(updatedAt, null);
525     }
526 
527     @Deprecated
528     public void setUpdatedAt_CommonTerms(LocalDateTime updatedAt, ConditionOptionCall<CommonTermsQueryBuilder> opLambda) {
529         CommonTermsQueryBuilder builder = regCommonTermsQ("updatedAt", updatedAt);
530         if (opLambda != null) {
531             opLambda.callback(builder);
532         }
533     }
534 
535     public BsUserInfoCQ addOrderBy_UpdatedAt_Asc() {
536         regOBA("updatedAt");
537         return this;
538     }
539 
540     public BsUserInfoCQ addOrderBy_UpdatedAt_Desc() {
541         regOBD("updatedAt");
542         return this;
543     }
544 
545 }