Updates the TaskRepository createTaskExecution to support TaskExecution param

resolves #223

Updated to use TaskExecution when creating new executions for test.
This commit is contained in:
Glenn Renfro
2016-10-20 16:59:18 -04:00
parent 7298bdd485
commit 02a8c3368b
7 changed files with 68 additions and 55 deletions

View File

@@ -204,8 +204,13 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
this.taskNameResolver.getTaskName(), new Date(), args, taskProperties.getExternalExecutionId());
}
else {
TaskExecution taskExecution = new TaskExecution();
taskExecution.setTaskName(this.taskNameResolver.getTaskName());
taskExecution.setStartTime(new Date());
taskExecution.setArguments(args);
taskExecution.setExternalExecutionId(taskProperties.getExternalExecutionId());
this.taskExecution = this.taskRepository.createTaskExecution(
this.taskNameResolver.getTaskName(), new Date(), args, taskProperties.getExternalExecutionId());
taskExecution);
}
}
else {

View File

@@ -59,15 +59,16 @@ public interface TaskRepository {
/**
* Notifies the repository that a taskExecution needs to be created.
*
* @param taskName the name that associated with the task execution.
* @param startTime the time task began.
* @param arguments list of key/value pairs that configure the task.
* @param externalExecutionId id assigned to the task by the platform.
* @return the initial {@link TaskExecution}
* @param taskExecution a TaskExecution instance containing the startTime,
* arguments and externalExecutionId that will be stored in the repository.
* Only the values enumerated above will be stored for this
* TaskExecution.
* @return the {@link TaskExecution} that was stored in the repository. The
* TaskExecution's taskExecutionId will also contain the id that was used
* to store the TaskExecution.
*/
@Transactional
TaskExecution createTaskExecution(String taskName,
Date startTime,List<String> arguments, String externalExecutionId);
TaskExecution createTaskExecution(TaskExecution taskExecution);
/**
* Creates an empty TaskExecution with just an id provided. This is intended to be

View File

@@ -101,14 +101,17 @@ public class SimpleTaskRepository implements TaskRepository {
}
@Override
public TaskExecution createTaskExecution(String taskName,
Date startTime,List<String> arguments, String externalExecutionId) {
public TaskExecution createTaskExecution(TaskExecution taskExecution) {
initialize();
validateCreateInformation(startTime, taskName);
TaskExecution taskExecution =
taskExecutionDao.createTaskExecution(taskName, startTime, arguments, externalExecutionId);
validateCreateInformation(taskExecution);
TaskExecution daoTaskExecution =
taskExecutionDao.createTaskExecution(
taskExecution.getTaskName(),
taskExecution.getStartTime(),
taskExecution.getArguments(),
taskExecution.getExternalExecutionId());
logger.debug("Creating: " + taskExecution.toString());
return taskExecution;
return daoTaskExecution;
}
@Override
@@ -155,11 +158,11 @@ public class SimpleTaskRepository implements TaskRepository {
/**
* Validate startTime and taskName are valid.
*/
private void validateCreateInformation(Date startTime, String taskName) {
Assert.notNull(startTime, "TaskExecution start time cannot be null.");
private void validateCreateInformation(TaskExecution taskExecution) {
Assert.notNull(taskExecution.getStartTime(), "TaskExecution start time cannot be null.");
if (taskName != null &&
taskName.length() > this.maxTaskNameSize) {
if (taskExecution.getTaskName() != null &&
taskExecution.getTaskName().length() > this.maxTaskNameSize) {
throw new IllegalArgumentException("TaskName length exceeds "
+ this.maxTaskNameSize + " characters");
}