use of org.mifos.security.rolesandpermission.business.RoleBO in project head by mifos.
the class PersonAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm personActionForm = (PersonActionForm) form;
String globalId = request.getParameter("globalPersonnelNum");
if (globalId == null) {
globalId = personActionForm.getGlobalPersonnelNum();
}
PersonnelInformationDto personnelInformationDto = this.personnelServiceFacade.getPersonnelInformationDto(null, globalId);
SessionUtils.removeThenSetAttribute("personnelInformationDto", personnelInformationDto, request);
// John W - for other actions downstream (like edit) business_key set (until all actions refactored)
PersonnelBO personnelBO = this.personnelDao.findPersonnelById(personnelInformationDto.getPersonnelId());
SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, personnelBO, request);
String url = String.format("PersonAction.do?globalPersonnelNum=%s", personnelBO.getGlobalPersonnelNum());
SessionUtils.removeThenSetAttribute("currentPageUrl", url, request);
List<ValueListElement> titles = this.customerDao.retrieveTitles();
List<ValueListElement> genders = this.customerDao.retrieveGenders();
List<ValueListElement> maritalStatuses = this.customerDao.retrieveMaritalStatuses();
List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
List<RoleBO> roles = legacyRolesPermissionsDao.getRoles();
List<PersonnelLevelEntity> personnelLevels = this.customerDao.retrievePersonnelLevels();
for (PersonnelLevelEntity personnelLevelEntity : personnelLevels) {
String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelLevelEntity.getLookUpValue().getPropertiesKey());
personnelLevelEntity.setName(messageTextLookup);
}
SessionUtils.setCollectionAttribute(PersonnelConstants.TITLE_LIST, titles, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_LEVEL_LIST, personnelLevels, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.GENDER_LIST, genders, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.MARITAL_STATUS_LIST, maritalStatuses, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.LANGUAGE_LIST, languages, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, roles, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, roles, request);
List<CustomFieldDefinitionEntity> customFieldDefs1 = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs1, request);
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
personActionForm.setCustomFields(customFields);
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.security.rolesandpermission.business.RoleBO in project head by mifos.
the class PersonAction method previewManage.
@SuppressWarnings("unchecked")
@TransactionDemarcate(joinToken = true)
public ActionForward previewManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm actionForm = (PersonActionForm) form;
boolean addFlag = false;
List<RoleBO> selectList = new ArrayList<RoleBO>();
if (actionForm.getPersonnelRoles() != null) {
List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
for (RoleBO role : masterList) {
for (String roleId : actionForm.getPersonnelRoles()) {
if (roleId != null && role.getId().intValue() == Integer.valueOf(roleId).intValue()) {
selectList.add(role);
addFlag = true;
}
}
}
}
if (addFlag) {
SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
} else {
SessionUtils.setAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, null, request);
}
return mapping.findForward(ActionForwards.previewManage_success.toString());
}
use of org.mifos.security.rolesandpermission.business.RoleBO in project head by mifos.
the class BirtReportsUploadActionStrutsTest method setupReportEditPermission.
private void setupReportEditPermission(boolean allowReportEdit) throws Exception {
UserContext userContext = TestUtils.makeUser();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
request.getSession(false).setAttribute(Constants.ACTIVITYCONTEXT, ac);
RoleBO role = legacyRolesPermissionsDao.getRole(userContext.getRoles().iterator().next());
List<ActivityEntity> roleActivities = new ArrayList<ActivityEntity>(role.getActivities());
List<ActivityEntity> updatedRoleActivities = new ArrayList<ActivityEntity>();
for (ActivityEntity ae : roleActivities) {
if (ae.getId() != SecurityConstants.EDIT_REPORT_INFORMATION || allowReportEdit) {
updatedRoleActivities.add(ae);
}
}
try {
StaticHibernateUtil.startTransaction();
role.update(userContext.getId(), "test", updatedRoleActivities);
legacyRolesPermissionsDao.save(role);
StaticHibernateUtil.flushSession();
for (ActivityEntity ae : legacyRolesPermissionsDao.getActivities()) {
StaticHibernateUtil.getSessionTL().refresh(ae);
}
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
setRequestPathInfo("/birtReportsUploadAction.do");
addRequestParameter("method", "edit");
addRequestParameter("reportId", "1");
}
use of org.mifos.security.rolesandpermission.business.RoleBO in project head by mifos.
the class RolesPermissionsActionStrutsTest method testDeleteFailure.
@Test
public void testDeleteFailure() throws Exception {
RoleBO roleBO = legacyRolesPermissionsDao.getRole("Admin");
setRequestPathInfo("/rolesPermission.do");
addRequestParameter("method", "preview");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("id", roleBO.getId().toString());
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.preview_success.toString());
Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
setRequestPathInfo("/rolesPermission.do");
addRequestParameter("method", "delete");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyActionErrors(new String[] { RolesAndPermissionConstants.KEYROLEASSIGNEDTOPERSONNEL });
verifyForward(ActionForwards.delete_failure.toString());
Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
}
use of org.mifos.security.rolesandpermission.business.RoleBO in project head by mifos.
the class RolesPermissionsBusinessServiceIntegrationTest method testGetRoleForGivenId.
@Test
public void testGetRoleForGivenId() throws Exception {
RoleBO role = rolesPermissionsBusinessService.getRole(Short.valueOf("1"));
Assert.assertNotNull(role);
Assert.assertEquals(RoleTestUtil.EXPECTED_ACTIVITIES_FOR_ROLE, role.getActivities().size());
}
Aggregations