Iterator<Scenario> uploadedListIter = uploadedService.getScenarios().iterator();
Iterator<Scenario> inMemListIter = inMemoryService.getScenarios().iterator();
while (uploadedListIter.hasNext()) {
Scenario uploadedScenario = (Scenario) uploadedListIter.next();
boolean inMemScenarioExistTemp = false;
Scenario inMemScenarioTemp = null;
while (inMemListIter.hasNext()) {
inMemScenarioTemp = (Scenario) inMemListIter.next();
if (inMemScenarioTemp.hasSameNameAndResponse(uploadedScenario)) {
inMemScenarioExistTemp = true;
break;
}
}
if (!inMemScenarioExistTemp) {
// Hey, we have a new scenario.
// NOTE: incoming/uploaded scenario has an ID.
// We MUST nullify it, to ensure there's no common Service's
// scenario's ID
uploadedScenario.setId(null);
uploadedScenario.setServiceId(inMemoryService.getId());
// Tag for Service:Scenario
uploadedScenario.addTagToList(tagArguments);
inMemoryService.saveOrUpdateScenario(uploadedScenario);
readResults.addAdditionMsg("Scenario name '" + uploadedScenario.getScenarioName()
+ "' from uploaded service named '" + uploadedService.getServiceName()
+ "' was merged into service '" + inMemoryService.getServiceName() + "' ");
} else {
// OK, we have a MATCHING Scenario.
// Be sure to add the uploaded-file tags
inMemScenarioTemp.addTagToList(tagArguments);
// Be sure to add the uploaded-scenario tags
inMemScenarioTemp.addTagToList(uploadedScenario.getTag());
// Save the scenario to the Service
inMemoryService.saveOrUpdateScenario(inMemScenarioTemp);
// Although we still need to
readResults.addConflictMsg("Uploaded Scenario '" + uploadedScenario.getScenarioName()