Changeset 445
- Timestamp:
- Mar 16, 2010, 5:18:20 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/TaskRecurringSchedule.groovy
r210 r445 12 12 Integer generateAhead = 1 13 13 Integer subTasksGenerated = 0 14 Integer maxSubTasks = 0 14 15 Date nextGenerationDate = new Date() 15 Date nextTargetStartDate = new Date() 16 Date nextTargetStartDate = new Date()+1 16 17 Date nextTargetCompletionDate = new Date() 17 18 boolean enabled = true 19 boolean useTargetCompletionDate = false 18 20 19 21 // static hasMany = [] -
trunk/grails-app/i18n/messages.properties
r440 r445 129 129 taskRecurringSchedule.generateAhead=Generate Ahead 130 130 taskRecurringSchedule.generateAhead.help=How far ahead of the next target start date to generate sub tasks. \ 131 This allows work packs to be built and work load to be seen and planned. \ 132 Only generate ahead as far as short term planning is done, since all generated sub task values will be set and therefore \ 133 time consuming to change. 131 This allows work packs to be built and work load to be seen and planned. \ 132 Only generate ahead as far as short term planning is done, since all generated sub task \ 133 values will be set and therefore time consuming to change. 134 taskRecurringSchedule.maxSubTasks=Max Sub Tasks 135 taskRecurringSchedule.maxSubTasks.help=Maximum number of sub tasks to generate. Set to 0 \ 136 for no limit. 137 taskRecurringSchedule.useTargetCompletionDate=Target Completion 138 taskRecurringSchedule.useTargetCompletionDate.help=On to use the parent task's target completion date. \ 139 Off to continue generation past the parent task's target completion date. 134 140 taskRecurringSchedule.enabled=Enabled 135 taskRecurringSchedule.enabled.help=On to enable automatic sub task generation. Off to stop automatic sub task generation. 141 taskRecurringSchedule.enabled.help=On to enable automatic sub task generation. \ 142 Off to stop automatic sub task generation. <br /><br />\ 143 The system will turn this off if there are no further sub tasks to be generated. 136 144 137 145 task.primaryAsset=Primary Asset -
trunk/grails-app/services/TaskRecurringScheduleService.groovy
r434 r445 15 15 def generateAll() { 16 16 17 def taskRecurringScheduleList = TaskRecurringSchedule.findAllByEnabled(true)18 19 17 // Prevent errors if base data has not yet been created. 20 18 if(!appConfigService.exists("baseDataCreated")) { … … 26 24 } 27 25 28 taskRecurringScheduleList.each() { 26 def p = [:] 27 def targetCompletionDate 28 def nextTargetCompletionDate 29 def tomorrow = dateUtilService.tomorrow 30 31 def taskRecurringScheduleList = TaskRecurringSchedule.findAllByEnabled(true) 32 33 // Stop generation if max reached. 34 def maxSubTasksReached = { 35 if( (it.maxSubTasks > 0) && (it.subTasksGenerated >= it.maxSubTasks) ) { 36 it.enabled = false 37 return true 38 } 39 return false 40 } 41 42 // Stop generation by targetCompletionDate. 43 def targetCompletionDateReached = { 44 if( it.useTargetCompletionDate) { 45 targetCompletionDate = dateUtilService.getMidnight(it.task.targetCompletionDate) 46 nextTargetCompletionDate = dateUtilService.getMidnight(it.nextTargetCompletionDate) 47 if(nextTargetCompletionDate > targetCompletionDate) { 48 it.enabled = false 49 return true 50 } 51 } 52 return false 53 } 54 55 // Main loop. 56 for(it in taskRecurringScheduleList) { 57 58 if(maxSubTasksReached(it)) 59 continue 60 61 if(targetCompletionDateReached(it)) 62 continue 29 63 30 64 if (dateUtilService.tomorrow > it.nextGenerationDate) { 31 defp = [:]65 p = [:] 32 66 33 // Build the requiredparams.34 35 36 37 38 67 // Build the subTask params. 68 p.targetStartDate = it.nextTargetStartDate 69 p.targetCompletionDate = it.nextTargetCompletionDate 70 if(it.task.taskProcedure) p.taskProcedure = it.task.taskProcedure 71 if(it.task.assignedGroups) p.assignedGroups = new ArrayList(it.task.assignedGroups) 72 if(it.task.assignedPersons) p.assignedPersons = new ArrayList(it.task.assignedPersons) 39 73 40 41 42 43 44 45 46 47 48 49 50 51 74 def result = taskService.createSubTask(it.task, p) 75 if( !result.error ) { 76 it.lastGeneratedSubTask = result.taskInstance 77 it.subTasksGenerated++ 78 it.setNextTargetStartDate() 79 it.setNextGenerationDate() 80 it.setNextTargetCompletionDate() 81 } 82 else { 83 log.error "Sub task generation for recurring schedule ${it.id} failed." 84 log.error result.taskInstance.errors 85 } 52 86 } 53 87 54 } 55 } 88 // Run the completion reached checks for a second time so 89 // that this recurring schedule does not run again if 90 // there are no more subTasks to be generated. 91 if(maxSubTasksReached(it)) 92 continue 93 94 if(targetCompletionDateReached(it)) 95 continue 96 97 } // for() 98 } // generateAll() 56 99 57 100 /** -
trunk/grails-app/views/taskDetailed/show.gsp
r431 r445 561 561 562 562 <tr class="prop"> 563 <td valign="top" class="name">Enabled:</td> 564 565 <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td> 566 </tr> 567 568 <tr class="prop"> 563 569 <td valign="top" class="name">Next Generation Date:</td> 564 570 … … 598 604 <g:formatDate date="${taskRecurringScheduleInstance.nextTargetCompletionDate}" format="EEE, dd-MMM-yyyy"/> 599 605 </td> 600 </tr>601 602 <tr class="prop">603 <td valign="top" class="name">Enabled:</td>604 605 <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>606 606 </tr> 607 607 -
trunk/grails-app/views/taskRecurringScheduleDetailed/create.gsp
r213 r445 81 81 </td> 82 82 </tr> 83 84 <tr class="prop"> 85 <td valign="top" class="name"> 86 <label for="maxSubTasks">Max Sub Tasks:</label> 87 </td> 88 <td valign="top" class="value" > 89 <input type="text" class="time ${hasErrors(bean:taskRecurringScheduleInstance,field:'maxSubTasks','errors')}" 90 id="maxSubTasks" name="maxSubTasks" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'maxSubTasks')}" /> 91 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.maxSubTasks" /> 92 </td> 93 </tr> 94 95 <tr class="prop"> 96 <td valign="top" class="name"> 97 <label for="useTargetCompletionDate">Use Target Completion Date:</label> 98 </td> 99 <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'useTargetCompletionDate','errors')}"> 100 <g:checkBox name="useTargetCompletionDate" 101 value="${taskRecurringScheduleInstance?.useTargetCompletionDate}" > 102 </g:checkBox> 103 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.useTargetCompletionDate" /> 104 <g:formatDate date="${taskRecurringScheduleInstance.task.targetCompletionDate}" 105 format="EEE, dd-MMM-yyyy"/> 106 </td> 107 </tr> 83 108 84 109 <tr class="prop"> -
trunk/grails-app/views/taskRecurringScheduleDetailed/edit.gsp
r213 r445 34 34 <td valign="top" name="recForTask" class="value"> 35 35 <g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance?.task?.id}">${taskRecurringScheduleInstance?.task?.encodeAsHTML()}</g:link> 36 </td> 37 </tr> 38 39 <tr class="prop"> 40 <td valign="top" class="name"> 41 <label for="enabled">Enabled:</label> 42 </td> 43 <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}"> 44 <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox> 45 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.enabled" /> 36 46 </td> 37 47 </tr> … … 82 92 </td> 83 93 </tr> 94 95 <tr class="prop"> 96 <td valign="top" class="name"> 97 <label for="maxSubTasks">Max Sub Tasks:</label> 98 </td> 99 <td valign="top" class="value" > 100 <input type="text" class="time ${hasErrors(bean:taskRecurringScheduleInstance,field:'maxSubTasks','errors')}" 101 id="maxSubTasks" name="maxSubTasks" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'maxSubTasks')}" /> 102 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.maxSubTasks" /> 103 </td> 104 </tr> 84 105 85 106 <tr class="prop"> 86 107 <td valign="top" class="name"> 87 <label for=" enabled">Enabled:</label>108 <label for="useTargetCompletionDate">Use Target Completion Date:</label> 88 109 </td> 89 <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}"> 90 <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox> 91 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.enabled" /> 110 <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'useTargetCompletionDate','errors')}"> 111 <g:checkBox name="useTargetCompletionDate" 112 value="${taskRecurringScheduleInstance?.useTargetCompletionDate}" > 113 </g:checkBox> 114 <g:helpBalloon class="helpballoon" code="taskRecurringSchedule.useTargetCompletionDate" /> 115 <g:formatDate date="${taskRecurringScheduleInstance.task.targetCompletionDate}" 116 format="EEE, dd-MMM-yyyy"/> 92 117 </td> 93 118 </tr> -
trunk/grails-app/views/taskRecurringScheduleDetailed/show.gsp
r199 r445 33 33 <td valign="top" class="value">${taskRecurringScheduleInstance.encodeAsHTML()}</td> 34 34 </tr> 35 36 <tr class="prop"> 37 <td valign="top" class="name">Enabled:</td> 38 39 <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td> 40 </tr> 41 42 <g:if test="${taskRecurringScheduleInstance.useTargetCompletionDate}" > 43 <tr class="prop"> 44 <td valign="top" class="name">Task Target Completion:</td> 45 46 <td valign="top" class="value"> 47 <g:formatDate date="${taskRecurringScheduleInstance.task.targetCompletionDate}" 48 format="EEE, dd-MMM-yyyy"/> 49 </td> 50 </tr> 51 </g:if> 35 52 36 53 <tr class="prop"> … … 74 91 </tr> 75 92 76 <tr class="prop">77 <td valign="top" class="name">Enabled:</td>78 79 <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>80 </tr>81 82 93 </tbody> 83 94 </table> … … 100 111 </td> 101 112 </tr> 113 114 <g:if test="${taskRecurringScheduleInstance.maxSubTasks > 0}" > 115 <tr class="prop"> 116 <td valign="top" class="name">Max Sub Tasks:</td> 117 118 <td valign="top" class="value"> 119 ${fieldValue(bean:taskRecurringScheduleInstance, field:'maxSubTasks')} 120 </td> 121 </tr> 122 </g:if> 102 123 103 124 <g:if test="${taskRecurringScheduleInstance.lastGeneratedSubTask}">
Note: See TracChangeset
for help on using the changeset viewer.