use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class CampaignParameterDAO method findCampaignParameterByKey.
@Override
public CampaignParameter findCampaignParameterByKey(Integer campaignparameterID) throws CerberusException {
boolean throwEx = false;
final String query = "SELECT * FROM campaignparameter c WHERE c.campaignparameterID = ?";
CampaignParameter campaignParameterResult = null;
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
preStat.setInt(1, campaignparameterID);
try (ResultSet resultSet = preStat.executeQuery()) {
if (resultSet.first()) {
campaignParameterResult = this.loadFromResultSet(resultSet);
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
}
if (throwEx) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return campaignParameterResult;
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class CountryEnvParamDAO method findCountryEnvParamByCriteria.
@Override
public List<CountryEnvParam> findCountryEnvParamByCriteria(CountryEnvParam countryEnvParam) throws CerberusException {
List<CountryEnvParam> result = new ArrayList();
boolean throwex = false;
StringBuilder query = new StringBuilder();
query.append("SELECT `system`, `country`, `environment`, `Build`, `Revision`,`chain`, `distriblist`, `eMailBodyRevision`, `type`,`eMailBodyChain`, `eMailBodyDisableEnvironment`, `active`, `maintenanceact`, ");
query.append(" `maintenancestr`, `maintenanceend`, `Description` FROM countryenvparam WHERE `system` LIKE ? AND `country` LIKE ? ");
query.append("AND `environment` LIKE ? AND `build` LIKE ? AND `Revision` LIKE ? AND `chain` LIKE ? ");
query.append("AND `distriblist` LIKE ? AND `eMailBodyRevision` LIKE ? AND `type` LIKE ? AND `eMailBodyChain` LIKE ? ");
query.append("AND `eMailBodyDisableEnvironment` LIKE ? AND `active` LIKE ? AND `maintenanceact` LIKE ? AND `maintenancestr` LIKE ? ");
query.append("AND `maintenanceend` LIKE ? ");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getSystem()));
preStat.setString(2, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getCountry()));
preStat.setString(3, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getEnvironment()));
preStat.setString(4, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getBuild()));
preStat.setString(5, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getRevision()));
preStat.setString(6, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getChain()));
preStat.setString(7, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getDistribList()));
preStat.setString(8, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.geteMailBodyRevision()));
preStat.setString(9, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getType()));
preStat.setString(10, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.geteMailBodyChain()));
preStat.setString(11, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.geteMailBodyDisableEnvironment()));
if (countryEnvParam.isActive()) {
preStat.setString(12, "Y");
} else {
preStat.setString(12, "%");
}
if (countryEnvParam.isMaintenanceAct()) {
preStat.setString(13, "Y");
} else {
preStat.setString(13, "%");
}
preStat.setString(14, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getMaintenanceStr()));
preStat.setString(15, ParameterParserUtil.wildcardIfEmpty(countryEnvParam.getMaintenanceEnd()));
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
result.add(this.loadFromResultSet(resultSet));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwex) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return result;
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseCountryDAO method findTestCaseCountryByKey.
@Override
public TestCaseCountry findTestCaseCountryByKey(String test, String testCase, String country) throws CerberusException {
final String query = "SELECT * FROM testcasecountry tcc WHERE test = ? AND testcase = ? AND country = ? ";
TestCaseCountry result = null;
boolean throwException = false;
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, test);
preStat.setString(2, testCase);
preStat.setString(3, country);
ResultSet resultSet = preStat.executeQuery();
try {
if (resultSet.first()) {
result = factoryTestCaseCountry.create(test, testCase, country);
} else {
throwException = true;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwException) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return result;
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseCountryDAO method insertTestCaseCountry.
@Override
public void insertTestCaseCountry(TestCaseCountry testCaseCountry) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO testcasecountry (`test`, `testCase`, `country`) ");
query.append("VALUES (?,?,?)");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, testCaseCountry.getTest());
preStat.setString(2, testCaseCountry.getTestCase());
preStat.setString(3, testCaseCountry.getCountry());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseCountryPropertiesDAO method insertTestCaseCountryProperties.
@Override
public void insertTestCaseCountryProperties(TestCaseCountryProperties testCaseCountryProperties) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO testcasecountryproperties (`Test`,`TestCase`,`Country`,`Property` ,`Description`,`Type`");
query.append(",`Database`,`Value1`,`Value2`,`Length`,`RowLimit`,`Nature`,`RetryNb`,`RetryPeriod`) ");
query.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, testCaseCountryProperties.getTest());
preStat.setString(2, testCaseCountryProperties.getTestCase());
preStat.setString(3, testCaseCountryProperties.getCountry());
preStat.setBytes(4, testCaseCountryProperties.getProperty().getBytes("UTF-8"));
preStat.setBytes(5, testCaseCountryProperties.getDescription().getBytes("UTF-8"));
preStat.setString(6, testCaseCountryProperties.getType());
preStat.setString(7, testCaseCountryProperties.getDatabase());
preStat.setBytes(8, testCaseCountryProperties.getValue1().getBytes("UTF-8"));
preStat.setBytes(9, testCaseCountryProperties.getValue2().getBytes("UTF-8"));
preStat.setString(10, testCaseCountryProperties.getLength());
preStat.setInt(11, testCaseCountryProperties.getRowLimit());
preStat.setString(12, testCaseCountryProperties.getNature());
preStat.setInt(13, testCaseCountryProperties.getRetryNb());
preStat.setInt(14, testCaseCountryProperties.getRetryPeriod());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} catch (UnsupportedEncodingException ex) {
LOG.error(ex.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
Aggregations