/* Copyright 1999-2008 Acelet.org. All rights reserved. GPL v2 license */
/** @author Wei Jiang */
package com.acelet.s.scheduler;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import com.acelet.lib.Common;
import com.acelet.lib.Externals;
import com.acelet.lib.Kit;
import com.acelet.lib.LogAgent;
import com.acelet.lib.LoggingConstants;
import com.acelet.lib.NotSupportedException;
import com.acelet.lib.Phrase;
import com.acelet.lib.SendEmail;
import com.acelet.lib.SuperProperties;
import com.acelet.s.MailServerData;
import com.acelet.s.task.CandidateTask;
import com.acelet.s.task.DoerTalker;
import com.acelet.s.task.Holiday;
import com.acelet.s.task.HolidayRule;
import com.acelet.s.task.Task;
import com.acelet.s.task.TaskProcess;
import com.acelet.s.task.WorkingTask;
/**
* The <code>Api</code> is a utility class for SuperScheduler. It is the API to SuperScheduler.
* <br>
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.task.Task
* @see com.acelet.s.task.TaskConstants
* @see com.acelet.s.task.WorkingTask
*/
public class Api extends ApiBase {
protected Api() throws Exception {
}
/**
* <code>changeTaskStatus</code> changes the status for a Task.
* <br>
* @param taskName the name of the Task.
* @param newStatus the new status. It can be
* <code>STATUS_ACTIVE</code> or <code>STATUS_SUSPENDED</code>
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @exception Exception.
* @see com.acelet.s.job.AbstractTaskConstants
*/
public static int changeTaskStatus(String taskName, int newStatus) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).changeTaskStatus(taskName, newStatus);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>changeTaskStatus</code> changes the status for a Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param taskName the name of the Task.
* @param newStatus the new status. It can be
* <code>STATUS_ACTIVE</code> or <code>STATUS_SUSPENDED</code>
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @exception Exception.
* @see com.acelet.s.job.AbstractTaskConstants
*/
public static int changeTaskStatus(Connection connection, String taskName, int newStatus)
throws Exception {
return new TaskProcess(connection).changeTaskStatus(taskName, newStatus);
}
/**
* <code>deleteHoliday</code> deletes the Holiday.
* <br>
* @param id the id of the Holiday.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
* @see #selectAllHolidays
*/
public static int deleteHoliday(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).deleteHoliday(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>deleteHoliday</code> deletes the Holiday.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the Holiday.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
* @see #selectAllHolidays
*/
public static int deleteHoliday(Connection connection, long id) throws Exception {
return new TaskProcess(connection).deleteHoliday(id);
}
/**
* <code>deleteHolidayRule</code> deletes the HolidayRule.
* <br>
* @param id the id of the HolidayRule.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int deleteHolidayRule(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).deleteHolidayRule(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>deleteHolidayRule</code> deletes the HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the HolidayRule.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int deleteHolidayRule(Connection connection, long id) throws Exception {
return new TaskProcess(connection).deleteHolidayRule(id);
}
/**
* <code>deleteHolidaySet</code> deletes the holiday set.
* <br>
* @param setName the name of the set
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
*/
public static int deleteHolidaySet(String setName) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).deleteHolidaySet(setName);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>deleteHolidaySet</code> deletes the holiday set.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param setName the name of the set
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
*/
public static int deleteHolidaySet(Connection connection, String setName) throws Exception {
return new TaskProcess(connection).deleteHolidaySet(setName);
}
/**
* <code>deleteTask</code> deletes the Task.
* <br>
* @param id the ID for the task.
* @return the number of rows deleted. It is 1, if successful, 0 otherwise.
* @exception Exception.
*/
public static int deleteTask(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).deleteTask(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>deleteTask</code> deletes the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the ID for the task.
* @return the number of rows deleted. It is 1, if successful, 0 otherwise.
* @exception Exception.
*/
public static int deleteTask(Connection connection, long id) throws Exception {
return new TaskProcess(connection).deleteTask(id);
}
/**
* <code>deleteTask</code> deletes the Task.
* <br>
* @param name the name of the Task.
* @return the number of rows deleted. It is 1, if successful, 0 otherwise.
* @exception Exception.
*/
public static int deleteTask(String name) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).deleteTask(name);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>deleteTask</code> deletes the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param name the name of the Task.
* @return the number of rows deleted. It is 1, if successful, 0 otherwise.
* @exception Exception.
*/
public static int deleteTask(Connection connection, String name) throws Exception {
return new TaskProcess(connection).deleteTask(name);
}
public static void init() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
new TaskProcess(connection).setLogAgent();
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>init</code> init this Api. It must be called before Api can be used.
* <br>
* @param logAgentName a LogAgent object to use for logging. It can be null if you do not
* want log.
* @exception Exception.
*/
public static void init(String logAgentName) throws Exception {
TaskProcess.setLogAgent(logAgentName, Scheduling.logAgentTimeout);
initialized = true;
}
/**
* <code>insertCandidateTask</code> is the same as <code>requestRunTask</code> from
* com.acelet.s.scheduler.SchedulerControl, which requests SuperScheduler to run the task.
* A Doer will take the request and run the task.
* @param taskName the name of the task.
* @exception Exception.
*/
public static int insertCandidateTask(String taskName) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertCandidateTask(taskName);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertCandidateTask</code> is the same as <code>requestRunTask</code> from
* com.acelet.s.scheduler.SchedulerControl, which requests SuperScheduler to run the task.
* A Doer will take the request and run the task.
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param taskName the name of the task.
* @exception Exception.
*/
public static int insertCandidateTask(Connection connection, String taskName) throws Exception {
return new TaskProcess(connection).insertCandidateTask(taskName);
}
/**
* <code>insertHoliday</code> insert a Holiday.
* <br>
* @param holiday the Holiday to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
*/
public static int insertHoliday(Holiday holiday) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertHoliday(holiday);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertHoliday</code> insert a Holiday.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holiday the Holiday to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
*/
public static int insertHoliday(Connection connection, Holiday holiday) throws Exception {
return new TaskProcess(connection).insertHoliday(holiday);
}
/**
* <code>insertHolidayRule</code> insert a HolidayRule.
* <br>
* @param holidayRule the HolidayRule to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int insertHolidayRule(HolidayRule holidayRule) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertHolidayRule(holidayRule);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertHolidayRule</code> insert a HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holidayRule the HolidayRule to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int insertHolidayRule(Connection connection, HolidayRule holidayRule)
throws Exception {
return new TaskProcess(connection).insertHolidayRule(holidayRule);
}
/**
* <code>insertHolidayRules</code> insert a Vector of HolidayRule.
* <br>
* @param holidayRuleVector a Vector of HolidayRule to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int insertHolidayRules(Vector holidayRuleVector) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertHolidayRules(holidayRuleVector);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertHolidayRules</code> insert a Vector of HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holidayRuleVector a Vector of HolidayRule to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int insertHolidayRules(Connection connection, Vector holidayRuleVector)
throws Exception {
return new TaskProcess(connection).insertHolidayRules(holidayRuleVector);
}
/**
* <code>insertHolidays</code> insert a Vector of Holiday
* <br>
* @param holidayVector a Vector of Holiday to be inserted.
* @return the number of rows changed.
* @see com.acelet.s.task.Holiday
*/
public static int insertHolidays(Vector holidayVector) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertHolidays(holidayVector);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertHolidays</code> insert a Vector of Holiday
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holidayVector a Vector of Holiday to be inserted.
* @return the number of rows changed.
* @see com.acelet.s.task.Holiday
*/
public static int insertHolidays(Connection connection, Vector holidayVector) throws Exception {
return new TaskProcess(connection).insertHolidays(holidayVector);
}
/**
* <code>insertTask</code> insert the Task
* <br>
* @param task the Task to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.task.Task
* @see com.acelet.s.task.TaskConstants
*/
public static int insertTask(Task task) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).insertTask(task);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>insertTask</code> insert the Task
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param task the Task to be inserted.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.task.Task
* @see com.acelet.s.task.TaskConstants
*/
public static int insertTask(Connection connection, Task task) throws Exception {
return new TaskProcess(connection).insertTask(task);
}
public static boolean isInitialized() {
return initialized;
}
/**
* <code>modifyTask</code> modify the Task.
* <br>
* @param task the Task to be modified.
* @param newModifiedAt the time this task is updated.
* It should be from java.System.currentTimeMillis().
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.task.Task
* @see com.acelet.s.task.TaskConstants
*/
public static int modifyTask(Task task, long newModifiedAt) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).modifyTask(task, newModifiedAt);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>modifyTask</code> modify the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param task the Task to be modified.
* @param newModifiedAt the time this task is updated.
* It should be from java.System.currentTimeMillis().
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.job.AbstractTaskConstants
* @see com.acelet.s.task.Task
* @see com.acelet.s.task.TaskConstants
*/
public static int modifyTask(Connection connection, Task task, long newModifiedAt)
throws Exception {
return new TaskProcess(connection).modifyTask(task, newModifiedAt);
}
/**
* <code>renameHolidaySet</code> rename the holiday set.
* <br>
* @param oldName the old name of the holiday set.
* @param newName the new name of the holiday set.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
*/
public static int renameHolidaySet(String oldName, String newName) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).renameHolidaySet(oldName, newName);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>renameHolidaySet</code> rename the holiday set.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param oldName the old name of the holiday set.
* @param newName the new name of the holiday set.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
*/
public static int renameHolidaySet(Connection connection, String oldName, String newName)
throws Exception {
return new TaskProcess(connection).renameHolidaySet(oldName, newName);
}
/**
* <code>selectAllHolidays</code> select all Holiday.
* <br>
* @return Vector of Holiday
* @see com.acelet.s.task.Holiday
*/
public static Vector selectAllHolidays() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectAllHolidays();
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectAllHolidays</code> select all Holiday.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @return Vector of Holiday
* @see com.acelet.s.task.Holiday
*/
public static Vector selectAllHolidays(Connection connection) throws Exception {
return new TaskProcess(connection).selectAllHolidays();
}
/**
* <code>selectAllHolidayRules</code> select all HolidayRule.
* <br>
* @return Vector of HolidayRule.
* @see com.acelet.s.task.HolidayRule
*/
public static Vector selectAllHolidayRules() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectAllHolidayRules();
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectAllHolidayRules</code> select all HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @return Vector of HolidayRule.
* @see com.acelet.s.task.HolidayRule
*/
public static Vector selectAllHolidayRules(Connection connection) throws Exception {
return new TaskProcess(connection).selectAllHolidayRules();
}
/**
* <code>selectAllTasks_</code> select all Task.
* <br>
* @return Vector of Task
* @see com.acelet.s.task.Task
*/
public static Vector selectAllTasks() throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectAllTasks();
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectAllTasks_</code> select all Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @return Vector of Task
* @see com.acelet.s.task.Task
*/
public static Vector selectAllTasks(Connection connection) throws Exception {
return new TaskProcess(connection).selectAllTasks();
}
/**
* <code>selectAllWorkingTasks</code> select all WorkingTask.
* <br>
* @param from the start time.
* @param to the end time.
* @return Vector of WorkingTask
* @see com.acelet.s.task.WorkingTask
*/
public static Vector selectAllWorkingTasks(long from, long to) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectAllWorkingTasks(from, to);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectAllWorkingTasks</code> select all WorkingTask.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param from the start time.
* @param to the end time.
* @return Vector of WorkingTask
* @see com.acelet.s.task.WorkingTask
*/
public static Vector selectAllWorkingTasks(Connection connection, long from, long to)
throws Exception {
return new TaskProcess(connection).selectAllWorkingTasks(from, to);
}
/**
* <code>selectAllWorkingTasks_</code> select all WorkingTask.
* <br>
* @param from the start time.
* @param to the end time.
* @param rows the number of rows to select.
* @return Vector of WorkingTask
* @see com.acelet.s.task.WorkingTask
*/
public static Vector selectAllWorkingTasks(long from, long to, int rows) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectAllWorkingTasks(from, to, rows);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectAllWorkingTasks_</code> select all WorkingTask.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param from the start time.
* @param to the end time.
* @param rows the number of rows to select.
* @return Vector of WorkingTask
* @see com.acelet.s.task.WorkingTask
*/
public static Vector selectAllWorkingTasks(Connection connection, long from, long to, int rows)
throws Exception {
return new TaskProcess(connection).selectAllWorkingTasks(from, to, rows);
}
/**
* <code>selectHoliday</code> select the Holiday.
* <br>
* @param id the id of the Holiday.
* @return Holiday
* @see com.acelet.s.task.Holiday
* @see #selectAllHolidays
*/
public static Holiday selectHoliday(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectHoliday(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectHoliday</code> select the Holiday.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the Holiday.
* @return Holiday
* @see com.acelet.s.task.Holiday
* @see #selectAllHolidays
*/
public static Holiday selectHoliday(Connection connection, long id) throws Exception {
return new TaskProcess(connection).selectHoliday(id);
}
/**
* <code>selectHolidayRule</code> select the HolidayRule.
* <br>
* @param id the id of the holiday rule.
* @return HolidayRule
* @see com.acelet.s.task.HolidayRule
* @see #selectAllHolidayRules
*/
public static HolidayRule selectHolidayRule(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectHolidayRule(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectHolidayRule</code> select the HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the holiday rule.
* @return HolidayRule
* @see com.acelet.s.task.HolidayRule
* @see #selectAllHolidayRules
*/
public static HolidayRule selectHolidayRule(Connection connection, long id) throws Exception {
return new TaskProcess(connection).selectHolidayRule(id);
}
/**
* <code>selectTask</code> select the Task.
* <br>
* @param id the id of the Task.
* @return Task
* @see com.acelet.s.task.Task
* @see #selectAllTasks
*/
public static Task selectTask(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectTask(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectTask</code> select the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the Task.
* @return Task
* @see com.acelet.s.task.Task
* @see #selectAllTasks
*/
public static Task selectTask(Connection connection, long id) throws Exception {
return new TaskProcess(connection).selectTask(id);
}
/**
* <code>selectTask</code> select the Task.
* <br>
* @param name the name of the Task.
* @return Task
* @see com.acelet.s.task.Task
*/
public static Task selectTask(String name) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectTask(name);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectTask</code> select the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param name the name of the Task.
* @return Task
* @see com.acelet.s.task.Task
*/
public static Task selectTask(Connection connection, String name) throws Exception {
return new TaskProcess(connection).selectTask(name);
}
/**
* <code>selectWorkingTask</code> select the WorkingTask.
* <br>
* @param id the id of the WorkingTask.
* @return WorkingTask
* @see com.acelet.s.task.WorkingTask
* @see #selectAllWorkingTasks
*/
public static WorkingTask selectWorkingTask(long id) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).selectWorkingTask(id);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>selectWorkingTask</code> select the WorkingTask.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param id the id of the WorkingTask.
* @return WorkingTask
* @see com.acelet.s.task.WorkingTask
* @see #selectAllWorkingTasks
*/
public static WorkingTask selectWorkingTask(Connection connection, long id) throws Exception {
return new TaskProcess(connection).selectWorkingTask(id);
}
/**
* <code>sendAlertEmail</code> send an alert email.
* <br>
* @param subject the subject of the email.
* @param msg the email body.
*/
public static void sendAlertEmail(String subject, String msg) throws Exception {
SendEmail sendEmail = MailServerData.getSendEmailObject();
sendEmail.sendAlert(subject, "SuperScheduler: " + msg);
}
/**
* <code>updateHoliday</code> update the Holiday.
* <br>
* @param holiday the Holiday.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
*/
public static int updateHoliday(Holiday holiday) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).updateHoliday(holiday);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>updateHoliday</code> update the Holiday.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holiday the Holiday.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.Holiday
*/
public static int updateHoliday(Connection connection, Holiday holiday) throws Exception {
return new TaskProcess(connection).updateHoliday(holiday);
}
/**
* <code>updateHolidayRule</code> update the HolidayRule.
* <br>
* @param holidayRule the HolidayRule.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int updateHolidayRule(HolidayRule holidayRule) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).updateHolidayRule(holidayRule);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>updateHolidayRule</code> update the HolidayRule.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param holidayRule the HolidayRule.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.HolidayRule
*/
public static int updateHolidayRule(Connection connection, HolidayRule holidayRule)
throws Exception {
return new TaskProcess(connection).updateHolidayRule(holidayRule);
}
/**
* <code>updateTask</code> update the Task.
* <br>
* @param task the Task to be updated.
* @param newModifiedAt the time this task is updated.
* It should be from java.System.currentTimeMillis().
* @return Task
* @see com.acelet.s.task.Task
*/
public static int updateTask(Task task, long newModifiedAt) throws Exception {
return ApiBase.updateTask(task, newModifiedAt);
}
/**
* <code>updateTask</code> update the Task.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param task the Task to be updated.
* @param newModifiedAt the time this task is updated.
* It should be from java.System.currentTimeMillis().
* @return Task
* @see com.acelet.s.task.Task
*/
public static int updateTask(Connection connection, Task task, long newModifiedAt)
throws Exception {
return new TaskProcess(connection).updateTask(task, newModifiedAt);
}
/**
* <code>updateWorkingTask</code> update the WorkingTask.
* <br>
* @param workingTask the WorkingTask to be updated.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.WorkingTask
*/
public static int updateWorkingTask(WorkingTask workingTask) throws Exception {
Connection connection = null;
try {
connection = DirectTaskDatabaseConnection.getNewConnection();
return new TaskProcess(connection).updateWorkingTask(workingTask);
} finally {
if (connection != null)
connection.close();
}
}
/**
* <code>updateWorkingTask</code> update the WorkingTask.
* <br>
* @param connection the connection will be used for this operation. It will not be closed
* automatically.
* @param workingTask the WorkingTask to be updated.
* @return the number of rows changed. It is 1, if successful, 0 otherwise.
* @see com.acelet.s.task.WorkingTask
*/
public static int updateWorkingTask(Connection connection, WorkingTask workingTask)
throws Exception {
return new TaskProcess(connection).updateWorkingTask(workingTask);
}
}