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.dataconfig;
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 * Form class for creating data store configurations.
30 * Data configs allow administrators to set up crawling of various data sources
31 * including databases, CSV files, and other structured data sources.
32 */
33 public class CreateForm {
34
35 /**
36 * Creates a new CreateForm instance.
37 */
38 public CreateForm() {
39 // Default constructor
40 }
41
42 /** CRUD operation mode (CREATE, EDIT, etc.) */
43 @ValidateTypeFailure
44 public Integer crudMode;
45
46 /** Configuration name for identifying this data source */
47 @Required
48 @Size(max = 200)
49 public String name;
50
51 /** Optional description of this data configuration */
52 @Size(max = 1000)
53 public String description;
54
55 /** Handler class name for processing this data source */
56 @Required
57 @CustomSize(maxKey = "form.admin.max.input.size")
58 public String handlerName;
59
60 /** Parameters passed to the data handler */
61 @CustomSize(maxKey = "form.admin.max.input.size")
62 public String handlerParameter;
63
64 /** Script for custom data processing logic */
65 @CustomSize(maxKey = "form.admin.max.input.size")
66 public String handlerScript;
67
68 /** Boost value for documents from this data source */
69 @Required
70 @ValidateTypeFailure
71 public Float boost;
72
73 /** Whether this configuration is enabled (true/false) */
74 @Required
75 @Size(max = 5)
76 public String available;
77
78 /** Access permissions for documents from this data source */
79 @CustomSize(maxKey = "form.admin.max.input.size")
80 public String permissions;
81
82 /** Virtual hosts where this configuration applies */
83 @CustomSize(maxKey = "form.admin.max.input.size")
84 public String virtualHosts;
85
86 /** Sort order for displaying configurations */
87 @Required
88 @Min(value = 0)
89 @Max(value = 2147483647)
90 @ValidateTypeFailure
91 public Integer sortOrder;
92
93 /** User who created this configuration */
94 @Size(max = 1000)
95 public String createdBy;
96
97 /** Timestamp when this configuration was created */
98 @ValidateTypeFailure
99 public Long createdTime;
100
101 /**
102 * Initializes the form with default values for creating a new data configuration.
103 */
104 public void initialize() {
105 crudMode = CrudMode.CREATE;
106 boost = 1.0f;
107 sortOrder = 0;
108 createdBy = ComponentUtil.getSystemHelper().getUsername();
109 createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
110 permissions = ComponentUtil.getFessConfig().getSearchDefaultDisplayPermission();
111 }
112 }