Search in sources :

Example 6 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TaskActivityServiceImpl method addSuccessfulExecution.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public boolean addSuccessfulExecution(Long activityId) {
    TaskActivity activity = taskActivitiesDataService.findById(activityId);
    if (activity == null) {
        return false;
    }
    TaskExecutionProgress progress = activity.getTaskExecutionProgress();
    progress.addSuccess();
    return updateTaskProgress(progress, activity);
}
Also used : TaskExecutionProgress(org.motechproject.tasks.domain.mds.task.TaskExecutionProgress) TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TaskActivityServiceImpl method addTaskFiltered.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void addTaskFiltered(Long activityId) {
    TaskActivity activity = taskActivitiesDataService.findById(activityId);
    activity.setActivityType(TaskActivityType.FILTERED);
    activity.setMessage(TASK_FILTERED);
    taskActivitiesDataService.update(activity);
}
Also used : TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TaskActivityServiceImpl method addTaskStarted.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public long addTaskStarted(Task task, Map<String, Object> parameters) {
    int totalActions = task.getActions().size();
    TaskActivity activity = taskActivitiesDataService.create(new TaskActivity(TASK_IN_PROGRESS, Arrays.asList("0", String.valueOf(totalActions)), task.getId(), task.getTrigger().getDisplayName(), TaskActivityType.IN_PROGRESS, null, parameters, new TaskExecutionProgress(totalActions)));
    return activity.getId();
}
Also used : TaskExecutionProgress(org.motechproject.tasks.domain.mds.task.TaskExecutionProgress) TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TaskTriggerHandler method retryTask.

@Override
@Transactional
public void retryTask(Long activityId) {
    TaskActivity activity = activityService.getTaskActivityById(activityId);
    handleTask(taskService.getTask(activity.getTask()), activity.getParameters());
}
Also used : TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TasksPostExecutionHandlerTest method initTaskActivity.

private void initTaskActivity() {
    taskActivity = new TaskActivity();
    taskActivity.setId(TASK_ACTIVITY_ID);
    taskActivity.setTask(task.getId());
}
Also used : TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity)

Aggregations

TaskActivity (org.motechproject.tasks.domain.mds.task.TaskActivity)16 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)6 TaskExecutionProgress (org.motechproject.tasks.domain.mds.task.TaskExecutionProgress)4 QueryParams (org.motechproject.mds.query.QueryParams)3 TaskHandlerException (org.motechproject.tasks.exception.TaskHandlerException)3 HashSet (java.util.HashSet)2 DateTime (org.joda.time.DateTime)2 TaskActivityType (org.motechproject.tasks.domain.enums.TaskActivityType)2 Order (org.motechproject.mds.util.Order)1