- Timestamp:
- May 15, 2009, 4:09:30 PM (16 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r134 r136 32 32 { 33 33 println "BootStrapping demo data..." 34 3.times{println it} 34 35 35 36 /*********************** … … 415 416 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), 416 417 recurEvery: 1, 417 period: Period.get(1), 418 nextDueDate: new Date()) 418 recurPeriod: Period.get(1), 419 startDate: new Date(), 420 generateAhead: 1, 421 generateAheadPeriod: Period.get(1), 422 taskDuration: 1, 423 taskDurationPeriod: Period.get(1)) 419 424 BootStrapSaveAndTest(taskRecurringScheduleInstance) 420 425 … … 422 427 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2), 423 428 recurEvery: 1, 424 period: Period.get(1), 425 nextDueDate: new Date()) 429 recurPeriod: Period.get(1), 430 startDate: new Date(), 431 generateAhead: 1, 432 generateAheadPeriod: Period.get(1), 433 taskDuration: 1, 434 taskDurationPeriod: Period.get(1)) 426 435 BootStrapSaveAndTest(taskRecurringScheduleInstance) 427 436 -
trunk/grails-app/controllers/PersonController.groovy
r97 r136 39 39 /** 40 40 * Person delete action. Before removing an existing person, 41 * he should be removed from those authorities which he isinvolved.41 * they should be removed from those authorities which they are involved. 42 42 */ 43 43 def delete = { -
trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy
r135 r136 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 import org.codehaus.groovy.runtime.TimeCategory 2 3 3 4 class TaskRecurringScheduleDetailedController extends BaseController { … … 66 67 } 67 68 } 68 taskRecurringScheduleInstance.properties = params 69 // taskRecurringScheduleInstance.properties = params 70 setUpdateProperties() 71 69 72 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 70 73 flash.message = "TaskRecurringSchedule ${params.id} updated" … … 104 107 else { 105 108 106 taskRecurringScheduleInstance.nextDueDate = new Date()107 108 // taskRecurringScheduleInstance.nextDueDate = calculateNextDueDate(new Date())109 110 109 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save()) { 111 110 … … 127 126 128 127 } 129 130 // private Date calculateNextDueDate(nextDue) { 131 // // def now = new Date() 132 // // def calculatedDays = new Integer() 133 // // def nextDue = new Date() 134 // 135 // // switch (period) { 136 // // case "Day(s)": 137 // // calculatedDays = period 138 // // nextDue = now + calculatedDays 139 // // case "Week(s)": 140 // // calculatedDays = period * 7 141 // // nextDue = now + calculatedDays 142 // // // default: 143 // // } 144 // nextDue = nextDue + 1 145 // return nextDue 146 // } 147 128 129 private setUpdateProperties() { 130 def originalStartDate = taskRecurringScheduleInstance.startDate 131 132 if(taskRecurringScheduleInstance.startDate == params.startDate) { 133 taskRecurringScheduleInstance.properties = params 134 } 135 else { 136 taskRecurringScheduleInstance.properties = params 137 taskRecurringScheduleInstance.nextTargetStartDate = params.startDate 138 } 139 140 } 141 142 /* 143 private Date calculateNextDueDate(recurEvery, period, startDate) { 144 def nextDue = new Date() 145 146 switch (period) { 147 case "Day(s)": 148 use(TimeCategory) { 149 nextDue = startDate + recurEvery.days 150 } 151 return nextDue 152 case "Week(s)": 153 use(TimeCategory) { 154 nextDue = startDate + recurEvery.weeks 155 } 156 return nextDue 157 case "Month(s)": 158 use(TimeCategory) { 159 nextDue = startDate + recurEvery.months 160 } 161 return nextDue 162 case "Year(s)": 163 use(TimeCategory) { 164 nextDue = startDate + recurEvery.years 165 } 166 return nextDue 167 default: 168 return nextDue 169 } 170 171 }*/ 148 172 } -
trunk/grails-app/domain/Period.groovy
r131 r136 5 5 6 6 static hasMany = [taskRecurringSchedules: TaskRecurringSchedule] 7 // 7 8 static mappedBy = [taskRecurringSchedules:"recurPeriod"] 9 8 10 // static belongsTo = [] 9 // 11 10 12 // static constraints = { 11 13 // -
trunk/grails-app/domain/TaskRecurringSchedule.groovy
r135 r136 1 import org.codehaus.groovy.runtime.TimeCategory 2 1 3 class TaskRecurringSchedule { 2 4 3 5 Task lastGeneratedSubTask 4 Period period 6 Period recurPeriod 7 Period generateAheadPeriod 8 Period taskDurationPeriod 5 9 6 10 Integer recurEvery = 1 11 Integer taskDuration = 0 12 Integer generateAhead = 1 7 13 Date startDate = new Date() 8 14 Date lastGeneratedDate 9 Date nextDueDate 15 Date nextTargetStartDate = new Date() 16 Date nextTargetCompletionDate = new Date() 17 Date nextGenerationDate = new Date() 10 18 boolean isEnabled = true 11 19 … … 15 23 16 24 static constraints = { 25 // startDate(validator: {return (it > new Date())}) 26 recurEvery(min:0, max:365) 27 taskDuration(min:0, max:365) 28 generateAhead(min:0, max:365) 17 29 lastGeneratedDate(blank:true, nullable:true) 18 30 lastGeneratedSubTask(blank:true, nullable:true) … … 20 32 21 33 String toString() { 22 "Recur every ${recurEvery} ${ period}"34 "Recur every ${recurEvery} ${recurPeriod}" 23 35 } 36 37 //As of Grails 1.1 this does not fire/pass before validation. 38 //But setting defaults above and placing this code here in the hope that this will be fixed in future versions. 39 def beforeInsert = { 40 def now = new Date() 41 42 nextTargetStartDate = startDate 43 44 //nextGenerationDate 45 switch (generateAheadPeriod.period) { 46 case "Day(s)": 47 use(TimeCategory) { 48 nextGenerationDate = nextTargetStartDate - generateAhead.days 49 } 50 break 51 case "Week(s)": 52 use(TimeCategory) { 53 nextGenerationDate = nextTargetStartDate - generateAhead.weeks 54 } 55 break 56 case "Month(s)": 57 use(TimeCategory) { 58 nextGenerationDate = nextTargetStartDate - generateAhead.months 59 } 60 break 61 case "Year(s)": 62 use(TimeCategory) { 63 nextGenerationDate = nextTargetStartDate - generateAhead.years 64 } 65 break 66 default: 67 break 68 } 69 70 if( nextGenerationDate < now) {nextGenerationDate = now} 71 72 //nextTargetCompletionDate 73 switch (taskDurationPeriod.period) { 74 case "Day(s)": 75 use(TimeCategory) { 76 nextTargetCompletionDate = nextTargetStartDate + taskDuration.days 77 } 78 break 79 case "Week(s)": 80 use(TimeCategory) { 81 nextTargetCompletionDate = nextTargetStartDate + taskDuration.weeks 82 } 83 break 84 case "Month(s)": 85 use(TimeCategory) { 86 nextTargetCompletionDate = nextTargetStartDate + taskDuration.months 87 } 88 break 89 case "Year(s)": 90 use(TimeCategory) { 91 nextTargetCompletionDate = nextTargetStartDate + taskDuration.years 92 } 93 break 94 default: 95 break 96 } 97 98 } 99 24 100 } 25 101
Note: See TracChangeset
for help on using the changeset viewer.