Search in sources :

Example 6 with Scenario

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);
}
Also used : Scenario(org.asqatasun.entity.scenario.Scenario)

Example 7 with 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());
}
Also used : Contract(org.asqatasun.entity.contract.Contract) Scenario(org.asqatasun.entity.scenario.Scenario) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Scenario (org.asqatasun.entity.scenario.Scenario)7 Contract (org.asqatasun.entity.contract.Contract)3 Secured (org.springframework.security.access.annotation.Secured)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Parameter (org.asqatasun.entity.parameterization.Parameter)1 AuditSetUpCommand (org.asqatasun.webapp.command.AuditSetUpCommand)1