use of org.cerberus.util.answer.AnswerList in project cerberus-source by cerberustesting.
the class UserSystemDAO method readByUser.
@Override
public AnswerList<UserSystem> readByUser(String login) {
AnswerList ans = new AnswerList();
MessageEvent msg = null;
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(Query.READ_BY_USER)) {
// Prepare and execute query
preStat.setString(1, login);
try (ResultSet resultSet = preStat.executeQuery()) {
// Parse query
List<UserSystem> result = new ArrayList<>();
while (resultSet.next()) {
result.add(loadUserSystemFromResultSet(resultSet));
}
ans.setDataList(result);
// Set the final message
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("ITEM", OBJECT_NAME).resolveDescription("OPERATION", "GET");
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
}
} catch (Exception e) {
LOG.warn("Unable to read userSystem: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
ans.setResultMessage(msg);
}
return ans;
}
use of org.cerberus.util.answer.AnswerList in project cerberus-source by cerberustesting.
the class InvariantService method readToHashMapGp1IntegerByIdname.
@Override
public HashMap<String, Integer> readToHashMapGp1IntegerByIdname(String idName, Integer defaultValue) {
HashMap<String, Integer> result = new HashMap<String, Integer>();
// TODO: handle if the response does not turn ok
AnswerList answer = readByIdname(idName);
for (Invariant inv : (List<Invariant>) answer.getDataList()) {
int gp1ToInt = ParameterParserUtil.parseIntegerParam(inv.getGp1(), defaultValue);
result.put(inv.getValue(), gp1ToInt);
}
return result;
}
use of org.cerberus.util.answer.AnswerList in project cerberus-source by cerberustesting.
the class InvariantService method readByPrivateByCriteria.
@Override
public AnswerList readByPrivateByCriteria(int start, int amount, String column, String dir, String searchTerm, String individualSearch) {
// We first get the list of all Private invariant from the invariant table.
String searchSQL = this.getPublicPrivateFilter("INVARIANTPRIVATE");
// Then, we build the list of invariant entry based on the filter.
// TODO this method should return a AnswerList, after complete refactoring this method should be changed
AnswerList answer = invariantDao.readByCriteria(start, amount, column, dir, searchTerm, individualSearch, searchSQL);
return answer;
}
use of org.cerberus.util.answer.AnswerList in project cerberus-source by cerberustesting.
the class InvariantService method readByPublicByCriteria.
@Override
public AnswerList readByPublicByCriteria(int start, int amount, String column, String dir, String searchTerm, Map<String, List<String>> individualSearch) {
// We first get the list of all Public invariant from the invariant table.
String searchSQL = this.getPublicPrivateFilter("INVARIANTPUBLIC");
// Then, we build the list of invariant entry based on the filter.
// TODO this method should return a AnswerList, after complete refactoring this method should be changed
AnswerList answer = invariantDao.readByCriteria(start, amount, column, dir, searchTerm, individualSearch, searchSQL);
return answer;
}
use of org.cerberus.util.answer.AnswerList in project cerberus-source by cerberustesting.
the class InvariantService method readByPublicByCriteria.
@Override
public AnswerList readByPublicByCriteria(int start, int amount, String column, String dir, String searchTerm, String individualSearch) {
// We first get the list of all Public invariant from the invariant table.
String searchSQL = this.getPublicPrivateFilter("INVARIANTPUBLIC");
// Then, we build the list of invariant entry based on the filter.
// TODO this method should return a AnswerList, after complete refactoring this method should be changed
AnswerList answer = invariantDao.readByCriteria(start, amount, column, dir, searchTerm, individualSearch, searchSQL);
return answer;
}
Aggregations