use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class LabelDAO method delete.
@Override
public Answer delete(Label object) {
Answer response = new Answer();
MessageEvent msg = null;
final String query = "DELETE FROM label WHERE id = ? ";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
preStat.setInt(1, object.getId());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
} catch (Exception e) {
LOG.warn("Unable to delete label: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
response.setResultMessage(msg);
}
return response;
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class LabelDAO method update.
@Override
public Answer update(Label object) {
Answer response = new Answer();
MessageEvent msg = null;
final String query = "UPDATE label SET `system` = ?, `label` = ?, `type` = ?, `color` = ?, `parentLabel` = ?, `usrModif` = ?, `dateModif` = ?, `description` = ?" + ", `LongDesc` = ?, `ReqType` = ?, `ReqStatus` = ?, `ReqCriticity` = ? WHERE id = ?";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
int i = 1;
preStat.setString(i++, object.getSystem());
preStat.setString(i++, object.getLabel());
preStat.setString(i++, object.getType());
preStat.setString(i++, object.getColor());
preStat.setString(i++, object.getParentLabel());
preStat.setString(i++, object.getUsrModif());
preStat.setTimestamp(i++, object.getDateModif());
preStat.setString(i++, object.getDescription());
preStat.setString(i++, object.getLongDesc());
preStat.setString(i++, object.getReqType());
preStat.setString(i++, object.getReqStatus());
preStat.setString(i++, object.getReqCriticity());
preStat.setInt(i++, object.getId());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
} catch (Exception e) {
LOG.warn("Unable to update label: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
response.setResultMessage(msg);
}
return response;
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class LabelDAO method create.
@Override
public Answer create(Label object) {
Answer response = new Answer();
MessageEvent msg = null;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO label (`system`, `label`, `type`, `color`, `parentLabel`, `ReqType`, `ReqStatus`, `ReqCriticity`, `description`, `longdesc`, `usrCreated`, `dateCreated`, `usrModif`, `dateModif` ) ");
query.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
}
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString())) {
int i = 1;
preStat.setString(i++, object.getSystem());
preStat.setString(i++, object.getLabel());
preStat.setString(i++, object.getType());
preStat.setString(i++, object.getColor());
preStat.setString(i++, object.getParentLabel());
preStat.setString(i++, object.getReqType());
preStat.setString(i++, object.getReqStatus());
preStat.setString(i++, object.getReqCriticity());
preStat.setString(i++, object.getDescription());
preStat.setString(i++, object.getLongDesc());
preStat.setString(i++, object.getUsrCreated());
preStat.setTimestamp(i++, object.getDateCreated());
preStat.setString(i++, object.getUsrModif());
preStat.setTimestamp(i++, object.getDateModif());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));
} catch (Exception e) {
LOG.warn("Unable to create label: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
response.setResultMessage(msg);
}
return response;
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class ParameterDAO method create.
@Override
public Answer create(Parameter object) {
Answer ans = new Answer();
MessageEvent msg = null;
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(Query.CREATE)) {
// Prepare and execute query
preStat.setString(1, object.getSystem());
preStat.setString(2, object.getParam());
preStat.setString(3, object.getValue());
preStat.setString(4, object.getDescription());
preStat.executeUpdate();
// Set the final message
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("ITEM", OBJECT_NAME).resolveDescription("OPERATION", "CREATE");
} catch (Exception e) {
LOG.warn("Unable to create robot capability: " + 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.Answer in project cerberus-source by cerberustesting.
the class ParameterDAO method delete.
@Override
public Answer delete(Parameter object) {
Answer ans = new Answer();
MessageEvent msg = null;
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(Query.DELETE)) {
// Prepare and execute query
preStat.setString(1, object.getSystem());
preStat.setString(2, object.getParam());
preStat.executeUpdate();
// Set the final message
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).resolveDescription("ITEM", OBJECT_NAME).resolveDescription("OPERATION", "DELETE");
} catch (Exception e) {
LOG.warn("Unable to delete parameter: " + e.getMessage());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED).resolveDescription("DESCRIPTION", e.toString());
} finally {
ans.setResultMessage(msg);
}
return ans;
}
Aggregations