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.scheduler;
17  
18  import org.codelibs.fess.Constants;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.codelibs.fess.validation.CronExpression;
21  import org.codelibs.fess.validation.CustomSize;
22  import org.lastaflute.web.validation.Required;
23  import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
24  
25  import jakarta.validation.constraints.Max;
26  import jakarta.validation.constraints.Min;
27  import jakarta.validation.constraints.Size;
28  
29  /**
30   * The create form for Scheduler.
31   *
32   */
33  public class CreateForm {
34  
35      /**
36       * Creates a new CreateForm instance.
37       */
38      public CreateForm() {
39      }
40  
41      /**
42       * The CRUD mode for the form.
43       */
44      @ValidateTypeFailure
45      public Integer crudMode;
46  
47      /**
48       * The name of the scheduled job.
49       */
50      @Required
51      @Size(max = 100)
52      public String name;
53  
54      /**
55       * The target class for the scheduled job.
56       */
57      @Required
58      @Size(max = 100)
59      public String target;
60  
61      /**
62       * The cron expression defining when the job should run.
63       */
64      @Size(max = 100)
65      @CronExpression
66      public String cronExpression;
67  
68      /**
69       * The type of script for the scheduled job.
70       */
71      @Required
72      @Size(max = 100)
73      public String scriptType;
74  
75      /**
76       * The script data or code for the scheduled job.
77       */
78      @CustomSize(maxKey = "form.admin.max.input.size")
79      public String scriptData;
80  
81      /**
82       * Whether this job is related to crawling.
83       */
84      public String crawler;
85  
86      /**
87       * Whether job logging is enabled.
88       */
89      public String jobLogging;
90  
91      /**
92       * Whether the scheduled job is available/enabled.
93       */
94      public String available;
95  
96      /**
97       * The sort order for displaying this scheduled job.
98       */
99      @Required
100     @Min(value = 0)
101     @Max(value = 2147483647)
102     @ValidateTypeFailure
103     public Integer sortOrder;
104 
105     /**
106      * The username of who created this scheduled job.
107      */
108     @Size(max = 1000)
109     public String createdBy;
110 
111     /**
112      * The timestamp when this scheduled job was created.
113      */
114     @ValidateTypeFailure
115     public Long createdTime;
116 
117     /**
118      * Initializes the form with default values for creating a new scheduled job.
119      */
120     public void initialize() {
121         target = Constants.DEFAULT_JOB_TARGET;
122         cronExpression = Constants.DEFAULT_CRON_EXPRESSION;
123         scriptType = Constants.DEFAULT_JOB_SCRIPT_TYPE;
124         sortOrder = 0;
125         createdBy = ComponentUtil.getSystemHelper().getUsername();
126         createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
127 
128     }
129 }