Class TaskDAO

java.lang.Object
com.almis.awe.config.ServiceConfig
com.almis.awe.scheduler.dao.TaskDAO
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class TaskDAO extends ServiceConfig
  • Constructor Details

    • TaskDAO

      public TaskDAO(org.quartz.Scheduler scheduler, int storedExecutions, String executionLogPath, QueryService queryService, MaintainService maintainService, QueryUtil queryUtil, CalendarDAO calendarDAO, ServerDAO serverDAO, FileChecker fileChecker)
      Autowired constructor
      Parameters:
      scheduler - Scheduler
      storedExecutions - Stored execution
      executionLogPath - Execution log path
      queryService - Query service
      maintainService - Maintain service
      queryUtil - Query utilities
      calendarDAO - Calendar DAO
      serverDAO - Server DAO
      fileChecker - File checker
  • Method Details

    • getTask

      public Task getTask(org.quartz.Trigger trigger)
      Load task from trigger
      Parameters:
      trigger - Trigger
      Returns:
      Generated task
    • getTask

      public Task getTask(org.quartz.JobDetail jobDetail)
      Load task from job detail
      Parameters:
      jobDetail - Job detail
      Returns:
      Generated task
    • getTask

      @Async("schedulerTaskPool") public Future<Task> getTask(Integer taskId) throws AWException
      Load task from task id
      Parameters:
      taskId - Task id
      Returns:
      Generated task
      Throws:
      AWException - Error retrieving task
    • getTask

      @Async("schedulerTaskPool") public Future<Task> getTask(Integer taskId, TaskLaunchType launchType) throws AWException
      Load task from task id
      Parameters:
      taskId - Task id
      launchType - forced launch type
      Returns:
      Generated task
      Throws:
      AWException - Error retrieving task
    • getTask

      @Async("schedulerTaskPool") public Future<Task> getTask(Integer taskId, String database, TaskLaunchType launchType) throws AWException
      Load task from task id
      Parameters:
      taskId - Task id
      database - Database
      launchType - forced launch type
      Returns:
      Generated task
      Throws:
      AWException - Error retrieving task
    • isTaskExecutionAllowed

      public boolean isTaskExecutionAllowed(Task task)
      Check if task is allowed to be launched
      Parameters:
      task - Task
      Returns:
      Task is allowed
    • startTask

      public TaskExecution startTask(Task task) throws AWException
      Start a task
      Parameters:
      task - Task
      Returns:
      Task execution
      Throws:
      AWException
    • endTask

      public TaskExecution endTask(Task task, TaskExecution execution) throws AWException
      End a task
      Parameters:
      task - Task
      execution - Task execution
      Returns:
      Task execution
      Throws:
      AWException
    • getExecutionsToPurge

      public ServiceData getExecutionsToPurge(Integer taskId, Integer executions) throws AWException
      Retrieve executions to purge (sorted)
      Parameters:
      taskId - Task identifier
      executions - Executions to purge
      Returns:
      Purge results
      Throws:
      AWException - Error retrieving executions to be purged
    • purgeExecutionLogFiles

      public ServiceData purgeExecutionLogFiles(Integer taskId, Integer executions) throws AWException
      Purge execution log files
      Parameters:
      taskId - Task identifier
      Throws:
      AWException - Error on purge
    • purgeExecutionsAtStart

      public ServiceData purgeExecutionsAtStart() throws AWException
      Purge executions at start
      Throws:
      AWException - Error on purge
    • updateInterruptedTasks

      public ServiceData updateInterruptedTasks() throws AWException
      Update running task status [4] to interrupted [6]
      Returns:
      Interrupt task status
      Throws:
      AWException
    • changeStatus

      public ServiceData changeStatus(Task task, TaskExecution execution, TaskStatus status, String reason) throws AWException
      Change a task status
      Parameters:
      execution - Task execution
      status - New status
      Returns:
      Change status
      Throws:
      AWException
    • addTaskToScheduler

      public void addTaskToScheduler(Task task) throws AWException
      Add task to the scheduler
      Parameters:
      task - Task to add
      Throws:
      AWException - Error adding task to scheduler
    • insertTask

      public ServiceData insertTask(Integer taskId) throws AWException
      Insert and schedule a new task
      Parameters:
      taskId - Task identifier
      Returns:
      ServiceData
      Throws:
      AWException - Error inserting task
    • updateTask

      public ServiceData updateTask(Integer taskId) throws AWException
      Update and reschedule a task
      Parameters:
      taskId - Task identifier list
      Returns:
      ServiceData
      Throws:
      AWException - Error updating task
    • deleteTask

      public ServiceData deleteTask(List<Integer> ideTsk) throws AWException
      Delete a task from scheduler
      Parameters:
      ideTsk - Task identifier list
      Returns:
      ServiceData
      Throws:
      AWException - Error deleting task
    • deleteTask

      public ServiceData deleteTask(Integer ideTsk) throws AWException
      Delete a single task from scheduler
      Parameters:
      ideTsk - Task i dentifier list
      Returns:
      ServiceData
      Throws:
      AWException - Error deleting task
    • updateExecutionTime

      public ServiceData updateExecutionTime(Integer taskId, Integer executionId) throws AWException
      Update execution time
      Parameters:
      taskId - Task id
      Returns:
      Execution time
      Throws:
      AWException - Error updating execution time
    • getTaskExecutionList

      public ServiceData getTaskExecutionList(Integer taskId) throws AWException
      Retrieve task execution list fixed
      Parameters:
      taskId - Task id
      Returns:
      Task execution list fixed
      Throws:
      AWException - Error retrieving task execution list
    • getProgressNode

      public com.fasterxml.jackson.databind.node.ObjectNode getProgressNode(long percentage)
      Retrieve progress node
      Parameters:
      percentage - Percentage
      Returns:
      Progress node
    • getStatusIcon

      public com.fasterxml.jackson.databind.node.ObjectNode getStatusIcon(TaskExecution execution)
      Generate status icon
      Parameters:
      execution - Execution
      Returns:
      Status icon
    • getProgress

      public long getProgress(Date initialDate, long averageExecution)
      Retrieve progress
      Parameters:
      initialDate - Initial date
      averageExecution - Average execution
      Returns:
      Progress
    • getElapsedTime

      public Integer getElapsedTime(Date startDate)
      Retrieve elapsed time from a start date (without ms)
      Parameters:
      startDate - Start date
      Returns:
      Elapsed time
    • executeTaskNow

      public ServiceData executeTaskNow(Integer taskId, String user) throws AWException
      Execute the selected task now
      Parameters:
      taskId - Task identifier
      Returns:
      ServiceData
      Throws:
      AWException - Error executing immediate task
    • executeDependency

      public void executeDependency(Integer taskId, TaskExecution parentExecution) throws AWException
      Execute the task ask dependency
      Parameters:
      taskId - Task identifier
      parentExecution - Parent execution
      Throws:
      AWException - Error executing dependency task
    • pauseTask

      public ServiceData pauseTask(Task task) throws org.quartz.SchedulerException
      Pause the selected task
      Parameters:
      task - Task to pause
      Returns:
      ServiceData
      Throws:
      org.quartz.SchedulerException - Error pausing task
    • resumeTask

      public ServiceData resumeTask(Task task) throws AWException
      Resume the selected task
      Parameters:
      task - Task to resume
      Returns:
      ServiceData
      Throws:
      AWException - Error resuming task
    • getTaskList

      public ServiceData getTaskList(TaskListCriteria taskListCriteria) throws AWException
      Retrieve the task list
      Returns:
      ServiceData
      Throws:
      AWException - Error retrieving task list
    • loadMaintainVariables

      public ServiceData loadMaintainVariables(String maintainStr) throws AWException
      Load needed variables from the selected maintain
      Parameters:
      maintainStr - Maintain identifier
      Returns:
      ServiceData
      Throws:
      AWException - Error loading maintain variables
    • loadExecutionScreen

      public ServiceData loadExecutionScreen(String path, com.fasterxml.jackson.databind.node.ObjectNode address) throws AWException
      Load execution screen parameters
      Parameters:
      path - Log path
      address - Button address
      Returns:
      ServiceData
      Throws:
      AWException
    • reloadExecutionScreen

      public ServiceData reloadExecutionScreen(Integer taskId, Integer executionId) throws AWException
      Reload execution task parameters
      Parameters:
      taskId - Task identifier
      executionId - Execution identifier
      Returns:
      Service Data
      Throws:
      AWException - Error reloading execution screen
    • getTaskExecution

      public TaskExecution getTaskExecution(org.quartz.Trigger trigger)
      Get task execution from trigger
      Parameters:
      trigger - Trigger
      Returns:
      Task execution from trigger
    • getTaskExecution

      public TaskExecution getTaskExecution(Integer taskId, Integer executionId) throws AWException
      Get execution from Database
      Parameters:
      taskId - Task id
      executionId - Execution id
      Returns:
      Task execution
      Throws:
      AWException - Error retrieving task execution from database
    • getTaskExecution

      public TaskExecution getTaskExecution(Task task, Integer executionId) throws AWException
      Get execution from Database
      Parameters:
      task - Task
      executionId - Execution id
      Returns:
      Task execution
      Throws:
      AWException - Error retrieving task execution from database
    • getAverageTime

      public Integer getAverageTime(Integer taskId) throws AWException
      Get the average time as string
      Parameters:
      taskId - Task identifier
      Returns:
      Average time as string
      Throws:
      AWException - Error retrieving average time
    • onFinishTask

      public void onFinishTask(Task task, TaskExecution execution) throws AWException
      On finish task event
      Parameters:
      task - Finished task
      execution - Task execution
      Throws:
      AWException