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.relatedcontent;
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.Max;
24 import jakarta.validation.constraints.Min;
25 import jakarta.validation.constraints.Size;
26
27 /**
28 * The create form for managing related content.
29 */
30 public class CreateForm {
31
32 /**
33 * Creates a new CreateForm instance.
34 */
35 public CreateForm() {
36 }
37
38 /**
39 * The CRUD operation mode (create, update, etc.).
40 */
41 @ValidateTypeFailure
42 public Integer crudMode;
43
44 /**
45 * The search term for which related content is shown.
46 */
47 @Required
48 @Size(max = 10000)
49 public String term;
50
51 /**
52 * The related content to be displayed.
53 */
54 @Required
55 @Size(max = 10000)
56 public String content;
57
58 /**
59 * The virtual host for which this related content applies.
60 */
61 @Size(max = 1000)
62 public String virtualHost;
63
64 /**
65 * The sort order for this related content (0-2147483647).
66 */
67 @Min(value = 0)
68 @Max(value = 2147483647)
69 @ValidateTypeFailure
70 public Integer sortOrder;
71
72 /**
73 * The username who created this related content.
74 */
75 @Size(max = 1000)
76 public String createdBy;
77
78 /**
79 * The timestamp when this related content was created.
80 */
81 @ValidateTypeFailure
82 public Long createdTime;
83
84 /**
85 * Initializes the form with default values for creating new related content.
86 */
87 public void initialize() {
88 crudMode = CrudMode.CREATE;
89 createdBy = ComponentUtil.getSystemHelper().getUsername();
90 createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
91 sortOrder = 1;
92 }
93 }