use of org.cerberus.crud.entity.TestCaseExecutionwwwDet in project cerberus-source by cerberustesting.
the class TestCaseExecutionwwwDetDAO method getListOfDetail.
@Override
public List<TestCaseExecutionwwwDet> getListOfDetail(int execId) {
List<TestCaseExecutionwwwDet> list = null;
final String query = "SELECT * FROM testcaseexecutionwwwdet WHERE execID = ?";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, String.valueOf(execId));
ResultSet resultSet = preStat.executeQuery();
try {
list = new ArrayList<TestCaseExecutionwwwDet>();
while (resultSet.next()) {
TestCaseExecutionwwwDet detail = new TestCaseExecutionwwwDet();
detail.setId(resultSet.getString("ID") == null ? 0 : resultSet.getInt("ID"));
detail.setExecID(resultSet.getString("EXECID") == null ? 0 : resultSet.getInt("EXECID"));
detail.setStart(resultSet.getString("START") == null ? "" : resultSet.getString("START"));
detail.setUrl(resultSet.getString("URL") == null ? "" : resultSet.getString("URL"));
detail.setEnd(resultSet.getString("END") == null ? "" : resultSet.getString("END"));
detail.setExt(resultSet.getString("EXT") == null ? "" : resultSet.getString("EXT"));
detail.setStatusCode(resultSet.getInt("StatusCode") == 0 ? 0 : resultSet.getInt("StatusCode"));
detail.setMethod(resultSet.getString("Method") == null ? "" : resultSet.getString("Method"));
detail.setBytes(resultSet.getString("Bytes") == null ? 0 : resultSet.getInt("Bytes"));
detail.setTimeInMillis(resultSet.getString("TimeInMillis") == null ? 0 : resultSet.getInt("TimeInMillis"));
detail.setReqHeader_Host(resultSet.getString("ReqHeader_Host") == null ? "" : resultSet.getString("ReqHeader_Host"));
detail.setResHeader_ContentType(resultSet.getString("ResHeader_ContentType") == null ? "" : resultSet.getString("ResHeader_ContentType"));
list.add(detail);
}
} catch (SQLException exception) {
LOG.warn(exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn(exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn(exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
return list;
}
use of org.cerberus.crud.entity.TestCaseExecutionwwwDet in project cerberus-source by cerberustesting.
the class TCEwwwDetail method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
String echo = httpServletRequest.getParameter("sEcho");
String sStart = httpServletRequest.getParameter("iDisplayStart");
String sAmount = httpServletRequest.getParameter("iDisplayLength");
String sCol = httpServletRequest.getParameter("iSortCol_0");
String sdir = httpServletRequest.getParameter("sSortDir_0");
String dir = "asc";
// String[] cols = {"id","execID","start","url",
// "end","ext","statusCode","method","bytes","timeInMillis","reqHeader_Host","resHeader_ContentType"};
int start = 0;
int amount = 0;
int col = 0;
if (sStart != null) {
start = Integer.parseInt(sStart);
if (start < 0)
start = 0;
}
if (sAmount != null) {
amount = Integer.parseInt(sAmount);
if (amount < 10 || amount > 100)
amount = 10;
}
if (sCol != null) {
col = Integer.parseInt(sCol);
if (col < 0 || col > 5)
col = 0;
}
if (sdir != null) {
if (!sdir.equals("asc"))
dir = "desc";
}
// String colName = cols[col];
// data that will be shown in the table
JSONArray data = new JSONArray();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ITestCaseExecutionwwwDetService tCEwwwDetService = appContext.getBean(ITestCaseExecutionwwwDetService.class);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String id = policy.sanitize(httpServletRequest.getParameter("id"));
List<TestCaseExecutionwwwDet> detailList = tCEwwwDetService.getListOfDetail(Integer.valueOf(id));
try {
JSONObject jsonResponse = new JSONObject();
for (TestCaseExecutionwwwDet detail : detailList) {
JSONArray row = new JSONArray();
row.put(detail.getId()).put(detail.getExecID()).put(detail.getStart()).put(detail.getUrl()).put(detail.getEnd()).put(detail.getExt()).put(detail.getStatusCode()).put(detail.getMethod()).put(detail.getBytes()).put(detail.getTimeInMillis()).put(detail.getReqHeader_Host()).put(detail.getResHeader_ContentType());
data.put(row);
}
jsonResponse.put("aaData", data);
jsonResponse.put("sEcho", echo);
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().print(jsonResponse.toString());
} catch (JSONException e) {
httpServletResponse.setContentType("text/html");
httpServletResponse.getWriter().print(e.getMessage());
}
}
Aggregations