View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.batch;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.kuali.ole.sys.batch.service.SchedulerService;
24  import org.quartz.JobDetail;
25  import org.springframework.beans.factory.BeanNameAware;
26  
27  public class JobDescriptor implements BeanNameAware {
28      private String name;
29      private String namespaceCode;
30      private String group;
31      private Map<String, String> dependencies;
32      private List<Step> steps;
33      private SchedulerService schedulerService;
34      private boolean durable = true;
35  
36      public JobDescriptor() {
37          dependencies = new HashMap();
38          steps = new ArrayList();
39      }
40  
41      public JobDescriptor(String name, String group, Step step, boolean durable) {
42          this();
43          this.name = name;
44          this.group = group;
45          this.durable = durable;
46          steps.add(step);
47      }
48  
49      /**
50       * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
51       */
52      public void setBeanName(String name) {
53          this.name = name;
54      }
55  
56      /**
57       * Constructs a non-volatile, durable, non-recoverable JobDetail w/ org.kuali.ole.sys.batch.Job as the job class and the specified
58       * name and group from this instance. Also adds status=Pending to the JobDataMap, if this is a scheduled job.
59       * 
60       * @return the org.quartz.JobDetail corresponding to this instance
61       */
62      public JobDetail getJobDetail() {
63          return new JobDetail(name, group, Job.class, false, durable, false);
64      }
65  
66      /**
67       * Sets the group attribute value.
68       * 
69       * @param group The group to set.
70       */
71      public void setGroup(String group) {
72          this.group = group;
73      }
74  
75      /**
76       * Sets the dependencies attribute value.
77       * 
78       * @param dependencies The dependencies to set.
79       */
80      public void setDependencies(Map<String, String> dependencies) {
81          this.dependencies = dependencies;
82      }
83  
84      /**
85       * Gets the dependencies attribute.
86       * 
87       * @return Returns the dependencies.
88       */
89      public Map<String, String> getDependencies() {
90          return dependencies;
91      }
92  
93      /**
94       * Sets the steps attribute value.
95       * 
96       * @param steps The steps to set.
97       */
98      public void setSteps(List<Step> steps) {
99          this.steps = steps;
100     }
101 
102     /**
103      * Gets the steps attribute.
104      * 
105      * @return Returns the steps.
106      */
107     public List<Step> getSteps() {
108         return steps;
109     }
110 
111     /**
112      * Sets the schedulerService attribute value.
113      * 
114      * @param schedulerService The schedulerService to set.
115      */
116     public void setSchedulerService(SchedulerService schedulerService) {
117         this.schedulerService = schedulerService;
118     }
119 
120     public String getGroup() {
121         return group;
122     }
123 
124     public String getName() {
125         return name;
126     }
127 
128     public SchedulerService getSchedulerService() {
129         return schedulerService;
130     }
131 
132     public boolean isDurable() {
133         return durable;
134     }
135 
136     public void setDurable(boolean durable) {
137         this.durable = durable;
138     }
139 
140     /**
141      * Gets the namespaceCode attribute. 
142      * @return Returns the namespaceCode.
143      */
144     public String getNamespaceCode() {
145         return namespaceCode;
146     }
147 
148     /**
149      * Sets the namespaceCode attribute value.
150      * @param namespaceCode The namespaceCode to set.
151      */
152     public void setNamespaceCode(String namespaceCode) {
153         this.namespaceCode = namespaceCode;
154     }
155 
156 }