use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractManagementController method deleteContractPage.
/**
* @param contractId
* @param request
* @param response
* @param model
* @return The pages audit set-up form page
*/
@RequestMapping(value = TgolKeyStore.DELETE_CONTRACT_URL, method = RequestMethod.GET)
@Secured(TgolKeyStore.ROLE_ADMIN_KEY)
public String deleteContractPage(@RequestParam(TgolKeyStore.CONTRACT_ID_KEY) String contractId, HttpServletRequest request, HttpServletResponse response, Model model) {
Long lContractId;
try {
lContractId = Long.valueOf(contractId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
Contract contractToDelete = getContractDataService().read(lContractId);
request.getSession().setAttribute(TgolKeyStore.CONTRACT_ID_TO_DELETE_KEY, contractToDelete.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_TO_DELETE_KEY, contractToDelete.getLabel());
model.addAttribute(TgolKeyStore.USER_ID_KEY, contractToDelete.getUser().getId());
model.addAttribute(TgolKeyStore.USER_NAME_KEY, contractToDelete.getUser().getEmail1());
return TgolKeyStore.DELETE_CONTRACT_VIEW_NAME;
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractManagementController method deleteContractAuditsPage.
/**
*
* @param contractId
* @param request
* @param response
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.DELETE_CONTRACT_AUDITS_URL, method = RequestMethod.GET)
@Secured(TgolKeyStore.ROLE_ADMIN_KEY)
public String deleteContractAuditsPage(@RequestParam(TgolKeyStore.CONTRACT_ID_KEY) String contractId, HttpServletRequest request, HttpServletResponse response, Model model) {
Long lContractId;
try {
lContractId = Long.valueOf(contractId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
Contract contractToDelete = getContractDataService().read(lContractId);
model.addAttribute(TgolKeyStore.CONTRACT_NAME_TO_DELETE_KEY, contractToDelete.getLabel());
model.addAttribute(TgolKeyStore.USER_ID_KEY, contractToDelete.getUser().getId());
model.addAttribute(TgolKeyStore.USER_NAME_KEY, contractToDelete.getUser().getEmail1());
request.getSession().setAttribute(TgolKeyStore.CONTRACT_ID_TO_DELETE_KEY, contractToDelete.getId());
return TgolKeyStore.DELETE_AUDITS_VIEW_NAME;
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractManagementController method submitDeleteContractConfirmation.
/**
*
* @param request
* @param response
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.DELETE_CONTRACT_URL, method = RequestMethod.POST)
@Secured(TgolKeyStore.ROLE_ADMIN_KEY)
public String submitDeleteContractConfirmation(HttpServletRequest request, HttpServletResponse response, Model model) {
Object contractId = request.getSession().getAttribute(TgolKeyStore.CONTRACT_ID_TO_DELETE_KEY);
Long lContractId;
if (contractId instanceof Long) {
lContractId = (Long) contractId;
} else {
try {
lContractId = Long.valueOf(contractId.toString());
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
}
Contract contractToDelete = getContractDataService().read(lContractId);
getContractDataService().delete(contractToDelete.getId());
// to be updated
if (getAuthenticatedUsername().equals(contractToDelete.getUser().getEmail1())) {
updateCurrentUser(getUserDataService().read(contractToDelete.getUser().getId()));
}
request.getSession().removeAttribute(TgolKeyStore.CONTRACT_ID_TO_DELETE_KEY);
request.getSession().setAttribute(TgolKeyStore.DELETED_CONTRACT_NAME_KEY, contractToDelete.getLabel());
model.addAttribute(TgolKeyStore.USER_ID_KEY, contractToDelete.getUser().getId());
return TgolKeyStore.MANAGE_CONTRACTS_VIEW_REDIRECT_NAME;
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ActDAOImplTest method testFindLastActsByContract.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
public void testFindLastActsByContract() {
System.out.println("findLastActsByContract");
Contract contract = contractDAO.read((Long.valueOf(1)));
assertEquals(1, actDAO.findActsByContract(contract, 1, 2, null, false).size());
assertEquals(Long.valueOf(7), actDAO.findActsByContract(contract, 1, 2, null, false).iterator().next().getId());
Collection<Act> actSet = actDAO.findActsByContract(contract, 3, 2, null, false);
Iterator<Act> iter = actSet.iterator();
Date currentDate = null;
while (iter.hasNext()) {
Act act = iter.next();
if (currentDate != null) {
assertTrue(act.getBeginDate().before(currentDate));
}
currentDate = act.getBeginDate();
}
contract = contractDAO.read((Long.valueOf(2)));
assertEquals(0, actDAO.findActsByContract(contract, 1, 2, null, false).size());
}
use of org.asqatasun.webapp.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOImplTest method testRead.
/**
* Test of read method, of class ContractDAOImpl.
*/
public void testRead() {
System.out.println("read");
Contract contract = contractDAO.read(Long.valueOf(1));
assertNotNull(contract);
assertEquals("http://www.contract1.com/", contractDataService.getUrlFromContractOption(contract));
assertEquals(Long.valueOf("1"), contract.getUser().getId());
Set<String> functionalityCodeSet = new HashSet<String>();
for (Functionality functionality : contract.getFunctionalitySet()) {
functionalityCodeSet.add(functionality.getCode());
}
assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
assertTrue(!functionalityCodeSet.contains("SITE_AUDIT"));
assertEquals(1, contract.getReferentialSet().size());
assertTrue(contract.getScenarioSet().isEmpty());
contract = contractDAO.read(Long.valueOf(2));
assertNotNull(contract);
assertEquals("http://www.contract2.com/", contractDataService.getUrlFromContractOption(contract));
assertEquals(Long.valueOf("1"), contract.getUser().getId());
functionalityCodeSet = new HashSet<String>();
for (Functionality functionality : contract.getFunctionalitySet()) {
functionalityCodeSet.add(functionality.getCode());
}
assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
assertTrue(functionalityCodeSet.contains("SITE_AUDIT"));
assertEquals(2, contract.getReferentialSet().size());
assertEquals(2, contract.getScenarioSet().size());
contract = contractDAO.read(Long.valueOf(3));
assertNull(contract);
}
Aggregations