Changeset 529
- Timestamp:
- May 10, 2010, 8:30:25 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/CreateDataService.groovy
r523 r529 845 845 targetStartDate: dateUtilService.tomorrow, 846 846 targetCompletionDate: dateUtilService.tomorrow, 847 parentTask: Task. get(1)]847 parentTask: Task.list()[0]] 848 848 849 849 taskResult = taskService.save(p) … … 858 858 targetStartDate: dateUtilService.yesterday, 859 859 targetCompletionDate: dateUtilService.yesterday, 860 parentTask: Task. get(1)]860 parentTask: Task.list()[0]] 861 861 862 862 taskResult = taskService.save(p) … … 871 871 targetStartDate: dateUtilService.today, 872 872 targetCompletionDate: dateUtilService.oneWeekFromNow, 873 parentTask: Task. get(1)]873 parentTask: Task.list()[0]] 874 874 875 875 taskResult = taskService.save(p) … … 927 927 928 928 //Entry #1 929 p = [task: Task. get(1),929 p = [task: Task.list()[0], 930 930 entryType: EntryType.get(1), 931 931 comment: "This level sensor is causing us trouble.", … … 935 935 936 936 //Entry #2 937 p = [task: Task. get(1),937 p = [task: Task.list()[0], 938 938 entryType: EntryType.get(3), 939 939 comment: "Cleaned sensor, see how it goes.", … … 943 943 944 944 //Entry #3 945 p = [task: Task. get(1),945 p = [task: Task.list()[0], 946 946 entryType: EntryType.get(3), 947 947 comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", … … 958 958 //AssignedGroup #1 959 959 p = [personGroup: PersonGroup.get(1), 960 task: Task. get(1),960 task: Task.list()[0], 961 961 estimatedHour: 2, 962 962 estimatedMinute: 30] … … 965 965 //AssignedGroup #2 966 966 p = [personGroup: PersonGroup.get(2), 967 task: Task. get(1),967 task: Task.list()[0], 968 968 estimatedHour: 1, 969 969 estimatedMinute: 0] … … 978 978 //AssignedPerson #1 979 979 p = [person: Person.get(4), 980 task: Task. get(1),980 task: Task.list()[0], 981 981 estimatedHour: 1, 982 982 estimatedMinute: 20] … … 985 985 //AssignedPerson #2 986 986 p = [person: Person.get(5), 987 task: Task. get(1),987 task: Task.list()[0], 988 988 estimatedHour: 3, 989 989 estimatedMinute: 30] … … 997 997 998 998 //TaskRecurringSchedule #1 999 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task. get(1),999 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0], 1000 1000 recurEvery: 1, 1001 1001 recurPeriod: Period.get(2), … … 1008 1008 1009 1009 //TaskRecurringSchedule #2 1010 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task. get(6),1010 taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0], 1011 1011 recurEvery: 1, 1012 1012 recurPeriod: Period.get(1), … … 1270 1270 taskProcedureInstance = new TaskProcedure(name: "Daily check") 1271 1271 saveAndTest(taskProcedureInstance) 1272 taskProcedureInstance.addToTasks(Task. get(1))1272 taskProcedureInstance.addToTasks(Task.list()[0]) 1273 1273 } 1274 1274 -
trunk/grails-app/services/TaskSearchService.groovy
r524 r529 251 251 * @param endDate The end date to get tasks for, defaults to the start of tomorrow and is exclusive (less than). 252 252 */ 253 def getBudgetTasks(params, budgetStatus=null, startDate=null, endDate=null) {253 def getBudgetTasks(params, taskBudgetStatus=null, startDate=null, endDate=null) { 254 254 def paginateParams = [:] 255 255 paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) … … 261 261 262 262 def namedParams = [:] 263 namedParams. budgetStatus = budgetStatus ?: TaskBudgetStatus.read(2) // Planned.263 namedParams.taskBudgetStatus = taskBudgetStatus ?: TaskBudgetStatus.read(2) // Planned. 264 264 namedParams.startDate = startDate ?: dateUtilService.today 265 namedParams.endDate = endDate ?: dateUtilService. oneWeekAgo265 namedParams.endDate = endDate ?: dateUtilService.tomorrow 266 266 267 267 def baseQuery = "from Task as task \ 268 268 where (task.trash = false \ 269 and task. budgetStatus = :budgetStatus \269 and task.taskBudgetStatus = :taskBudgetStatus \ 270 270 and task.targetStartDate < :endDate \ 271 271 and task.targetCompletionDate >= :startDate \ -
trunk/test/integration/TaskSearchServiceTests.groovy
r514 r529 121 121 void testGetPersonsTasks() { 122 122 123 def result124 123 def p = [:] 124 def params = [:] 125 125 126 126 // Todays tasks should be returned, since Person #1 is lead and created the tasks. 127 def tasks = taskSearchService.getPersonsTasks( [:])127 def tasks = taskSearchService.getPersonsTasks(params) 128 128 assert tasks.totalCount == taskCount 129 129 … … 131 131 taskA.trash = true 132 132 taskA.save(flush:true) 133 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 1133 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1 134 134 taskB.trash = true 135 135 taskB.save(flush:true) 136 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 2136 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 2 137 137 138 138 // Restored tasks should be returned. 139 139 taskA.trash = false 140 140 taskA.save(flush:true) 141 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 1141 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1 142 142 taskB.trash = false 143 143 taskB.save(flush:true) 144 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount144 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount 145 145 146 146 // Tomorrows tasks should not be returned. … … 148 148 taskA.targetCompletionDate = dateUtilService.tomorrow 149 149 taskA.save(flush:true) 150 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 1150 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1 151 151 152 152 // Tomorrows tasks should be returned, if we ask for them. 153 assert taskSearchService.getPersonsTasks( [:], null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount153 assert taskSearchService.getPersonsTasks(params, null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount 154 154 155 155 // Yesterdays tasks should not be returned. … … 157 157 taskA.targetCompletionDate = dateUtilService.yesterday 158 158 taskA.save(flush:true) 159 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 1159 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1 160 160 161 161 // Yesterdays tasks should be returned, if we ask for them. 162 assert taskSearchService.getPersonsTasks( [:], null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount162 assert taskSearchService.getPersonsTasks(params, null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount 163 163 164 164 // Tasks that span today should be returned. … … 166 166 taskA.targetCompletionDate = dateUtilService.tomorrow 167 167 taskA.save(flush:true) 168 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount168 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount 169 169 170 170 // Tasks for a different person should not be returned. 171 171 taskA.leadPerson = Person.get(2) 172 172 taskA.save(flush:true) 173 assert taskSearchService.getPersonsTasks( [:]).totalCount == taskCount - 1173 assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1 174 174 175 175 // Tasks for a specified leadPerson should be returned. … … 177 177 taskA.leadPerson = Person.get(2) 178 178 taskA.save(flush:true) 179 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 0179 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0 180 180 taskA.approved = true 181 181 taskA.save(flush:true) 182 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 1182 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1 183 183 // Moving the task to the trash, stops it being returned. 184 184 taskA.trash = true 185 185 taskA.save(flush:true) 186 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 0186 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0 187 187 188 188 // Tasks assigned to a person should be returned. … … 193 193 estimatedMinute: 20] 194 194 assert assignedPersonService.save(p).error == null 195 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 0195 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0 196 196 taskB.approved = true 197 197 taskB.save(flush:true) 198 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 1198 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1 199 199 200 200 // Tasks assigned to a person via a group should be returned. … … 209 209 estimatedMinute: 30] 210 210 assert assignedGroupService.save(p).error == null 211 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 1 // Only taskB from above.211 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1 // Only taskB from above. 212 212 taskA.approved = true 213 213 taskA.save(flush:true) 214 assert taskSearchService.getPersonsTasks( [:], Person.get(2)).totalCount == 2 // taskA and taskB.214 assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 2 // taskA and taskB. 215 215 216 216 } // testGetTasks() 217 217 218 void testGetBudgetTasks() { 219 220 def tasks 221 def params = [:] 222 def today = dateUtilService.today 223 def yesterday = dateUtilService.yesterday 224 def tomorrow = dateUtilService.tomorrow 225 def unplanned = TaskBudgetStatus.read(1) 226 def planned = TaskBudgetStatus.read(2) 227 228 assert planned != null 229 assert unplanned != null 230 231 // Default is to return planned. 232 // TaskA and taskB should be unplanned and therefore not returned. 233 tasks = taskSearchService.getBudgetTasks(params) 234 assert tasks.totalCount == 0 235 tasks = taskSearchService.getBudgetTasks(params, planned) 236 assert tasks.totalCount == 0 237 238 tasks = taskSearchService.getBudgetTasks(params, unplanned) 239 assert tasks.totalCount == taskCount 240 assert tasks.contains(taskA) 241 assert tasks.contains(taskB) 242 243 // Planned tasks are returned. 244 taskA.taskBudgetStatus = planned 245 taskA.save(flush:true) 246 tasks = taskSearchService.getBudgetTasks(params, planned) 247 assert tasks.totalCount == 1 248 assert tasks.contains(taskA) 249 250 // Tasks are returned when dates and budget status are specified. 251 tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow) 252 assert tasks.totalCount == 1 253 assert tasks.contains(taskA) 254 tasks = taskSearchService.getBudgetTasks(params, unplanned, today, tomorrow) 255 assert tasks.totalCount == 1 256 assert tasks.contains(taskB) 257 258 // No tasks for yesterday 259 tasks = taskSearchService.getBudgetTasks(params, null, yesterday, today) 260 assert tasks.totalCount == 0 261 262 // Tasks that span today are returned. 263 taskA.targetStartDate = yesterday 264 taskA.targetCompletionDate = tomorrow+2 265 taskA.save(flush:true) 266 tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow) 267 assert tasks.totalCount == 1 268 assert tasks.contains(taskA) 269 270 } // testGetBudgetTasks() 271 218 272 } // end class
Note: See TracChangeset
for help on using the changeset viewer.