Search in sources :

Example 6 with PersonActionForm

use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.

the class PersonAction method cancel.

@SuppressWarnings("unused")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    String forward = null;
    PersonActionForm actionForm = (PersonActionForm) form;
    String fromPage = actionForm.getInput();
    if (fromPage.equals(PersonnelConstants.MANAGE_USER) || fromPage.equals(PersonnelConstants.UNLOCK_USER)) {
        forward = ActionForwards.cancelEdit_success.toString();
    } else {
        forward = ActionForwards.cancel_success.toString();
    }
    return mapping.findForward(forward.toString());
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with PersonActionForm

use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.

the class PersonAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm actionform = (PersonActionForm) form;
    actionform.clear();
    PersonnelBO personnelInSession = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelInSession.getPersonnelId());
    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> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    UserContext userContext = getUserContext(request);
    List<PersonnelStatusEntity> statuses = legacyMasterDao.findMasterDataEntitiesWithLocale(PersonnelStatusEntity.class);
    for (PersonnelStatusEntity personnelStatusEntity : statuses) {
        String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatusEntity.getLookUpValue().getPropertiesKey());
        personnelStatusEntity.setName(messageTextLookup);
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.STATUS_LIST, statuses, request);
    OfficeBO loggedInOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    List<OfficeDetailsDto> officeHierarchy = new OfficePersistence().getChildOffices(loggedInOffice.getSearchId());
    SessionUtils.setCollectionAttribute(PersonnelConstants.OFFICE_LIST, officeHierarchy, request);
    actionform.setPersonnelId(personnel.getPersonnelId().toString());
    if (personnel.getOffice() != null) {
        actionform.setOfficeId(personnel.getOffice().getOfficeId().toString());
    }
    if (personnel.getTitle() != null) {
        actionform.setTitle(personnel.getTitle().toString());
    }
    if (personnel.getLevel() != null) {
        actionform.setLevel(personnel.getLevelEnum().getValue().toString());
    }
    if (personnel.getStatus() != null) {
        actionform.setStatus(personnel.getStatus().getId().toString());
    }
    actionform.setLoginName(personnel.getUserName());
    actionform.setGlobalPersonnelNum(personnel.getGlobalPersonnelNum());
    actionform.setCustomFields(new ArrayList<CustomFieldDto>());
    if (personnel.getPersonnelDetails() != null) {
        PersonnelDetailsEntity personnelDetails = personnel.getPersonnelDetails();
        actionform.setFirstName(personnelDetails.getName().getFirstName());
        actionform.setMiddleName(personnelDetails.getName().getMiddleName());
        actionform.setSecondLastName(personnelDetails.getName().getSecondLastName());
        actionform.setLastName(personnelDetails.getName().getLastName());
        if (personnelDetails.getGender() != null) {
            actionform.setGender(personnelDetails.getGender().toString());
        }
        if (personnelDetails.getMaritalStatus() != null) {
            actionform.setMaritalStatus(personnelDetails.getMaritalStatus().toString());
        }
        actionform.setAddress(personnelDetails.getAddress());
        if (personnelDetails.getDateOfJoiningMFI() != null) {
            actionform.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDateOfJoiningMFI()));
        }
        if (personnelDetails.getDob() != null) {
            actionform.setDob(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDob()));
        }
    }
    actionform.setEmailId(personnel.getEmailId());
    if (personnel.getPreferredLocale() != null) {
        actionform.setPreferredLocale(personnel.getPreferredLocale());
    }
    if (personnel.getPasswordExpirationDate() != null) {
        actionform.setPasswordExpirationDate(DateUtils.makeDateAsSentFromBrowser(personnel.getPasswordExpirationDate()));
    }
    List<RoleBO> selectList = new ArrayList<RoleBO>();
    for (PersonnelRoleEntity personnelRole : personnel.getPersonnelRoles()) {
        selectList.add(personnelRole.getRole());
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) MessageLookup(org.mifos.application.master.MessageLookup) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with PersonActionForm

use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.

the class PersonAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    Short officeId = getShortValue(personActionForm.getOfficeId());
    OfficeBO office = this.officeDao.findOfficeById(officeId);
    SessionUtils.setAttribute(PersonnelConstants.OFFICE, office, request);
    personActionForm.clear();
    //Shahid - keeping the previous session objects for the sake of existing tests, once fully converted to spring
    //then we can get rid of the session objects made redundant by the dto
    DefinePersonnelDto definePersonnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
    SessionUtils.setAttribute("definePersonnelDto", definePersonnelDto, 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();
    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);
    if (office.getOfficeLevel() != OfficeLevel.BRANCHOFFICE) {
        for (MasterDataEntity level : personnelLevels) {
            if (level.getId().equals(PersonnelLevel.LOAN_OFFICER.getValue())) {
                personnelLevels.remove(level);
                break;
            }
        }
    }
    personActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    personActionForm.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) OfficeBO(org.mifos.customers.office.business.OfficeBO) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with PersonActionForm

use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.

the class PersonAction method preview.

@SuppressWarnings("unchecked")
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    UserContext userContext = getUserContext(request);
    personActionForm.setDateOfJoiningBranch(DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    PersonActionForm personActionForm1 = (PersonActionForm) form;
    boolean addFlag = false;
    List<RoleBO> selectList = new ArrayList<RoleBO>();
    if (personActionForm1.getPersonnelRoles() != null) {
        List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
        for (RoleBO role : masterList) {
            for (String roleId : personActionForm1.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 createGroupQuestionnaire.fetchAppliedQuestions(mapping, personActionForm, request, ActionForwards.preview_success);
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) UserContext(org.mifos.security.util.UserContext) 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 10 with PersonActionForm

use of org.mifos.customers.personnel.struts.actionforms.PersonActionForm in project head by mifos.

the class PersonAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm actionForm = (PersonActionForm) form;
    try {
        CreateOrUpdatePersonnelInformation perosonnelInfo = translateFormToCreatePersonnelInformationDto(request, actionForm);
        UserDetailDto userDetails = this.personnelServiceFacade.updatePersonnel(perosonnelInfo);
        String globalPersonnelNum = userDetails.getSystemId();
        Name name = new Name(actionForm.getFirstName(), actionForm.getMiddleName(), actionForm.getSecondLastName(), actionForm.getLastName());
        request.setAttribute("displayName", name.getDisplayName());
        request.setAttribute("globalPersonnelNum", globalPersonnelNum);
        //refresh user context roles if active
        Set<Short> roles = new HashSet<Short>();
        for (ListElement userNewRole : perosonnelInfo.getRoles()) {
            roles.add(userNewRole.getId().shortValue());
        }
        refreshUserContextIfActive(request, perosonnelInfo.getId(), perosonnelInfo.getUserName(), roles);
        return mapping.findForward(ActionForwards.update_success.toString());
    } catch (BusinessRuleException e) {
        throw new PersonnelException(e.getMessageKey(), e.getMessageValues());
    }
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) UserDetailDto(org.mifos.dto.domain.UserDetailDto) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersonnelException(org.mifos.customers.personnel.exceptions.PersonnelException) Name(org.mifos.framework.business.util.Name) HashSet(java.util.HashSet) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

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