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.relatedquery;
17  
18  import org.codelibs.fess.app.web.CrudMode;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.lastaflute.web.validation.Required;
21  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
22  
23  import jakarta.validation.constraints.Size;
24  
25  /**
26   * The create form for managing related queries.
27   */
28  public class CreateForm {
29  
30      /**
31       * Creates a new CreateForm instance.
32       */
33      public CreateForm() {
34      }
35  
36      /**
37       * The CRUD operation mode (create, update, etc.).
38       */
39      @ValidateTypeFailure
40      public Integer crudMode;
41  
42      /**
43       * The search term for which related queries are shown.
44       */
45      @Required
46      @Size(max = 10000)
47      public String term;
48  
49      /**
50       * The related queries to be suggested (one per line).
51       */
52      @Required
53      @Size(max = 10000)
54      public String queries;
55  
56      /**
57       * The virtual host for which these related queries apply.
58       */
59      @Size(max = 1000)
60      public String virtualHost;
61  
62      /**
63       * The username who created these related queries.
64       */
65      @Size(max = 1000)
66      public String createdBy;
67  
68      /**
69       * The timestamp when these related queries were created.
70       */
71      @ValidateTypeFailure
72      public Long createdTime;
73  
74      /**
75       * Initializes the form with default values for creating new related queries.
76       */
77      public void initialize() {
78          crudMode = CrudMode.CREATE;
79          createdBy = ComponentUtil.getSystemHelper().getUsername();
80          createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
81      }
82  }