View Javadoc
1   /*
2    * Copyright 2012-2021 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.es.config.exentity;
17  
18  import org.codelibs.core.lang.StringUtil;
19  import org.codelibs.fess.Constants;
20  import org.codelibs.fess.es.config.bsentity.BsJobLog;
21  import org.codelibs.fess.util.ComponentUtil;
22  
23  /**
24   * @author FreeGen
25   */
26  public class JobLog extends BsJobLog {
27  
28      private static final long serialVersionUID = 1L;
29  
30      private ScheduledJob scheduledJob;
31  
32      public JobLog() {
33      }
34  
35      public JobLog(final ScheduledJob scheduledJob) {
36          this.scheduledJob = scheduledJob;
37          setJobName(scheduledJob.getName());
38          setScriptType(scheduledJob.getScriptType());
39          setScriptData(scheduledJob.getScriptData());
40          setStartTime(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
41          setLastUpdated(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
42          setJobStatus(Constants.RUNNING);
43          final String myName = ComponentUtil.getFessConfig().getSchedulerTargetName();
44          setTarget(StringUtil.isNotBlank(myName) ? myName : Constants.DEFAULT_JOB_TARGET);
45      }
46  
47      public ScheduledJob getScheduledJob() {
48          return scheduledJob;
49      }
50  
51      public String getId() {
52          return asDocMeta().id();
53      }
54  
55      public void setId(final String id) {
56          asDocMeta().id(id);
57      }
58  
59      public Long getVersionNo() {
60          return asDocMeta().version();
61      }
62  
63      public void setVersionNo(final Long version) {
64          asDocMeta().version(version);
65      }
66  
67      @Override
68      public String toString() {
69          return "JobLog [scheduledJob=" + scheduledJob + ", endTime=" + endTime + ", jobName=" + jobName + ", jobStatus=" + jobStatus
70                  + ", scriptData=" + scriptData + ", scriptResult=" + scriptResult + ", scriptType=" + scriptType + ", startTime="
71                  + startTime + ", target=" + target + ", docMeta=" + docMeta + "]";
72      }
73  }