use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class CountryEnvParam_logDAO method delete.
@Override
public Answer delete(CountryEnvParam_log countryEnvParamLog) {
MessageEvent msg = null;
final String query = "DELETE FROM countryenvparam_log WHERE id = ? ";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setLong(1, countryEnvParamLog.getId());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
} 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()));
} finally {
preStat.close();
}
} 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()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.error("Unable to close connection : " + exception.toString());
}
}
return new Answer(msg);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class CountryEnvParam_logDAO method update.
@Override
public Answer update(CountryEnvParam_log countryEnvPramaLog) {
MessageEvent msg = null;
final String query = "UPDATE countryenvparam_log SET system = ?, Country = ?, Environment = ?, Build = ?, Revision = ?, " + "Chain = ?, Description = ?, Creator = ? WHERE id = ? ";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, countryEnvPramaLog.getSystem());
preStat.setString(2, countryEnvPramaLog.getCountry());
preStat.setString(3, countryEnvPramaLog.getEnvironment());
preStat.setString(4, countryEnvPramaLog.getBuild());
preStat.setString(5, countryEnvPramaLog.getRevision());
preStat.setInt(6, countryEnvPramaLog.getChain());
preStat.setString(7, countryEnvPramaLog.getDescription());
preStat.setString(8, countryEnvPramaLog.getCreator());
preStat.setLong(9, countryEnvPramaLog.getId());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
} 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()));
} finally {
preStat.close();
}
} 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()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.error("Unable to close connection : " + exception.toString());
}
}
return new Answer(msg);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class CountryEnvironmentDatabaseDAO method delete.
@Override
public Answer delete(CountryEnvironmentDatabase object) {
MessageEvent msg = null;
final String query = "DELETE FROM `countryenvironmentdatabase` WHERE `system`=? and `country`=? and `environment`=? and `database`=?";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, object.getSystem());
preStat.setString(2, object.getCountry());
preStat.setString(3, object.getEnvironment());
preStat.setString(4, object.getDatabase());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
} 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()));
} finally {
preStat.close();
}
} 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()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to close connection : " + exception.toString());
}
}
return new Answer(msg);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class CountryEnvironmentParametersDAO method update.
@Override
public Answer update(CountryEnvironmentParameters object) {
MessageEvent msg = null;
final String query = "UPDATE `countryenvironmentparameters` SET `IP`=?, `URL`=?, `URLLOGIN`=?, `domain`=?, Var1=?, Var2=?, Var3=?, Var4=?, poolSize=? where `system`=? and `country`=? and `environment`=? and `application`=? ";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, object.getIp());
preStat.setString(2, object.getUrl());
preStat.setString(3, object.getUrlLogin());
preStat.setString(4, object.getDomain());
preStat.setString(5, object.getVar1());
preStat.setString(6, object.getVar2());
preStat.setString(7, object.getVar3());
preStat.setString(8, object.getVar4());
preStat.setInt(9, object.getPoolSize());
preStat.setString(10, object.getSystem());
preStat.setString(11, object.getCountry());
preStat.setString(12, object.getEnvironment());
preStat.setString(13, object.getApplication());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
} 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()));
} finally {
preStat.close();
}
} 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()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to close connection : " + exception.toString());
}
}
return new Answer(msg);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class CountryEnvironmentParametersDAO method delete.
@Override
public Answer delete(CountryEnvironmentParameters object) {
MessageEvent msg = null;
final String query = "DELETE FROM `countryenvironmentparameters` WHERE `system`=? and `country`=? and `environment`=? and `application`=? ";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, object.getSystem());
preStat.setString(2, object.getCountry());
preStat.setString(3, object.getEnvironment());
preStat.setString(4, object.getApplication());
preStat.executeUpdate();
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
} 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()));
} finally {
preStat.close();
}
} 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()));
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to close connection : " + exception.toString());
}
}
return new Answer(msg);
}
Aggregations