Search in sources :

Example 36 with ListElement

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

the class SavingsProductFormBeanAssembler method populatePrincipalGlCodesDropdown.

private void populatePrincipalGlCodesDropdown(SavingsProductFormDto referenceData, SavingsProductFormBean formBean) {
    Map<String, GLCodeDto> principalGeneralLedgerOptions = new LinkedHashMap<String, GLCodeDto>();
    for (ListElement glCode : referenceData.getPrincipalGlCodes()) {
        GLCodeDto codeDto = new GLCodeDto();
        codeDto.setGlcode(glCode.getName());
        codeDto.setGlname(glCode.getGlname());
        principalGeneralLedgerOptions.put(glCode.getId().toString(), codeDto);
    }
    formBean.setPrincipalGeneralLedgerOptions(principalGeneralLedgerOptions);
}
Also used : GLCodeDto(org.mifos.dto.domain.GLCodeDto) ListElement(org.mifos.dto.screen.ListElement) LinkedHashMap(java.util.LinkedHashMap)

Example 37 with ListElement

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

the class SavingsProductFormBeanAssembler method populateInterestGlCodesDropdown.

private void populateInterestGlCodesDropdown(SavingsProductFormDto referenceData, SavingsProductFormBean formBean) {
    Map<String, GLCodeDto> interestGeneralLedgerOptions = new LinkedHashMap<String, GLCodeDto>();
    for (ListElement glCode : referenceData.getInterestGlCodes()) {
        GLCodeDto codeDto = new GLCodeDto();
        codeDto.setGlcode(glCode.getName());
        codeDto.setGlname(glCode.getGlname());
        interestGeneralLedgerOptions.put(glCode.getId().toString(), codeDto);
    }
    formBean.setInterestGeneralLedgerOptions(interestGeneralLedgerOptions);
}
Also used : GLCodeDto(org.mifos.dto.domain.GLCodeDto) ListElement(org.mifos.dto.screen.ListElement) LinkedHashMap(java.util.LinkedHashMap)

Example 38 with ListElement

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

the class SavingsProductFormBeanAssembler method populateDepositTypesDropdown.

private void populateDepositTypesDropdown(SavingsProductFormDto referenceData, SavingsProductFormBean formBean) {
    Map<String, String> depositTypes = new LinkedHashMap<String, String>();
    for (ListElement option : referenceData.getDepositTypes()) {
        depositTypes.put(option.getId().toString(), option.getName());
    }
    formBean.setDepositTypeOptions(depositTypes);
}
Also used : ListElement(org.mifos.dto.screen.ListElement) LinkedHashMap(java.util.LinkedHashMap)

Example 39 with ListElement

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

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

the class PersonnelServiceFacadeWebTier method createPersonnelInformation.

@Override
public UserDetailDto createPersonnelInformation(CreateOrUpdatePersonnelInformation personnel) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    try {
        PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
        List<RoleBO> roles = new ArrayList<RoleBO>();
        for (ListElement element : personnel.getRoles()) {
            RoleBO role = personnelBusinessService.getRoleById(new Short(element.getId().shortValue()));
            roles.add(role);
        }
        AddressDto addressDto = personnel.getAddress();
        Address address = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
        OfficeBO office = officeDao.findOfficeById(personnel.getOfficeId());
        Name name = new Name(personnel.getFirstName(), personnel.getMiddleName(), personnel.getSecondLastName(), personnel.getLastName());
        verifyFields(personnel.getUserName(), personnel.getGovernmentIdNumber(), personnel.getDob().toDate(), name.getDisplayName());
        PersonnelBO newPersonnel = new PersonnelBO(PersonnelLevel.fromInt(personnel.getPersonnelLevelId().intValue()), office, personnel.getTitle(), personnel.getPreferredLocale(), personnel.getPassword(), personnel.getUserName(), personnel.getEmailId(), roles, personnel.getCustomFields(), name, personnel.getGovernmentIdNumber(), personnel.getDob().toDate(), personnel.getMaritalStatus(), personnel.getGender(), personnel.getDateOfJoiningMFI().toDate(), personnel.getDateOfJoiningBranch().toDate(), address, Integer.valueOf(user.getUserId()).shortValue(), personnel.getPasswordExpirationDate().toDate(), null);
        transactionHelper.startTransaction();
        this.personnelDao.save(newPersonnel);
        transactionHelper.flushSession();
        newPersonnel.generateGlobalPersonnelNum();
        this.personnelDao.save(newPersonnel);
        transactionHelper.commitTransaction();
        return newPersonnel.toDto();
    } catch (PersistenceException e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (ValidationException e) {
        transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e.getValues(), e);
    } catch (ServiceException e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ValidationException(org.mifos.framework.exceptions.ValidationException) Address(org.mifos.framework.business.util.Address) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) AddressDto(org.mifos.dto.domain.AddressDto) Name(org.mifos.framework.business.util.Name) BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ListElement (org.mifos.dto.screen.ListElement)41 ArrayList (java.util.ArrayList)20 LinkedHashMap (java.util.LinkedHashMap)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ValueListElement (org.mifos.dto.domain.ValueListElement)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 AddressDto (org.mifos.dto.domain.AddressDto)5 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)5 MifosUser (org.mifos.security.MifosUser)5 UserContext (org.mifos.security.util.UserContext)5 DateTime (org.joda.time.DateTime)4 OfficeBO (org.mifos.customers.office.business.OfficeBO)4 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 CreateOrUpdatePersonnelInformation (org.mifos.dto.domain.CreateOrUpdatePersonnelInformation)3 Address (org.mifos.framework.business.util.Address)3 LocalDate (org.joda.time.LocalDate)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2