pstmt.setInt(index, limit);
}
rset = pstmt.executeQuery();
Command command = null;
Calendar calendar = null;
Timestamp timestamp = null;
if (rset != null) {
query = new StringBuffer(" IN (");
while (rset.next()) {
command = new Command(rset.getString(NAME_FIELD), rset.getString(CATEGORY_FIELD));
command.setId(rset.getLong(ID_FIELD));
command.setUserId(rset.getString(USER_ID_FIELD));
command.setDescription(rset.getString(DESCRIPTION_FIELD));
command.setFailureReason(rset.getString(FAILURE_REASON_FIELD));
command.setCommandGroupId(rset.getString(COMMAND_GROUP_ID_FIELD));
command.setAsynchronous(true);
command.setPriorityLevel(rset.getInt(PRIORITY_LEVEL_FIELD));
command.setExecutionMode(ExecutionModeValues.PARALLEL.equals(rset.getString(EXECUTION_MODE_FIELD)) ? ExecutionModeValues.PARALLEL: ExecutionModeValues.SERIAL);
calendar = null;
timestamp = rset.getTimestamp(CREATION_TIME_FIELD);
if (timestamp != null) {
calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp.getTime());
command.setCreationTime(calendar);
}
commandList.put(""+command.getId(), command);
query.append("'").append(command.getId()).append("',");
}
query.replace(query.length() - 1, query.length(), ")");
if (commandList.size() > 0) {
StringBuffer setScheduledQuery = new StringBuffer("update ");
setScheduledQuery.append(QUEUE_TABLE).append(" set ").append(IS_SCHEDULED_FIELD);
setScheduledQuery.append(" = true where ").append(ID_FIELD).append(query);
pstmt = connection.prepareStatement(setScheduledQuery.toString());
pstmt.executeUpdate();
StringBuffer selectParameterQuery = new StringBuffer("select ");
selectParameterQuery.append(PARAMETER_TABLE).append(".").append(ID_FIELD).append(" as PARAMETER_ID, ");
selectParameterQuery.append(PARAMETER_TABLE).append(".").append(COMMAND_ID_FIELD).append(" as ").append(COMMAND_ID_FIELD).append(", ");
selectParameterQuery.append(PARAMETER_TABLE).append(".").append(NAME_FIELD).append(" as PARAMETER_NAME, ");
selectParameterQuery.append(PARAMETER_TABLE).append(".").append(VALUE_FIELD).append(" as PARAMETER_VALUE from ");
selectParameterQuery.append(PARAMETER_TABLE).append(" where ").append(COMMAND_ID_FIELD).append(query);
pstmt = connection.prepareStatement(selectParameterQuery.toString());
rset = pstmt.executeQuery();
if (rset != null) {
long commandId = -1;
while (rset.next()) {
commandId = rset.getLong(COMMAND_ID_FIELD);
command = commandList.get(""+commandId);
if (commandId > 0) {
parameterName = rset.getString("PARAMETER_NAME");
parameterValue = rset.getString("PARAMETER_VALUE");
if (command.containsParameterKey(parameterName)) {
List<String> valueList = command.getParameterMultivalue(parameterName);
valueList.add(parameterValue);
command.addParameter(parameterName, valueList);
} else {
command.addParameter(parameterName, parameterValue);
}
}
}
}
}