use of com.axway.ats.log.autodb.entities.CheckpointSummary in project ats-framework by Axway.
the class DbReadAccess method getCheckpointsSummary.
public List<CheckpointSummary> getCheckpointsSummary(String whereClause, String sortColumn, boolean ascending) throws DatabaseAccessException {
List<CheckpointSummary> checkpoints = new ArrayList<CheckpointSummary>();
String sqlLog = new SqlRequestFormatter().add("where", whereClause).add("sort by", sortColumn).add("asc", ascending).format();
Connection connection = getConnection();
CallableStatement callableStatement = null;
ResultSet rs = null;
try {
callableStatement = connection.prepareCall("{ call sp_get_checkpoints_summary(?, ?, ?) }");
callableStatement.setString(1, "where " + whereClause);
callableStatement.setString(2, sortColumn);
callableStatement.setString(3, (ascending ? "ASC" : "DESC"));
rs = callableStatement.executeQuery();
int numberRecords = 0;
while (rs.next()) {
CheckpointSummary checkpointSummary = new CheckpointSummary();
checkpointSummary.checkpointSummaryId = rs.getInt("checkpointSummaryId");
checkpointSummary.name = rs.getString("name");
checkpointSummary.numRunning = rs.getInt("numRunning");
checkpointSummary.numPassed = rs.getInt("numPassed");
checkpointSummary.numFailed = rs.getInt("numFailed");
checkpointSummary.numTotal = checkpointSummary.numRunning + checkpointSummary.numPassed + checkpointSummary.numFailed;
checkpointSummary.minResponseTime = rs.getInt("minResponseTime");
if (checkpointSummary.minResponseTime == Integer.MAX_VALUE) {
checkpointSummary.minResponseTime = 0;
}
checkpointSummary.avgResponseTime = rs.getFloat("avgResponseTime");
checkpointSummary.maxResponseTime = rs.getInt("maxResponseTime");
checkpointSummary.minTransferRate = rs.getFloat("minTransferRate");
if (checkpointSummary.minTransferRate == Integer.MAX_VALUE) {
checkpointSummary.minTransferRate = 0.0F;
}
checkpointSummary.avgTransferRate = rs.getFloat("avgTransferRate");
checkpointSummary.maxTransferRate = rs.getFloat("maxTransferRate");
checkpointSummary.transferRateUnit = rs.getString("transferRateUnit");
checkpoints.add(checkpointSummary);
numberRecords++;
}
logQuerySuccess(sqlLog, "checkpoints summary", numberRecords);
} catch (Exception e) {
throw new DatabaseAccessException("Error when " + sqlLog, e);
} finally {
DbUtils.closeResultSet(rs);
DbUtils.close(connection, callableStatement);
}
return checkpoints;
}
Aggregations