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.elevateword;
17  
18  import org.codelibs.fess.util.ComponentUtil;
19  import org.codelibs.fess.validation.CustomSize;
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   * Form class for creating new elevate word configuration entries.
27   * This form handles the creation of elevate word rules that boost
28   * specific documents in search results when certain keywords are matched.
29   */
30  public class CreateForm {
31  
32      /**
33       * Creates a new CreateForm instance.
34       */
35      public CreateForm() {
36          // Default constructor
37      }
38  
39      /** The label type IDs associated with this elevate word entry */
40      public String[] labelTypeIds;
41  
42      /** The CRUD operation mode for form processing */
43      @ValidateTypeFailure
44      public Integer crudMode;
45  
46      /** The word that should trigger document elevation in search results */
47      @Required
48      public String suggestWord;
49  
50      /** The reading/pronunciation of the suggest word for language analysis */
51      public String reading;
52  
53      /** The target label for filtering documents to be elevated */
54      public String targetLabel;
55  
56      /** The permission settings for accessing this elevate word configuration */
57      @CustomSize(maxKey = "form.admin.max.input.size")
58      public String permissions;
59  
60      /** The boost score multiplier applied to elevated documents */
61      @Required
62      @ValidateTypeFailure
63      public Float boost;
64  
65      /** The username of who created this elevate word entry */
66      @Size(max = 1000)
67      public String createdBy;
68  
69      /** The timestamp when this elevate word entry was created */
70      @ValidateTypeFailure
71      public Long createdTime;
72  
73      /**
74       * Initializes the form with default values for creating a new elevate word entry.
75       */
76      public void initialize() {
77          boost = 100.0f;
78          createdBy = ComponentUtil.getSystemHelper().getUsername();
79          createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
80          permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
81      }
82  }