use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TagService method createAuto.
@Override
public Answer createAuto(String tagS, String campaign, String user) {
AnswerItem answerTag;
answerTag = readByKey(tagS);
Tag tag = (Tag) answerTag.getItem();
if (tag == null) {
Answer ans = tagDAO.create(factoryTag.create(0, tagS, "", campaign, null, user, null, user, null));
if (!StringUtil.isNullOrEmpty(campaign)) {
emailService.generateAndSendNotifyStartTagExecution(tagS, campaign);
}
return ans;
// If campaign is not empty, we could notify the Start of campaign execution.
} else {
if ((StringUtil.isNullOrEmpty(tag.getCampaign())) && !StringUtil.isNullOrEmpty(campaign)) {
tag.setCampaign(campaign);
return tagDAO.update(tag.getTag(), tag);
}
return null;
}
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class AppServiceContentService method compareListAndUpdateInsertDeleteElements.
@Override
public Answer compareListAndUpdateInsertDeleteElements(String service, List<AppServiceContent> newList) {
Answer ans = new Answer(null);
MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
Answer finalAnswer = new Answer(msg1);
List<AppServiceContent> oldList = new ArrayList();
try {
oldList = this.convert(this.readByVarious(service, null));
} catch (CerberusException ex) {
LOG.error(ex);
}
/**
* Update and Create all objects database Objects from newList
*/
List<AppServiceContent> listToUpdateOrInsert = new ArrayList(newList);
listToUpdateOrInsert.removeAll(oldList);
List<AppServiceContent> listToUpdateOrInsertToIterate = new ArrayList(listToUpdateOrInsert);
for (AppServiceContent objectDifference : listToUpdateOrInsertToIterate) {
for (AppServiceContent objectInDatabase : oldList) {
if (objectDifference.hasSameKey(objectInDatabase)) {
ans = this.update(objectDifference.getService(), objectDifference.getKey(), objectDifference);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
listToUpdateOrInsert.remove(objectDifference);
}
}
}
/**
* Delete all objects database Objects that do not exist from newList
*/
List<AppServiceContent> listToDelete = new ArrayList(oldList);
listToDelete.removeAll(newList);
List<AppServiceContent> listToDeleteToIterate = new ArrayList(listToDelete);
for (AppServiceContent tcsDifference : listToDeleteToIterate) {
for (AppServiceContent tcsInPage : newList) {
if (tcsDifference.hasSameKey(tcsInPage)) {
listToDelete.remove(tcsDifference);
}
}
}
if (!listToDelete.isEmpty()) {
ans = this.deleteList(listToDelete);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
// We insert only at the end (after deletion of all potencial enreg - linked with #1281)
if (!listToUpdateOrInsert.isEmpty()) {
ans = this.createList(listToUpdateOrInsert);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
return finalAnswer;
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class BuildRevisionParametersService method create.
@Override
public Answer create(BuildRevisionParameters brp) {
Answer ans = new Answer();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
ans.setResultMessage(msg);
/**
* Checking if the build Revision has already been deployed. If so the
* Create cannot be performed
*/
if (check_buildRevisionAlreadyUsed(brp.getApplication(), brp.getBuild(), brp.getRevision())) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "Create").replace("%REASON%", "Could not create this release as corresponding build " + brp.getBuild() + " revision " + brp.getRevision() + " has already been deployed in an environment."));
ans.setResultMessage(msg);
return ans;
}
return buildRevisionParametersDAO.create(brp);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class BuildRevisionParametersService method delete.
@Override
public Answer delete(BuildRevisionParameters brp) {
Answer ans = new Answer();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
ans.setResultMessage(msg);
/**
* Checking if the build Revision has already been deployed. If so the
* delete cannot be performed
*/
if (check_buildRevisionAlreadyUsed(brp.getApplication(), brp.getBuild(), brp.getRevision())) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "Delete").replace("%REASON%", "Could not delete this release as corresponding build " + brp.getBuild() + " revision " + brp.getRevision() + " has already been deployed in an environment."));
ans.setResultMessage(msg);
return ans;
}
return buildRevisionParametersDAO.delete(brp);
}
use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.
the class TestCaseCountryPropertiesService method duplicateList.
@Override
public Answer duplicateList(List<TestCaseCountryProperties> objectList, String targetTest, String targetTestCase) {
Answer ans = new Answer(null);
List<TestCaseCountryProperties> listToCreate = new ArrayList();
for (TestCaseCountryProperties objectToDuplicate : objectList) {
objectToDuplicate.setTest(targetTest);
objectToDuplicate.setTestCase(targetTestCase);
listToCreate.add(objectToDuplicate);
}
ans = createList(listToCreate);
return ans;
}
Aggregations