Refactored the use of the name parameters to be arguments

This PR refactors the use of the term parameters to arguments to be
consistent with how the component is utilized within Spring Cloud Data
Flow.
This commit is contained in:
Michael Minella
2016-06-08 13:04:58 -05:00
parent 7f53c7d9f7
commit 77fdfbdbc0
19 changed files with 101 additions and 102 deletions

View File

@@ -231,7 +231,7 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
return new TaskExecution(taskExecution.getExecutionId(),
taskExecution.getExitCode(), taskExecution.getTaskName(), startTime,
endTime,taskExecution.getExitMessage(),
Collections.unmodifiableList(taskExecution.getParameters()));
Collections.unmodifiableList(taskExecution.getArguments()));
}
@Override

View File

@@ -55,30 +55,30 @@ public class TaskExecution {
private Date endTime;
/**
* Message returned from the task or stacktrace.parameters.
* Message returned from the task or stacktrace.
*/
private String exitMessage;
/**
* The parameters that were used for this task execution.
* The arguments that were used for this task execution.
*/
private List<String> parameters;
private List<String> arguments;
public TaskExecution() {
parameters = new ArrayList<>();
arguments = new ArrayList<>();
}
public TaskExecution(long executionId, Integer exitCode, String taskName,
Date startTime, Date endTime,
String exitMessage, List<String> parameters) {
String exitMessage, List<String> arguments) {
Assert.notNull(parameters, "parameters must not be null");
Assert.notNull(arguments, "arguments must not be null");
Assert.notNull(startTime, "startTime must not be null");
this.executionId = executionId;
this.exitCode = exitCode;
this.taskName = taskName;
this.exitMessage = exitMessage;
this.parameters = new ArrayList<>(parameters);
this.arguments = new ArrayList<>(arguments);
this.startTime = (Date)startTime.clone();
this.endTime = (endTime != null) ? (Date)endTime.clone() : null;
}
@@ -127,12 +127,12 @@ public class TaskExecution {
this.exitMessage = exitMessage;
}
public List<String> getParameters() {
return parameters;
public List<String> getArguments() {
return arguments;
}
public void setParameters(List<String> parameters) {
this.parameters = new ArrayList<> (parameters);
public void setArguments(List<String> arguments) {
this.arguments = new ArrayList<> (arguments);
}
@Override
@@ -144,7 +144,7 @@ public class TaskExecution {
", startTime=" + startTime +
", endTime=" + endTime +
", exitMessage='" + exitMessage + '\'' +
", parameters=" + parameters +
", arguments=" + arguments +
'}';
}
}

View File

@@ -47,11 +47,11 @@ public interface TaskRepository {
*
* @param taskName the name that associated with the task execution.
* @param startTime the time task began.
* @param parameters list of key/value pairs that configure the task.
* @param arguments list of key/value pairs that configure the task.
* @return the initial {@link TaskExecution}
*/
@Transactional
TaskExecution createTaskExecution(String taskName,
Date startTime,List<String> parameters);
Date startTime,List<String> arguments);
}

View File

@@ -71,7 +71,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
+ "(TASK_EXECUTION_ID, START_TIME, TASK_NAME, LAST_UPDATED)"
+ "values (?, ?, ?, ?)";
private static final String CREATE_TASK_PARAMETER = "INSERT into "
private static final String CREATE_TASK_ARGUMENT = "INSERT into "
+ "%PREFIX%EXECUTION_PARAMS(TASK_EXECUTION_ID, TASK_PARAM ) values (?, ?)";
private static final String CHECK_TASK_EXECUTION_EXISTS = "SELECT COUNT(*) FROM "
@@ -86,7 +86,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
+ "EXIT_MESSAGE, LAST_UPDATED "
+ "from %PREFIX%EXECUTION where TASK_EXECUTION_ID = ?";
private static final String FIND_PARAMS_FROM_ID = "SELECT TASK_EXECUTION_ID, "
private static final String FIND_ARGUMENT_FROM_ID = "SELECT TASK_EXECUTION_ID, "
+ "TASK_PARAM from %PREFIX%EXECUTION_PARAMS where TASK_EXECUTION_ID = ?";
private static final String TASK_EXECUTION_COUNT = "SELECT COUNT(*) FROM " +
@@ -126,17 +126,17 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
@Override
public TaskExecution createTaskExecution(String taskName,
Date startTime, List<String> parameters) {
Date startTime, List<String> arguments) {
long taskExecutionId = getNextExecutionId();
TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName,
startTime, null, null, parameters);
startTime, null, null, arguments);
Object[] queryParameters = new Object[]{ taskExecutionId, startTime, taskName, new Date()};
jdbcTemplate.update(
getQuery(SAVE_TASK_EXECUTION),
queryParameters,
new int[]{ Types.BIGINT, Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP });
insertTaskParameters(taskExecutionId, parameters);
insertTaskArguments(taskExecutionId, arguments);
return taskExecution;
}
@@ -175,7 +175,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
try {
TaskExecution taskExecution = jdbcTemplate.queryForObject(getQuery(GET_EXECUTION_BY_ID),
new TaskExecutionRowMapper(), executionId);
taskExecution.setParameters(getTaskParameters(executionId));
taskExecution.setArguments(getTaskArguments(executionId));
return taskExecution;
}
catch (EmptyResultDataAccessException e) {
@@ -321,15 +321,15 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
}
/**
* Convenience method that inserts all parameters from the provided
* task parameters.
* Convenience method that inserts all arguments from the provided
* task arguments.
*
* @param executionId The executionId to which the params are associated.
* @param taskParameters The parameters to be stored.
* @param executionId The executionId to which the arguments are associated.
* @param taskArguments The arguments to be stored.
*/
private void insertTaskParameters(long executionId, List<String> taskParameters) {
for (String param : taskParameters) {
insertParameter(executionId, param);
private void insertTaskArguments(long executionId, List<String> taskArguments) {
for (String args : taskArguments) {
insertArgument(executionId, args);
}
}
@@ -337,13 +337,13 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
* Convenience method that inserts an individual records into the
* TASK_EXECUTION_PARAMS table.
*/
private void insertParameter(long executionId, String param) {
private void insertArgument(long executionId, String param) {
int[] argTypes = new int[]{ Types.BIGINT, Types.VARCHAR };
Object[] args = new Object[]{ executionId, param };
jdbcTemplate.update(getQuery(CREATE_TASK_PARAMETER), args, argTypes);
jdbcTemplate.update(getQuery(CREATE_TASK_ARGUMENT), args, argTypes);
}
private List<String> getTaskParameters(long executionId){
private List<String> getTaskArguments(long executionId){
final List<String> params= new ArrayList<>();
RowCallbackHandler handler = new RowCallbackHandler() {
@Override
@@ -352,7 +352,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
}
};
jdbcTemplate.query(getQuery(FIND_PARAMS_FROM_ID), new Object[] { executionId },
jdbcTemplate.query(getQuery(FIND_ARGUMENT_FROM_ID), new Object[] { executionId },
handler);
return params;
}
@@ -374,7 +374,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
rs.getTimestamp("START_TIME"),
rs.getTimestamp("END_TIME"),
rs.getString("EXIT_MESSAGE"),
getTaskParameters(id));
getTaskArguments(id));
}
private Integer getNullableExitCode(ResultSet rs) throws SQLException {

View File

@@ -53,10 +53,10 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
@Override
public TaskExecution createTaskExecution(String taskName,
Date startTime, List<String> parameters) {
Date startTime, List<String> arguments) {
long taskExecutionId = getNextExecutionId();
TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName,
startTime, null, null, parameters);
startTime, null, null, arguments);
taskExecutions.put(taskExecutionId, taskExecution);
return taskExecution;
}

View File

@@ -36,11 +36,11 @@ public interface TaskExecutionDao {
*
* @param taskName the name that associated with the task execution.
* @param startTime the time task began.
* @param parameters list of key/value pairs that configure the task.
* @param arguments list of key/value pairs that configure the task.
* @return A fully qualified {@link TaskExecution} instance.
*/
TaskExecution createTaskExecution( String taskName,
Date startTime, List<String> parameters);
Date startTime, List<String> arguments);
/**
* Update and existing {@link TaskExecution}.

View File

@@ -71,11 +71,11 @@ public class SimpleTaskRepository implements TaskRepository {
@Override
public TaskExecution createTaskExecution(String taskName,
Date startTime,List<String> parameters) {
Date startTime,List<String> arguments) {
initialize();
validateCreateInformation(startTime, taskName);
TaskExecution taskExecution =
taskExecutionDao.createTaskExecution(taskName, startTime, parameters);
taskExecutionDao.createTaskExecution(taskName, startTime, arguments);
logger.debug("Creating: " + taskExecution.toString());
return taskExecution;
}