View Javadoc
1   /**
2    * This Source Code Form is subject to the terms of the Mozilla Public
3    * License, v. 2.0. If a copy of the MPL was not distributed with this
4    * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5    *
6    * If it is not possible or desirable to put the notice in a particular
7    * file, then You may include the notice in a location (such as a LICENSE
8    * file in a relevant directory) where a recipient would be likely to look
9    * for such a notice.
10  
11   * 
12   */
13   
14  /*  ---------------------------------------------------------------------------
15   *  U.S. Government, Department of the Army
16   *  Army Materiel Command
17   *  Research Development Engineering Command
18   *  Communications Electronics Research Development and Engineering Center
19   *  ---------------------------------------------------------------------------
20   */
21  
22  package org.miloss.fgsms.auxsrv;
23  
24  import org.quartz.JobDetail;
25  import org.quartz.Scheduler;
26  import org.quartz.SchedulerException;
27  import org.quartz.Trigger;
28  
29  /**
30   *
31   * @author AO
32   */
33  public class AuxConstants {
34  
35      public static final String VERSION = "7.0 BUILD";
36      public static final String QUARTZ_SCHEDULER_NAME = "fgsmsAuxServicesQuartzScheduler";
37      public static final String QUARTZ_GROUP_NAME = "fgsms Aux Services";
38      public static final String QUARTZ_TRIGGER_GROUP_NAME = "fgsmsAuxServicesTriggers";
39  
40      public static boolean QuartzJobExists(String JobName, Scheduler sc) throws SchedulerException {
41          if (sc == null) {   //added in the case of the scheduler being null, which is probably only when the jdbc datasource is not configured. in this case we have bigger issues
42              return false;
43          }
44          String[] jobNames = sc.getJobNames(QUARTZ_GROUP_NAME);
45          for (int i = 0; i < jobNames.length; i++) {
46              if (jobNames[i].equals(JobName)) {
47                  return true;
48              }
49          }
50          return false;
51      }
52  
53      public static JobDetail GetQuartzJobReference(String JobName, Scheduler sc) throws SchedulerException {
54          if (sc == null) { //added in the case of the scheduler being null, which is probably only when the jdbc datasource is not configured. in this case we have bigger issues
55              return null;
56          }
57          String[] jobNames = sc.getJobNames(QUARTZ_GROUP_NAME);
58          for (int i = 0; i < jobNames.length; i++) {
59              if (jobNames[i].equals(JobName)) {
60                  return sc.getJobDetail(JobName, QUARTZ_GROUP_NAME);
61              }
62          }
63          return null;
64      }
65  
66      public static Trigger GetQuartzTriggerReference(String JobName, Scheduler sc) throws SchedulerException {
67          if (sc == null) { //added in the case of the scheduler being null, which is probably only when the jdbc datasource is not configured. in this case we have bigger issues
68              return null;
69          }
70          String[] jobNames = sc.getJobNames(QUARTZ_GROUP_NAME);
71          for (int i = 0; i < jobNames.length; i++) {
72              if (jobNames[i].equals(JobName)) {
73                  return sc.getTrigger(JobName, QUARTZ_GROUP_NAME);
74              }
75          }
76          return null;
77      }
78  }