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.app.web.admin.keymatch;
17  
18  import org.codelibs.fess.app.web.CrudMode;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.codelibs.fess.validation.CustomSize;
21  import org.lastaflute.web.validation.Required;
22  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
23  
24  import jakarta.validation.constraints.Max;
25  import jakarta.validation.constraints.Min;
26  import jakarta.validation.constraints.Size;
27  
28  /**
29   * The create form for Key Match.
30   */
31  public class CreateForm {
32  
33      /**
34       * Creates a new CreateForm instance.
35       */
36      public CreateForm() {
37      }
38  
39      /**
40       * The CRUD mode for the form.
41       */
42      @ValidateTypeFailure
43      public Integer crudMode;
44  
45      /**
46       * The search term that triggers the key match.
47       */
48      @Required
49      @Size(max = 100)
50      public String term;
51  
52      /**
53       * The query to execute when the term matches.
54       */
55      @Required
56      @CustomSize(maxKey = "form.admin.max.input.size")
57      public String query;
58  
59      /**
60       * The maximum number of results to return.
61       */
62      @Required
63      @Min(value = 0)
64      @Max(value = 2147483647)
65      @ValidateTypeFailure
66      public Integer maxSize;
67  
68      /**
69       * The boost score for matched results.
70       */
71      @Required
72      @ValidateTypeFailure
73      public Float boost;
74  
75      /**
76       * The virtual host for the key match.
77       */
78      @Size(max = 1000)
79      public String virtualHost;
80  
81      /**
82       * The user who created this key match.
83       */
84      @Size(max = 255)
85      public String createdBy;
86  
87      /**
88       * The timestamp when this key match was created.
89       */
90      @ValidateTypeFailure
91      public Long createdTime;
92  
93      /**
94       * Initializes the form with default values.
95       */
96      public void initialize() {
97          crudMode = CrudMode.CREATE;
98          maxSize = 10;
99          boost = 100.0f;
100         createdBy = ComponentUtil.getSystemHelper().getUsername();
101         createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
102 
103     }
104 }