use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class ContractManagementController method submitManageContractsAdminPage.
/**
* @param contractDisplayCommand
* @param userId
* @param request
* @param response
* @param model
* @return The pages audit set-up form page
*/
@RequestMapping(value = TgolKeyStore.MANAGE_CONTRACTS_URL, method = RequestMethod.POST)
@Secured(TgolKeyStore.ROLE_ADMIN_KEY)
public String submitManageContractsAdminPage(@ModelAttribute(TgolKeyStore.CONTRACT_SORT_COMMAND_KEY) ContractSortCommand contractDisplayCommand, @RequestParam(TgolKeyStore.USER_ID_KEY) String userId, HttpServletRequest request, HttpServletResponse response, Model model) {
Long lUserId;
try {
lUserId = Long.valueOf(userId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
User userToManage = getUserDataService().read(lUserId);
model.addAttribute(TgolKeyStore.CONTRACT_LIST_KEY, ContractSortCommandHelper.prepareContract(userToManage, contractDisplayCommand, displayOptionFieldsBuilderList, model));
model.addAttribute(TgolKeyStore.USER_NAME_KEY, userToManage.getEmail1());
return TgolKeyStore.MANAGE_CONTRACTS_VIEW_NAME;
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class HomeController method submitForm.
@RequestMapping(value = TgolKeyStore.HOME_URL, method = RequestMethod.POST)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
protected String submitForm(@ModelAttribute(TgolKeyStore.CONTRACT_SORT_COMMAND_KEY) ContractSortCommand contractDisplayCommand, BindingResult result, Model model, HttpServletRequest request) {
User user = getCurrentUser();
if (!user.getId().equals(contractDisplayCommand.getUserId())) {
throw new ForbiddenUserException();
}
// The page is displayed with sort option. Form needs to be set up
model.addAttribute(TgolKeyStore.CONTRACT_LIST_KEY, ContractSortCommandHelper.prepareContractInfo(user, contractDisplayCommand, displayOptionFieldsBuilderList, model));
return TgolKeyStore.HOME_VIEW_NAME;
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class ContractManagementController method displayManageContractsAdminPage.
/**
* @param userId
* @param request
* @param response
* @param model
* @return The pages audit set-up form page
*/
@RequestMapping(value = TgolKeyStore.MANAGE_CONTRACTS_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_ADMIN_KEY })
public String displayManageContractsAdminPage(@RequestParam(TgolKeyStore.USER_ID_KEY) String userId, HttpServletRequest request, HttpServletResponse response, Model model) {
Long lUserId;
try {
lUserId = Long.valueOf(userId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
if (request.getSession().getAttribute(TgolKeyStore.DELETED_CONTRACT_NAME_KEY) != null) {
model.addAttribute(TgolKeyStore.DELETED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_CONTRACT_NAME_KEY));
request.getSession().removeAttribute(TgolKeyStore.DELETED_CONTRACT_NAME_KEY);
}
if (request.getSession().getAttribute(TgolKeyStore.DELETED_CONTRACT_AUDITS_NAME_KEY) != null) {
model.addAttribute(TgolKeyStore.DELETED_CONTRACT_AUDITS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_CONTRACT_AUDITS_NAME_KEY));
request.getSession().removeAttribute(TgolKeyStore.DELETED_CONTRACT_AUDITS_NAME_KEY);
}
if (request.getSession().getAttribute(TgolKeyStore.UPDATED_CONTRACT_NAME_KEY) != null) {
model.addAttribute(TgolKeyStore.UPDATED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_CONTRACT_NAME_KEY));
request.getSession().removeAttribute(TgolKeyStore.UPDATED_CONTRACT_NAME_KEY);
}
if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null) {
model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY));
request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY);
}
User userToManage = getUserDataService().read(lUserId);
model.addAttribute(TgolKeyStore.CONTRACT_LIST_KEY, ContractSortCommandHelper.prepareContract(userToManage, null, displayOptionFieldsBuilderList, model));
model.addAttribute(TgolKeyStore.USER_NAME_KEY, userToManage.getEmail1());
return TgolKeyStore.MANAGE_CONTRACTS_VIEW_NAME;
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImplTest method testFindUserFromName.
public void testFindUserFromName() {
User user = userDAO.findUserFromName("Test1");
assertEquals(Long.valueOf(1), user.getId());
user = userDAO.findUserFromName("test");
assertNull(user);
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImplTest method testRead.
public void testRead() {
User user = userDAO.read(Long.valueOf(1));
assertEquals("Test1", user.getName());
assertEquals("Role1", user.getRole().getRoleName());
user = userDAO.read(Long.valueOf(2));
assertEquals("Test2", user.getName());
assertEquals("Role2", user.getRole().getRoleName());
}
Aggregations