1 | |
---|
2 | class TaskRecurringScheduleJob {/* |
---|
3 | // def timeout = 5000 // execute job once in 5 seconds |
---|
4 | def timeout = 60000 |
---|
5 | |
---|
6 | def execute() { |
---|
7 | // println "TaskRecurringScheduleJob: tick" |
---|
8 | // println "TaskRecurringScheduleJob: tock" |
---|
9 | def recurringScheduleInstanceList = RecurringSchedule.list() |
---|
10 | def now = new Date() |
---|
11 | |
---|
12 | recurringScheduleInstanceList.each() { |
---|
13 | |
---|
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 | }*/ |
---|
47 | } |
---|