use of org.asqatasun.entity.scenario.Scenario in project Asqatasun by Asqatasun.
the class AuditScenarioController method saveScenario.
/**
* Persist a scenario
*
* @param addScenarioCommand
* @param contract
*/
private void saveScenario(AddScenarioCommand addScenarioCommand, Contract contract) {
Scenario scenario = scenarioDataService.create();
scenario.setLabel(addScenarioCommand.getScenarioLabel());
scenario.setContent(addScenarioCommand.getScenarioContent());
scenario.setContract(contract);
scenario.setDateOfCreation(Calendar.getInstance().getTime());
scenarioDataService.saveOrUpdate(scenario);
}
use of org.asqatasun.entity.scenario.Scenario in project Asqatasun by Asqatasun.
the class AuditScenarioController method deleteScenarioFile.
@RequestMapping(value = TgolKeyStore.DELETE_SCENARIO_URL_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String deleteScenarioFile(@RequestParam(TgolKeyStore.CONTRACT_ID_KEY) String contractId, @RequestParam(TgolKeyStore.SCENARIO_ID_KEY) String scenarioId, HttpServletRequest request, HttpServletResponse response, Model model) {
Contract contract = contractDataService.read(Long.valueOf(contractId));
if (contract.getUser().getId().equals(getCurrentUser().getId())) {
for (Scenario scenario : contract.getScenarioSet()) {
if (scenario.getId().equals(Long.valueOf(scenarioId))) {
deleteScenario(scenario, contract);
model.addAttribute(TgolKeyStore.DELETED_SCENARIO_NAME_KEY, scenario.getLabel());
prepareScenarioManagementData(model, contractId);
return TgolKeyStore.SCENARIO_MANAGEMENT_VIEW_NAME;
}
}
}
throw new ForbiddenPageException(getCurrentUser());
}
Aggregations