Search in sources :

Example 1 with DefinePersonnelDto

use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.

the class SystemUserController method createUserFormBean.

public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) {
    OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue());
    formBean.setOfficeId(officeId);
    formBean.setOfficeName(selectedOffice.getName());
    MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields();
    formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1());
    formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2());
    formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3());
    formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity());
    formBean.getAddress().setStateHidden(dtoFields.isHideSystemState());
    formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry());
    formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode());
    DefinePersonnelDto userRefData = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId.shortValue());
    Map<String, String> genderOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getGenderList()) {
        genderOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setGenderOptions(genderOptions);
    Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getMaritalStatusList()) {
        maritalStatusOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setMaritalStatusOptions(maritalStatusOptions);
    Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getLanguageList()) {
        preferredLanguageOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setPreferredLanguageOptions(preferredLanguageOptions);
    Map<String, String> userTitleOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getTitleList()) {
        userTitleOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserTitleOptions(userTitleOptions);
    Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getPersonnelLevelList()) {
        userHierarchyOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserHierarchyOptions(userHierarchyOptions);
    Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getRolesList()) {
        availableRolesOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setAvailableRolesOptions(availableRolesOptions);
    formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>());
    DateTime today = new DateTime();
    formBean.setMfiJoiningDateDay(today.getDayOfMonth());
    formBean.setMfiJoiningDateMonth(today.getMonthOfYear());
    formBean.setMfiJoiningDateYear(today.getYearOfEra());
    return formBean;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ListElement(org.mifos.dto.screen.ListElement) MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) DateTime(org.joda.time.DateTime) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with DefinePersonnelDto

use of org.mifos.dto.screen.DefinePersonnelDto 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 3 with DefinePersonnelDto

use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.

the class PersonnelServiceFacadeWebTier method retrieveInfoForNewUserDefinition.

@Override
public DefinePersonnelDto retrieveInfoForNewUserDefinition(Short officeId) {
    String officeName = "";
    if (officeId != null) {
        OfficeBO office = officeDao.findOfficeById(officeId);
        officeName = office.getOfficeName();
    }
    List<ValueListElement> titles = customerDao.retrieveTitles();
    List<ListElement> titleList = new ArrayList<ListElement>();
    for (ValueListElement element : titles) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        titleList.add(listElement);
    }
    List<PersonnelLevelEntity> personnelLevels = customerDao.retrievePersonnelLevels();
    List<ListElement> personnelLevelList = new ArrayList<ListElement>();
    for (PersonnelLevelEntity level : personnelLevels) {
        String name = level.getLookUpValue().getLookUpName();
        String localisedName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(name);
        ListElement listElement = new ListElement(new Integer(level.getId()), localisedName);
        personnelLevelList.add(listElement);
    }
    List<ValueListElement> genders = customerDao.retrieveGenders();
    List<ListElement> genderList = new ArrayList<ListElement>();
    for (ValueListElement element : genders) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        genderList.add(listElement);
    }
    List<ValueListElement> maritalStatuses = customerDao.retrieveMaritalStatuses();
    List<ListElement> maritalStatusList = new ArrayList<ListElement>();
    for (ValueListElement element : maritalStatuses) {
        ListElement listElement = new ListElement(element.getId(), element.getName());
        maritalStatusList.add(listElement);
    }
    List<RoleBO> roles = new ArrayList<RoleBO>();
    try {
        roles = rolesPermissionsPersistence.getRoles();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    List<ListElement> roleList = new ArrayList<ListElement>();
    for (RoleBO element : roles) {
        ListElement listElement = new ListElement(new Integer(element.getId()), element.getName());
        roleList.add(listElement);
    }
    List<ListElement> languageList = Localization.getInstance().getLocaleList();
    DefinePersonnelDto defineUserDto = new DefinePersonnelDto(officeName, titleList, personnelLevelList, genderList, maritalStatusList, languageList, roleList);
    return defineUserDto;
}
Also used : ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) MessageLookup(org.mifos.application.master.MessageLookup) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with DefinePersonnelDto

use of org.mifos.dto.screen.DefinePersonnelDto in project head by mifos.

the class PersonnelServiceFacadeWebTierTest method shouldRetrieveOfficeName.

@Test
public void shouldRetrieveOfficeName() {
    // setup
    Short officeId = Short.valueOf("3");
    OfficeBO office = new OfficeBuilder().withName("officeTestName").build();
    when(officeDao.findOfficeById(officeId)).thenReturn(office);
    // exercise test
    DefinePersonnelDto personnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
    // verification
    assertThat(personnelDto.getOfficeName(), is("officeTestName"));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) Test(org.junit.Test)

Aggregations

DefinePersonnelDto (org.mifos.dto.screen.DefinePersonnelDto)4 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 ArrayList (java.util.ArrayList)2 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 ListElement (org.mifos.dto.screen.ListElement)2 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)2 LinkedHashMap (java.util.LinkedHashMap)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 MessageLookup (org.mifos.application.master.MessageLookup)1 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)1 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)1 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 MandatoryHiddenFieldsDto (org.mifos.dto.domain.MandatoryHiddenFieldsDto)1 OfficeDto (org.mifos.dto.domain.OfficeDto)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1