View Javadoc
1   /*
2    * Copyright 2012-2021 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.es.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.fesen.index.query.BoolQueryBuilder;
23  import org.codelibs.fesen.index.query.CommonTermsQueryBuilder;
24  import org.codelibs.fesen.index.query.ExistsQueryBuilder;
25  import org.codelibs.fesen.index.query.IdsQueryBuilder;
26  import org.codelibs.fesen.index.query.MatchPhrasePrefixQueryBuilder;
27  import org.codelibs.fesen.index.query.MatchPhraseQueryBuilder;
28  import org.codelibs.fesen.index.query.MatchQueryBuilder;
29  import org.codelibs.fesen.index.query.RangeQueryBuilder;
30  import org.codelibs.fesen.index.query.TermQueryBuilder;
31  import org.codelibs.fesen.index.query.TermsQueryBuilder;
32  import org.codelibs.fesen.index.query.functionscore.FunctionScoreQueryBuilder;
33  import org.codelibs.fesen.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder;
34  import org.codelibs.fess.es.log.allcommon.EsAbstractConditionQuery;
35  import org.codelibs.fess.es.log.cbean.cq.UserInfoCQ;
36  import org.dbflute.cbean.ckey.ConditionKey;
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     public BsUserInfoCQ addOrderBy_Id_Asc() {
174         regOBA("_id");
175         return this;
176     }
177 
178     public BsUserInfoCQ addOrderBy_Id_Desc() {
179         regOBD("_id");
180         return this;
181     }
182 
183     public void setCreatedAt_Equal(LocalDateTime createdAt) {
184         setCreatedAt_Term(createdAt, null);
185     }
186 
187     public void setCreatedAt_Equal(LocalDateTime createdAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
188         setCreatedAt_Term(createdAt, opLambda);
189     }
190 
191     public void setCreatedAt_Term(LocalDateTime createdAt) {
192         setCreatedAt_Term(createdAt, null);
193     }
194 
195     public void setCreatedAt_Term(LocalDateTime createdAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
196         TermQueryBuilder builder = regTermQ("createdAt", createdAt);
197         if (opLambda != null) {
198             opLambda.callback(builder);
199         }
200     }
201 
202     public void setCreatedAt_NotEqual(LocalDateTime createdAt) {
203         setCreatedAt_NotTerm(createdAt, null);
204     }
205 
206     public void setCreatedAt_NotTerm(LocalDateTime createdAt) {
207         setCreatedAt_NotTerm(createdAt, null);
208     }
209 
210     public void setCreatedAt_NotEqual(LocalDateTime createdAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
211         setCreatedAt_NotTerm(createdAt, opLambda);
212     }
213 
214     public void setCreatedAt_NotTerm(LocalDateTime createdAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
215         not(not -> not.setCreatedAt_Term(createdAt), opLambda);
216     }
217 
218     public void setCreatedAt_Terms(Collection<LocalDateTime> createdAtList) {
219         setCreatedAt_Terms(createdAtList, null);
220     }
221 
222     public void setCreatedAt_Terms(Collection<LocalDateTime> createdAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
223         TermsQueryBuilder builder = regTermsQ("createdAt", createdAtList);
224         if (opLambda != null) {
225             opLambda.callback(builder);
226         }
227     }
228 
229     public void setCreatedAt_InScope(Collection<LocalDateTime> createdAtList) {
230         setCreatedAt_Terms(createdAtList, null);
231     }
232 
233     public void setCreatedAt_InScope(Collection<LocalDateTime> createdAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
234         setCreatedAt_Terms(createdAtList, opLambda);
235     }
236 
237     public void setCreatedAt_Match(LocalDateTime createdAt) {
238         setCreatedAt_Match(createdAt, null);
239     }
240 
241     public void setCreatedAt_Match(LocalDateTime createdAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
242         MatchQueryBuilder builder = regMatchQ("createdAt", createdAt);
243         if (opLambda != null) {
244             opLambda.callback(builder);
245         }
246     }
247 
248     public void setCreatedAt_MatchPhrase(LocalDateTime createdAt) {
249         setCreatedAt_MatchPhrase(createdAt, null);
250     }
251 
252     public void setCreatedAt_MatchPhrase(LocalDateTime createdAt, ConditionOptionCall<MatchPhraseQueryBuilder> opLambda) {
253         MatchPhraseQueryBuilder builder = regMatchPhraseQ("createdAt", createdAt);
254         if (opLambda != null) {
255             opLambda.callback(builder);
256         }
257     }
258 
259     public void setCreatedAt_MatchPhrasePrefix(LocalDateTime createdAt) {
260         setCreatedAt_MatchPhrasePrefix(createdAt, null);
261     }
262 
263     public void setCreatedAt_MatchPhrasePrefix(LocalDateTime createdAt, ConditionOptionCall<MatchPhrasePrefixQueryBuilder> opLambda) {
264         MatchPhrasePrefixQueryBuilder builder = regMatchPhrasePrefixQ("createdAt", createdAt);
265         if (opLambda != null) {
266             opLambda.callback(builder);
267         }
268     }
269 
270     public void setCreatedAt_Fuzzy(LocalDateTime createdAt) {
271         setCreatedAt_Fuzzy(createdAt, null);
272     }
273 
274     public void setCreatedAt_Fuzzy(LocalDateTime createdAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
275         MatchQueryBuilder builder = regFuzzyQ("createdAt", createdAt);
276         if (opLambda != null) {
277             opLambda.callback(builder);
278         }
279     }
280 
281     public void setCreatedAt_GreaterThan(LocalDateTime createdAt) {
282         setCreatedAt_GreaterThan(createdAt, null);
283     }
284 
285     public void setCreatedAt_GreaterThan(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
286         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
287         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_GREATER_THAN, _value);
288         if (opLambda != null) {
289             opLambda.callback(builder);
290         }
291     }
292 
293     public void setCreatedAt_LessThan(LocalDateTime createdAt) {
294         setCreatedAt_LessThan(createdAt, null);
295     }
296 
297     public void setCreatedAt_LessThan(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
298         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
299         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_LESS_THAN, _value);
300         if (opLambda != null) {
301             opLambda.callback(builder);
302         }
303     }
304 
305     public void setCreatedAt_GreaterEqual(LocalDateTime createdAt) {
306         setCreatedAt_GreaterEqual(createdAt, null);
307     }
308 
309     public void setCreatedAt_GreaterEqual(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
310         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
311         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_GREATER_EQUAL, _value);
312         if (opLambda != null) {
313             opLambda.callback(builder);
314         }
315     }
316 
317     public void setCreatedAt_LessEqual(LocalDateTime createdAt) {
318         setCreatedAt_LessEqual(createdAt, null);
319     }
320 
321     public void setCreatedAt_LessEqual(LocalDateTime createdAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
322         final Object _value = toRangeLocalDateTimeString(createdAt, "date_optional_time");
323         RangeQueryBuilder builder = regRangeQ("createdAt", ConditionKey.CK_LESS_EQUAL, _value);
324         if (opLambda != null) {
325             opLambda.callback(builder);
326         }
327     }
328 
329     public void setCreatedAt_Exists() {
330         setCreatedAt_Exists(null);
331     }
332 
333     public void setCreatedAt_Exists(ConditionOptionCall<ExistsQueryBuilder> opLambda) {
334         ExistsQueryBuilder builder = regExistsQ("createdAt");
335         if (opLambda != null) {
336             opLambda.callback(builder);
337         }
338     }
339 
340     public void setCreatedAt_CommonTerms(LocalDateTime createdAt) {
341         setCreatedAt_CommonTerms(createdAt, null);
342     }
343 
344     public void setCreatedAt_CommonTerms(LocalDateTime createdAt, ConditionOptionCall<CommonTermsQueryBuilder> opLambda) {
345         CommonTermsQueryBuilder builder = regCommonTermsQ("createdAt", createdAt);
346         if (opLambda != null) {
347             opLambda.callback(builder);
348         }
349     }
350 
351     public BsUserInfoCQ addOrderBy_CreatedAt_Asc() {
352         regOBA("createdAt");
353         return this;
354     }
355 
356     public BsUserInfoCQ addOrderBy_CreatedAt_Desc() {
357         regOBD("createdAt");
358         return this;
359     }
360 
361     public void setUpdatedAt_Equal(LocalDateTime updatedAt) {
362         setUpdatedAt_Term(updatedAt, null);
363     }
364 
365     public void setUpdatedAt_Equal(LocalDateTime updatedAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
366         setUpdatedAt_Term(updatedAt, opLambda);
367     }
368 
369     public void setUpdatedAt_Term(LocalDateTime updatedAt) {
370         setUpdatedAt_Term(updatedAt, null);
371     }
372 
373     public void setUpdatedAt_Term(LocalDateTime updatedAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
374         TermQueryBuilder builder = regTermQ("updatedAt", updatedAt);
375         if (opLambda != null) {
376             opLambda.callback(builder);
377         }
378     }
379 
380     public void setUpdatedAt_NotEqual(LocalDateTime updatedAt) {
381         setUpdatedAt_NotTerm(updatedAt, null);
382     }
383 
384     public void setUpdatedAt_NotTerm(LocalDateTime updatedAt) {
385         setUpdatedAt_NotTerm(updatedAt, null);
386     }
387 
388     public void setUpdatedAt_NotEqual(LocalDateTime updatedAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
389         setUpdatedAt_NotTerm(updatedAt, opLambda);
390     }
391 
392     public void setUpdatedAt_NotTerm(LocalDateTime updatedAt, ConditionOptionCall<BoolQueryBuilder> opLambda) {
393         not(not -> not.setUpdatedAt_Term(updatedAt), opLambda);
394     }
395 
396     public void setUpdatedAt_Terms(Collection<LocalDateTime> updatedAtList) {
397         setUpdatedAt_Terms(updatedAtList, null);
398     }
399 
400     public void setUpdatedAt_Terms(Collection<LocalDateTime> updatedAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
401         TermsQueryBuilder builder = regTermsQ("updatedAt", updatedAtList);
402         if (opLambda != null) {
403             opLambda.callback(builder);
404         }
405     }
406 
407     public void setUpdatedAt_InScope(Collection<LocalDateTime> updatedAtList) {
408         setUpdatedAt_Terms(updatedAtList, null);
409     }
410 
411     public void setUpdatedAt_InScope(Collection<LocalDateTime> updatedAtList, ConditionOptionCall<TermsQueryBuilder> opLambda) {
412         setUpdatedAt_Terms(updatedAtList, opLambda);
413     }
414 
415     public void setUpdatedAt_Match(LocalDateTime updatedAt) {
416         setUpdatedAt_Match(updatedAt, null);
417     }
418 
419     public void setUpdatedAt_Match(LocalDateTime updatedAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
420         MatchQueryBuilder builder = regMatchQ("updatedAt", updatedAt);
421         if (opLambda != null) {
422             opLambda.callback(builder);
423         }
424     }
425 
426     public void setUpdatedAt_MatchPhrase(LocalDateTime updatedAt) {
427         setUpdatedAt_MatchPhrase(updatedAt, null);
428     }
429 
430     public void setUpdatedAt_MatchPhrase(LocalDateTime updatedAt, ConditionOptionCall<MatchPhraseQueryBuilder> opLambda) {
431         MatchPhraseQueryBuilder builder = regMatchPhraseQ("updatedAt", updatedAt);
432         if (opLambda != null) {
433             opLambda.callback(builder);
434         }
435     }
436 
437     public void setUpdatedAt_MatchPhrasePrefix(LocalDateTime updatedAt) {
438         setUpdatedAt_MatchPhrasePrefix(updatedAt, null);
439     }
440 
441     public void setUpdatedAt_MatchPhrasePrefix(LocalDateTime updatedAt, ConditionOptionCall<MatchPhrasePrefixQueryBuilder> opLambda) {
442         MatchPhrasePrefixQueryBuilder builder = regMatchPhrasePrefixQ("updatedAt", updatedAt);
443         if (opLambda != null) {
444             opLambda.callback(builder);
445         }
446     }
447 
448     public void setUpdatedAt_Fuzzy(LocalDateTime updatedAt) {
449         setUpdatedAt_Fuzzy(updatedAt, null);
450     }
451 
452     public void setUpdatedAt_Fuzzy(LocalDateTime updatedAt, ConditionOptionCall<MatchQueryBuilder> opLambda) {
453         MatchQueryBuilder builder = regFuzzyQ("updatedAt", updatedAt);
454         if (opLambda != null) {
455             opLambda.callback(builder);
456         }
457     }
458 
459     public void setUpdatedAt_GreaterThan(LocalDateTime updatedAt) {
460         setUpdatedAt_GreaterThan(updatedAt, null);
461     }
462 
463     public void setUpdatedAt_GreaterThan(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
464         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
465         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_GREATER_THAN, _value);
466         if (opLambda != null) {
467             opLambda.callback(builder);
468         }
469     }
470 
471     public void setUpdatedAt_LessThan(LocalDateTime updatedAt) {
472         setUpdatedAt_LessThan(updatedAt, null);
473     }
474 
475     public void setUpdatedAt_LessThan(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
476         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
477         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_LESS_THAN, _value);
478         if (opLambda != null) {
479             opLambda.callback(builder);
480         }
481     }
482 
483     public void setUpdatedAt_GreaterEqual(LocalDateTime updatedAt) {
484         setUpdatedAt_GreaterEqual(updatedAt, null);
485     }
486 
487     public void setUpdatedAt_GreaterEqual(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
488         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
489         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_GREATER_EQUAL, _value);
490         if (opLambda != null) {
491             opLambda.callback(builder);
492         }
493     }
494 
495     public void setUpdatedAt_LessEqual(LocalDateTime updatedAt) {
496         setUpdatedAt_LessEqual(updatedAt, null);
497     }
498 
499     public void setUpdatedAt_LessEqual(LocalDateTime updatedAt, ConditionOptionCall<RangeQueryBuilder> opLambda) {
500         final Object _value = toRangeLocalDateTimeString(updatedAt, "date_optional_time");
501         RangeQueryBuilder builder = regRangeQ("updatedAt", ConditionKey.CK_LESS_EQUAL, _value);
502         if (opLambda != null) {
503             opLambda.callback(builder);
504         }
505     }
506 
507     public void setUpdatedAt_Exists() {
508         setUpdatedAt_Exists(null);
509     }
510 
511     public void setUpdatedAt_Exists(ConditionOptionCall<ExistsQueryBuilder> opLambda) {
512         ExistsQueryBuilder builder = regExistsQ("updatedAt");
513         if (opLambda != null) {
514             opLambda.callback(builder);
515         }
516     }
517 
518     public void setUpdatedAt_CommonTerms(LocalDateTime updatedAt) {
519         setUpdatedAt_CommonTerms(updatedAt, null);
520     }
521 
522     public void setUpdatedAt_CommonTerms(LocalDateTime updatedAt, ConditionOptionCall<CommonTermsQueryBuilder> opLambda) {
523         CommonTermsQueryBuilder builder = regCommonTermsQ("updatedAt", updatedAt);
524         if (opLambda != null) {
525             opLambda.callback(builder);
526         }
527     }
528 
529     public BsUserInfoCQ addOrderBy_UpdatedAt_Asc() {
530         regOBA("updatedAt");
531         return this;
532     }
533 
534     public BsUserInfoCQ addOrderBy_UpdatedAt_Desc() {
535         regOBD("updatedAt");
536         return this;
537     }
538 
539 }