use of org.motechproject.tasks.domain.enums.TaskActivityType in project motech by motech.
the class TaskActivityServiceImplTest method shouldReturnPaginatedActivitiesForGivenTask.
@Test
public void shouldReturnPaginatedActivitiesForGivenTask() {
Set<TaskActivityType> types = new HashSet<>();
types.addAll(Arrays.asList(TaskActivityType.values()));
Set<Long> activitiesIds = new HashSet<>();
QueryParams queryParams = new QueryParams((Order) null);
boolean lastExecution = false;
when(taskActivitiesDataService.byTaskAndActivityTypesAndIds(TASK_ID, types, activitiesIds, queryParams)).thenReturn(activities);
List<TaskActivity> actual = activityService.getTaskActivities(TASK_ID, types, queryParams, lastExecution);
assertNotNull(actual);
assertEquals(activities, actual);
}
use of org.motechproject.tasks.domain.enums.TaskActivityType in project motech by motech.
the class ActionParametersBundleIT method hasTaskExecuted.
private boolean hasTaskExecuted(Long taskID) {
Set<TaskActivityType> activityTypes = new HashSet<>();
Set<Long> activityIds = new HashSet<>();
activityTypes.add(TaskActivityType.SUCCESS);
QueryParams queryParams = new QueryParams((Order) null);
List<TaskActivity> taskActivities = taskActivitiesDataService.byTaskAndActivityTypesAndIds(taskID, activityTypes, activityIds, queryParams);
return taskActivities.size() == 1;
}
use of org.motechproject.tasks.domain.enums.TaskActivityType in project motech by motech.
the class ActivityController method getTaskActivities.
/**
* Returns the list of activities for task with the given ID.
*
* @param taskId the ID of the task
* @return the list of activities
*/
@RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET)
@ResponseBody
public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) {
if (settings != null) {
QueryParams params = getParams(settings);
Set<TaskActivityType> types = settings.getTypesFromString();
Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo());
List<TaskActivityDto> activities;
long count;
if (dateTimeRange != null) {
activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution());
count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution());
} else {
activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution());
count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution());
}
int totalPages = (int) Math.ceil((double) count / settings.getRows());
return new TaskActivityRecords(settings.getPage(), totalPages, count, activities);
} else {
return null;
}
}
use of org.motechproject.tasks.domain.enums.TaskActivityType in project motech by motech.
the class TaskActivityTypeTest method shouldFindTypeFromString.
@Test
public void shouldFindTypeFromString() {
TaskActivityType actual = TaskActivityType.fromString(ERROR.getValue());
assertNotNull(actual);
assertEquals(ERROR.getValue(), actual.getValue());
}
use of org.motechproject.tasks.domain.enums.TaskActivityType in project motech by motech.
the class ActivityController method getAllActivities.
/**
* Returns the list of all the task activities.
*
* @return the list of activities
*/
@RequestMapping(value = "/activity/all", method = RequestMethod.GET)
@ResponseBody
public TaskActivityRecords getAllActivities(GridSettings settings) {
if (settings != null) {
QueryParams params = getParams(settings);
Set<TaskActivityType> types = settings.getTypesFromString();
Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo());
List<TaskActivityDto> activities;
long count;
if (dateTimeRange != null) {
activities = taskWebService.getAllActivities(types, dateTimeRange, params, settings.isLastExecution());
count = activityService.getAllTaskActivitiesCount(types, dateTimeRange, settings.isLastExecution());
} else {
activities = taskWebService.getAllActivities(types, params, settings.isLastExecution());
count = activityService.getAllTaskActivitiesCount(types, settings.isLastExecution());
}
int totalPages = (int) Math.ceil((double) count / settings.getRows());
return new TaskActivityRecords(settings.getPage(), totalPages, count, activities);
} else {
return null;
}
}
Aggregations