Ignore:
Timestamp:
Nov 28, 2009, 2:17:34 PM (14 years ago)
Author:
gav
Message:

Upgrade quartz plugin to 0.4.1 propper.
Refactor and enable quartz scheduling for recurring tasks.
Adjust svn ignores to ignore all log files.
Create a pseudo system person for automated insertions.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 stacktrace.log
         1*.log
        22*.war
  • trunk/grails-app/jobs/TaskRecurringScheduleJob.groovy

    r137 r199  
     1import org.codehaus.groovy.grails.commons.*
    12
    2 class TaskRecurringScheduleJob {/*
    3     def timeout = 1000 // execute job once in 1 seconds
    4 //     def timeout = 60000
     3/**
     4* Provides a quartz job that reviews and generates all recurring tasks.
     5* The quartz scheduler is restarted if this file is edited so startDelay will then delay again.
     6* The execute method is called once every repeatInterval (in milliseconds).
     7* With concurrent=false the repeat interval starts counting after the previous job completes.
     8* Apparently we need a hibernate session otherwise we get a LazyInitializationException, default is true but we specify it to be sure.
     9*/
     10class TaskRecurringScheduleJob {
     11
     12    def taskRecurringScheduleService
     13
     14    def concurrent = false
     15    def sessionRequired = true
     16
     17    static triggers = {
     18        simple name: "GenerateAll",
     19                    startDelay: 60000,
     20                    repeatInterval: ConfigurationHolder.config.taskRecurringScheduleJob.repeatInterval*1000
     21    }
    522
    623    def execute() {
    7         println "TaskRecurringScheduleJob: tick"
    8         println "TaskRecurringScheduleJob: tock"/*
    9         def recurringScheduleInstanceList = RecurringSchedule.list()
    10         def now = new Date()
    1124
    12         recurringScheduleInstanceList.each() {
     25        // Some information can be accessed if we run with "def execute(context) ".
     26        // For more info see: http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html
     27        // log.debug context.getTrigger()
     28        // log.debug context.getPreviousFireTime()
     29        // log.debug context.getFireTime()
    1330
    14             if ( now > it.nextDueDate) {
    15                 def taskInstance = it.task
    16                 def subTaskInstance = new Task()
    17    
    18                 //Make our new Task a subTask.
    19                 subTaskInstance.parentTask = taskInstance
    20    
    21                 // Set the required properties
    22                 subTaskInstance.description = "Generated recurring task: "+taskInstance.description
    23                 subTaskInstance.comment = taskInstance.comment
    24                 subTaskInstance.taskGroup = taskInstance.taskGroup
    25                 subTaskInstance.taskStatus = TaskStatus.findByName("Not Started")
    26                 subTaskInstance.taskPriority = TaskPriority.get(2)
    27                 subTaskInstance.taskType = TaskType.get(1)
    28                 subTaskInstance.leadPerson = taskInstance.leadPerson
    29                 subTaskInstance.save()
    30 //                 if(subTaskInstance.save()){println "yes"}
    31    
    32                 //Set the assignedPersons
    33                 taskInstance.assignedPersons.each() {
    34    
    35                 def assignedPerson = new AssignedPerson(person: it.person,
    36                                                                                         task: subTaskInstance,
    37                                                                                         estimatedHour: it.estimatedHour,
    38                                                                                         estimatedMinute: it.estimatedMinute).save()
    39                 }
    40 
    41                 //Set the nextDueDate so that we don't loop ;-)
    42                 it.nextDueDate = it.nextDueDate + 1
    43    
    44             }
    45         }//recurringScheduleInstanceList.each()
    46     }*/
     31        // We do everything via services, quartz just sets up and fires off the thread.
     32        taskRecurringScheduleService.generateAll()
     33    }
    4734}
Note: See TracChangeset for help on using the changeset viewer.