
class TaskRecurringScheduleJob {/*
    def timeout = 1000 // execute job once in 1 seconds
//     def timeout = 60000

    def execute() {
        println "TaskRecurringScheduleJob: tick"
        println "TaskRecurringScheduleJob: tock"/*
        def recurringScheduleInstanceList = RecurringSchedule.list()
        def now = new Date()

        recurringScheduleInstanceList.each() {

            if ( now > it.nextDueDate) {
                def taskInstance = it.task
                def subTaskInstance = new Task()
    
                //Make our new Task a subTask.
                subTaskInstance.parentTask = taskInstance
    
                // Set the required properties
                subTaskInstance.description = "Generated recurring task: "+taskInstance.description
                subTaskInstance.comment = taskInstance.comment
                subTaskInstance.taskGroup = taskInstance.taskGroup
                subTaskInstance.taskStatus = TaskStatus.findByName("Not Started")
                subTaskInstance.taskPriority = TaskPriority.get(2)
                subTaskInstance.taskType = TaskType.get(1)
                subTaskInstance.leadPerson = taskInstance.leadPerson
                subTaskInstance.save()
//                 if(subTaskInstance.save()){println "yes"}
    
                //Set the assignedPersons
                taskInstance.assignedPersons.each() {
    
                def assignedPerson = new AssignedPerson(person: it.person,
                                                                                        task: subTaskInstance,
                                                                                        estimatedHour: it.estimatedHour,
                                                                                        estimatedMinute: it.estimatedMinute).save()
                }

                //Set the nextDueDate so that we don't loop ;-)
                it.nextDueDate = it.nextDueDate + 1
    
            }
        }//recurringScheduleInstanceList.each()
    }*/
}
