use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm 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.customers.personnel.struts.actionforms.PersonActionForm 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.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.
the class PersonActionStrutsTest method testLoad.
@Test
public void testLoad() throws Exception {
addActionAndMethod(Methods.load.toString());
addRequestParameter("officeId", "1");
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
OfficeBO office = (OfficeBO) SessionUtils.getAttribute(PersonnelConstants.OFFICE, request);
Assert.assertNotNull(office);
Assert.assertEquals(1, office.getOfficeId().intValue());
verifyMasterData();
PersonActionForm personActionForm = (PersonActionForm) request.getSession().getAttribute("personActionForm");
Assert.assertNotNull(personActionForm);
// Assert.assertEquals(1, personActionForm.getCustomFields().size());
verifyForward(ActionForwards.load_success.toString());
PersonActionForm actionForm = (PersonActionForm) request.getSession().getAttribute("personActionForm");
Date currentDate = DateUtils.getCurrentDateWithoutTimeStamp();
Assert.assertEquals(currentDate, DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfJoiningMFI()));
}
Aggregations