edu.ucsb.nceas.metacat.scheduler
Class ScheduledJobAccess

java.lang.Object
  extended by edu.ucsb.nceas.metacat.shared.BaseAccess
      extended by edu.ucsb.nceas.metacat.scheduler.ScheduledJobAccess

public class ScheduledJobAccess
extends BaseAccess


Constructor Summary
ScheduledJobAccess()
           
 
Method Summary
 void createJob(ScheduledJobDAO jobDAO, java.util.HashMap<java.lang.String,java.lang.String> jobParams)
          Create a job in the database
 void createJob(java.lang.String name, java.lang.String triggerName, java.lang.String groupName, java.lang.Class<org.quartz.Job> jobClass, java.util.Calendar startTime, java.util.Calendar endTime, int intervalValue, java.lang.String intervalUnit, java.util.HashMap<java.lang.String,java.lang.String> jobParams)
          Create a job in the database.
 java.util.HashMap<java.lang.Long,ScheduledJobDAO> getAllJobs(java.lang.String groupName)
          Get all jobs for a given group.
 ScheduledJobDAO getJob(java.lang.Long jobId)
          Get a job based on it's id
 ScheduledJobDAO getJobByName(java.lang.String jobName)
          Get a job by it's name
 java.util.HashMap<java.lang.Long,ScheduledJobDAO> getJobsWithParameter(java.lang.String groupName, java.lang.String paramName, java.lang.String paramValue)
          Get all jobs that have a given parameter with a given value
protected  ScheduledJobDAO populateDAO(java.sql.ResultSet resultSet)
          Populate a job data object with the current row in a resultset
 void updateJobStatus(ScheduledJobDAO jobDAO)
          Update the status of a job in the database
 
Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseAccess
closeDBObjects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduledJobAccess

public ScheduledJobAccess()
                   throws AccessException
Throws:
AccessException
Method Detail

getJob

public ScheduledJobDAO getJob(java.lang.Long jobId)
                       throws AccessException
Get a job based on it's id

Parameters:
jobId - the id of the job in the database
Returns:
the scheduled job data object that represents the desired job
Throws:
AccessException

getJobByName

public ScheduledJobDAO getJobByName(java.lang.String jobName)
                             throws AccessException
Get a job by it's name

Parameters:
jobName - the name of the job to get
Returns:
the scheduled job data object that represents the desired job
Throws:
AccessException

getJobsWithParameter

public java.util.HashMap<java.lang.Long,ScheduledJobDAO> getJobsWithParameter(java.lang.String groupName,
                                                                              java.lang.String paramName,
                                                                              java.lang.String paramValue)
                                                                       throws AccessException
Get all jobs that have a given parameter with a given value

Parameters:
groupName - the group to which the job belongs. This keeps us from returning unrelated jobs that just happen to have a similar parameter
paramName - the name of the parameter we are looking for
paramValue - the value of the parameter we are looking for
Returns:
a HashMap of job data objects with all jobs in a given group that have parameters that match our parameter.
Throws:
AccessException

getAllJobs

public java.util.HashMap<java.lang.Long,ScheduledJobDAO> getAllJobs(java.lang.String groupName)
                                                             throws AccessException
Get all jobs for a given group. A group is typically a category that coincides with the job type (has it's own job implementation).

Parameters:
groupName - the name of the group we want to search
Returns:
a HashMap of job data objects for the desired group.
Throws:
AccessException

createJob

public void createJob(java.lang.String name,
                      java.lang.String triggerName,
                      java.lang.String groupName,
                      java.lang.Class<org.quartz.Job> jobClass,
                      java.util.Calendar startTime,
                      java.util.Calendar endTime,
                      int intervalValue,
                      java.lang.String intervalUnit,
                      java.util.HashMap<java.lang.String,java.lang.String> jobParams)
               throws AccessException
Create a job in the database.

Parameters:
name - the name of the job. This should be unique
triggerName - the name of the trigger that is registered in the scheduler service
groupName - the group of the job
jobClass - the class that implements the job functionality. The name of this class will be extracted and put into the database.
startTime - the time when the job should first run
intervalValue - the amount of time between job runs.
intervalUnit - the unit of time that the intervalValue represents. Valid values are s,m,h, d and w
jobParams - a map of parameters that are associated with this job.
Throws:
AccessException

createJob

public void createJob(ScheduledJobDAO jobDAO,
                      java.util.HashMap<java.lang.String,java.lang.String> jobParams)
               throws AccessException
Create a job in the database

Parameters:
jobDAO - the job data object that holds necessary information
jobParams - a map of parameters that are associated with this job.
Throws:
AccessException

updateJobStatus

public void updateJobStatus(ScheduledJobDAO jobDAO)
                     throws AccessException
Update the status of a job in the database

Parameters:
jobDAO - the job data object that we want to change. The status should already have been updated in this object
Throws:
AccessException

populateDAO

protected ScheduledJobDAO populateDAO(java.sql.ResultSet resultSet)
                               throws java.sql.SQLException
Populate a job data object with the current row in a resultset

Specified by:
populateDAO in class BaseAccess
Parameters:
resultSet - the result set which is already pointing to the desired row.
Returns:
a scheduled job data object
Throws:
java.sql.SQLException


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.