Search in sources :

Example 11 with PersonActionForm

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());
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MessageLookup(org.mifos.application.master.MessageLookup) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 12 with PersonActionForm

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());
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 13 with PersonActionForm

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()));
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) OfficeBO(org.mifos.customers.office.business.OfficeBO) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)13 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)11 ArrayList (java.util.ArrayList)5 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)4 ValueListElement (org.mifos.dto.domain.ValueListElement)4 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)3 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)3 UserContext (org.mifos.security.util.UserContext)3 List (java.util.List)2 Test (org.junit.Test)2 MessageLookup (org.mifos.application.master.MessageLookup)2 PersonnelException (org.mifos.customers.personnel.exceptions.PersonnelException)2 CreateOrUpdatePersonnelInformation (org.mifos.dto.domain.CreateOrUpdatePersonnelInformation)2 UserDetailDto (org.mifos.dto.domain.UserDetailDto)2 Name (org.mifos.framework.business.util.Name)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 Date (java.util.Date)1