Search in sources :

Example 1 with CheckpointSummary

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;
}
Also used : CallableStatement(java.sql.CallableStatement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DbConnection(com.axway.ats.core.dbaccess.DbConnection) ResultSet(java.sql.ResultSet) Checkpoint(com.axway.ats.log.autodb.entities.Checkpoint) SQLException(java.sql.SQLException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) CheckpointSummary(com.axway.ats.log.autodb.entities.CheckpointSummary)

Aggregations

DbConnection (com.axway.ats.core.dbaccess.DbConnection)1 Checkpoint (com.axway.ats.log.autodb.entities.Checkpoint)1 CheckpointSummary (com.axway.ats.log.autodb.entities.CheckpointSummary)1 DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)1 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1