use of org.cerberus.crud.entity.ApplicationObject in project cerberus-source by cerberustesting.
the class ApplicationObjectDAO method readByApplication.
@Override
public AnswerList readByApplication(String Application) {
AnswerList ans = new AnswerList();
MessageEvent msg = null;
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(Query.READ_BY_APP)) {
// Prepare and execute query
preStat.setString(1, Application);
ResultSet rs = preStat.executeQuery();
try {
List<ApplicationObject> al = new ArrayList<ApplicationObject>();
while (rs.next()) {
al.add(loadFromResultSet(rs));
}
ans.setDataList(al);
// Set the final message
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("ITEM", OBJECT_NAME).resolveDescription("OPERATION", "READ_BY_APP");
} catch (Exception e) {
LOG.warn("Unable to execute query : " + e.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
if (rs != null) {
rs.close();
}
}
} catch (Exception e) {
LOG.warn("Unable to read by app: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
ans.setResultMessage(msg);
}
return ans;
}
Aggregations