Search in sources :

Example 16 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class AuditScenarioController method addScenario.

@RequestMapping(value = TgolKeyStore.AUDIT_SCENARIO_MANAGEMENT_CONTRACT_URL, method = RequestMethod.POST)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
protected String addScenario(@ModelAttribute(TgolKeyStore.ADD_SCENARIO_COMMAND_KEY) AddScenarioCommand addScenarioCommand, BindingResult result, Model model, HttpServletRequest request) {
    Contract contract = getContractDataService().read(addScenarioCommand.getContractId());
    addScenarioFormValidator.validate(addScenarioCommand, result);
    // and the same page with updated data is displayed again
    if (!result.hasErrors()) {
        saveScenario(addScenarioCommand, contract);
        model.addAttribute(TgolKeyStore.NEW_SCENARIO_NAME_KEY, addScenarioCommand.getScenarioLabel());
        prepareScenarioManagementData(model, addScenarioCommand.getContractId().toString());
        return TgolKeyStore.SCENARIO_MANAGEMENT_VIEW_NAME;
    }
    addScenarioListToModel(contract, model);
    model.addAttribute(TgolKeyStore.ADD_SCENARIO_COMMAND_KEY, addScenarioCommand);
    model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
    return TgolKeyStore.SCENARIO_MANAGEMENT_VIEW_NAME;
}
Also used : Contract(org.asqatasun.webapp.entity.contract.Contract) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class AuditScenarioController method prepareScenarioManagementData.

/**
     * Prepare data to be displayed on the scenario management page
     * 
     * @param model
     * @param contractId 
     */
private void prepareScenarioManagementData(Model model, String contractId) {
    Long contractIdValue;
    try {
        contractIdValue = Long.valueOf(contractId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException(getCurrentUser());
    }
    Contract contract = getContractDataService().read(contractIdValue);
    if (isUserAllowedToDisplaySetUpPage(contract, TgolKeyStore.AUDIT_SCENARIO_SET_UP_VIEW_NAME)) {
        // add the AddScenarioCommand instance to the model
        model.addAttribute(TgolKeyStore.ADD_SCENARIO_COMMAND_KEY, AddScenarioCommandFactory.getAddScenarioCommand(contract));
        // add the contract label to the model
        model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
        // add the list of scenario to the model
        addScenarioListToModel(contract, model);
    }
}
Also used : Contract(org.asqatasun.webapp.entity.contract.Contract) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException)

Example 18 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ContractActionHandlerImpl method getActionList.

@Override
public synchronized List<Action> getActionList(Object object) {
    if (!(object instanceof Contract)) {
        return null;
    }
    List<Action> userContractActionList = getActionList();
    Collection<Functionality> functionalitySet = ((Contract) object).getFunctionalitySet();
    for (Action action : userContractActionList) {
        activateAction(action, functionalitySet);
    }
    return userContractActionList;
}
Also used : Action(org.asqatasun.webapp.action.Action) Functionality(org.asqatasun.webapp.entity.functionality.Functionality) Contract(org.asqatasun.webapp.entity.contract.Contract)

Example 19 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ContractFactoryImpl method createContract.

@Override
public Contract createContract(String label, Date beginDate, Date endDate, Date renewalDate, Float price, Set<Functionality> functionalitySet, Set<OptionElement> optionElementSet, Set<Referential> referentialSet, Set<Scenario> ScenarioSet, User user) {
    Contract contract = create();
    contract.setLabel(label);
    contract.setBeginDate(beginDate);
    contract.setEndDate(endDate);
    contract.setRenewalDate(renewalDate);
    contract.addAllFunctionality(functionalitySet);
    contract.addAllOptionElement(optionElementSet);
    contract.addAllReferential(referentialSet);
    contract.addAllScenario(ScenarioSet);
    contract.setPrice(price);
    return contract;
}
Also used : Contract(org.asqatasun.webapp.entity.contract.Contract)

Example 20 with Contract

use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.

the class ActDAOImplTest method testFindAllActsByContract.

/**
     * Test of findAllContractsByUser method, of class ContractDAOImpl.
     */
public void testFindAllActsByContract() {
    System.out.println("findAllActsByContract");
    Contract contract = contractDAO.read((Long.valueOf(1)));
    assertEquals(4, actDAO.findAllActsByContract(contract).size());
    contract = contractDAO.read((Long.valueOf(2)));
    assertEquals(3, actDAO.findAllActsByContract(contract).size());
}
Also used : Contract(org.asqatasun.webapp.entity.contract.Contract)

Aggregations

Contract (org.asqatasun.webapp.entity.contract.Contract)43 Secured (org.springframework.security.access.annotation.Secured)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)17 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)15 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)12 Audit (org.asqatasun.entity.audit.Audit)5 User (org.asqatasun.webapp.entity.user.User)5 List (java.util.List)4 Scenario (org.asqatasun.webapp.entity.scenario.Scenario)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Site (org.asqatasun.entity.subject.Site)3 WebResource (org.asqatasun.entity.subject.WebResource)3 Functionality (org.asqatasun.webapp.entity.functionality.Functionality)3 AuditResultSortCommand (org.asqatasun.webapp.command.AuditResultSortCommand)2 AuditSetUpFormValidator (org.asqatasun.webapp.validator.AuditSetUpFormValidator)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1