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;
}
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);
}
}
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;
}
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;
}
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());
}
Aggregations