Search in sources :

Example 26 with ListElement

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

the class CreateSavingsAccountControllerTest method testLoadProduct.

@SuppressWarnings("unchecked")
@Test
public void testLoadProduct() {
    Integer productId = 1;
    List<ListElement> interestCalculationOptions = new ArrayList<ListElement>();
    boolean groupSavingsAccount = false;
    Integer depositType = 1;
    Integer groupSavingsType = 1;
    Double amountForDeposit = 10.0;
    Double maxWithdrawal = 100.0;
    BigDecimal interestRate = new BigDecimal("5.0");
    Integer interestCalculationType = 1;
    Integer interestCalculationFrequency = 1;
    Integer interestCalculationFrequencyPeriod = 1;
    Integer interestPostingMonthlyFrequency = 1;
    BigDecimal minBalanceForInterestCalculation = new BigDecimal("1.0");
    Integer depositGlCode = 1;
    Integer interestGlCode = 1;
    ProductDetailsDto productsDetailDto = null;
    SavingsProductDto savingsProductDetails = new SavingsProductDto(productsDetailDto, groupSavingsAccount, depositType, groupSavingsType, amountForDeposit, maxWithdrawal, interestRate, interestCalculationType, interestCalculationFrequency, interestCalculationFrequencyPeriod, interestPostingMonthlyFrequency, minBalanceForInterestCalculation, depositGlCode, interestGlCode, false);
    SavingsProductReferenceDto savingsProductReference = new SavingsProductReferenceDto(interestCalculationOptions, savingsProductDetails, true);
    when(savingsServiceFacade.retrieveSavingsProductReferenceData(productId)).thenReturn(savingsProductReference);
    controller.loadProduct(productId, formBean);
    verify(formBean).setProductId(productId);
    verify(formBean).setProduct(savingsProductReference);
    verify(formBean).setMandatoryDepositAmount(any(String.class));
    verify(formBean).setSavingsTypes(any(Map.class));
    verify(formBean).setRecurrenceTypes(any(Map.class));
    verify(formBean).setRecurrenceFrequencies(any(Map.class));
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) HashMap(java.util.HashMap) Map(java.util.Map) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 27 with ListElement

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

the class SystemUserController method translateUserFormBeanToDto.

@SuppressWarnings("PMD")
private CreateOrUpdatePersonnelInformation translateUserFormBeanToDto(final UserFormBean userFormBean) {
    Short officeId = userFormBean.getOfficeId().shortValue();
    String firstName = userFormBean.getFirstName();
    String middleName = userFormBean.getMiddleName();
    String secondLastName = userFormBean.getSecondLastName();
    String lastName = userFormBean.getLastName();
    String governmentIdNumber = userFormBean.getGovernmentId();
    DateTime dateOfBirth = userFormBean.getDateOfBirthAsDateTime();
    DateTime mfiJoiningDate = userFormBean.getMfiJoiningDateAsDateTime();
    DateTime branchJoiningDate = userFormBean.getMfiJoiningDateAsDateTime();
    DateTime passwordExpirationDate = userFormBean.getPasswordExpirationDateAsDateTime();
    String email = userFormBean.getEmail();
    Integer maritalStatus = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedMaritalStatus())) {
        maritalStatus = Integer.valueOf(userFormBean.getSelectedMaritalStatus());
    }
    Integer gender = Integer.valueOf(userFormBean.getSelectedGender());
    Integer title = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedUserTitle())) {
        title = Integer.valueOf(userFormBean.getSelectedUserTitle());
    }
    Short personnelLevelId = Short.valueOf(userFormBean.getSelectedUserHierarchy());
    List<ListElement> roles = new ArrayList<ListElement>();
    String[] selectedRoles = userFormBean.getSelectedRoles();
    if (selectedRoles != null) {
        for (String role : selectedRoles) {
            roles.add(new ListElement(Integer.valueOf(role), userFormBean.getSelectedRolesOptions().get(role)));
        }
    }
    AddressBean bean = userFormBean.getAddress();
    AddressDto address = new AddressDto(bean.getAddress1(), bean.getAddress2(), bean.getAddress3(), bean.getCityDistrict(), bean.getState(), bean.getCountry(), bean.getPostalCode(), bean.getTelephoneNumber());
    Short preferredLocale = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedPreferredLanguage())) {
        preferredLocale = Short.valueOf(userFormBean.getSelectedPreferredLanguage());
    }
    String password = userFormBean.getPassword();
    String username = userFormBean.getUsername();
    // FIXME - add status to screen and support translation from bean to DTO
    // active
    Short personnelStatusId = Short.valueOf("1");
    List<CustomFieldDto> customFields = userFormBean.getCustomFields();
    CreateOrUpdatePersonnelInformation personnel = new CreateOrUpdatePersonnelInformation(userFormBean.getUserId(), personnelLevelId, officeId, title, preferredLocale, password, username, email, roles, customFields, firstName, middleName, lastName, secondLastName, governmentIdNumber, dateOfBirth, maritalStatus, gender, mfiJoiningDate, branchJoiningDate, address, personnelStatusId, passwordExpirationDate);
    return personnel;
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) ListElement(org.mifos.dto.screen.ListElement)

Example 28 with ListElement

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

the class SystemUserController method createPopulatedUserFormBean.

public UserFormBean createPopulatedUserFormBean(final Long userId, final UserFormBean formBean) {
    PersonnelInformationDto personnelInformation = this.personnelServiceFacade.getPersonnelInformationDto(userId, "");
    UserFormBean populatedBean = createUserFormBean(personnelInformation.getOfficeId().longValue(), formBean);
    populatedBean.setUserId(userId);
    populatedBean.setStatusId(personnelInformation.getStatus().getId());
    populatedBean.setDisplayName(personnelInformation.getDisplayName());
    PersonnelDetailsDto details = personnelInformation.getPersonnelDetails();
    populatedBean.setFirstName(details.getFirstName());
    populatedBean.setMiddleName(details.getMiddleName());
    populatedBean.setSecondLastName(details.getSecondLastName());
    populatedBean.setLastName(details.getLastName());
    populatedBean.setGovernmentId(details.getGovernmentIdNumber());
    populatedBean.setEmail(personnelInformation.getEmailId());
    populatedBean.setDateOfBirthDay(details.getDob().getDayOfMonth());
    populatedBean.setDateOfBirthMonth(details.getDob().getMonthOfYear());
    populatedBean.setDateOfBirthYear(details.getDob().getYearOfEra());
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setDateOfBirthDay(details.getPasswordExpirationDate().getDayOfMonth());
        populatedBean.setDateOfBirthMonth(details.getPasswordExpirationDate().getMonthOfYear());
        populatedBean.setDateOfBirthYear(details.getPasswordExpirationDate().getYearOfEra());
    }
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setMfiJoiningDateDay(details.getDateOfJoiningMFI().getDayOfMonth());
        populatedBean.setMfiJoiningDateMonth(details.getDateOfJoiningMFI().getMonthOfYear());
        populatedBean.setMfiJoiningDateYear(details.getDateOfJoiningMFI().getYearOfEra());
    }
    populatedBean.setSelectedGender(details.getGender().toString());
    if (details.getMaritalStatus() != null) {
        populatedBean.setSelectedMaritalStatus(details.getMaritalStatus().toString());
    }
    if (personnelInformation.getPreferredLanguageId() != null) {
        populatedBean.setSelectedPreferredLanguage(personnelInformation.getPreferredLanguageId().toString());
    }
    AddressDto address = details.getAddress();
    AddressBean bean = populatedBean.getAddress();
    bean.setAddress1(address.getLine1());
    bean.setAddress2(address.getLine2());
    bean.setAddress3(address.getLine3());
    bean.setCityDistrict(address.getCity());
    bean.setState(address.getState());
    bean.setCountry(address.getCountry());
    bean.setPostalCode(address.getZip());
    bean.setTelephoneNumber(address.getPhoneNumber());
    populatedBean.setAddress(bean);
    if (personnelInformation.getTitle() != null) {
        populatedBean.setSelectedUserTitle(personnelInformation.getTitle().toString());
    }
    populatedBean.setSelectedUserHierarchy(personnelInformation.getLevelId().toString());
    Set<ListElement> roles = personnelInformation.getPersonnelRoles();
    String[] selectedRoles = new String[roles.size()];
    int roleIndex = 0;
    for (ListElement listElement : roles) {
        selectedRoles[roleIndex] = listElement.getId().toString();
        roleIndex++;
    }
    populatedBean.setSelectedRoles(selectedRoles);
    populatedBean.setUsername(personnelInformation.getUserName());
    List<CustomFieldDto> currentBeanFields = new ArrayList<CustomFieldDto>();
    List<CustomFieldDto> defaultBeanFields = populatedBean.getCustomFields();
    for (CustomFieldDto customFieldDto : defaultBeanFields) {
        CustomFieldDto matchingField = findMatchingAndSetFieldValue(customFieldDto, personnelInformation.getCustomFields());
        if (matchingField != null) {
            currentBeanFields.add(matchingField);
        }
    }
    populatedBean.setRecentNotes(personnelInformation.getRecentPersonnelNotes());
    populatedBean.setCustomFields(currentBeanFields);
    populatedBean.prepareForPreview();
    populatedBean.prepateForReEdit();
    return populatedBean;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ListElement(org.mifos.dto.screen.ListElement) PersonnelDetailsDto(org.mifos.dto.screen.PersonnelDetailsDto)

Example 29 with ListElement

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

the class SystemUserController method showBranchHierarchy.

@SuppressWarnings("PMD")
public OfficeHierarchyFormBean showBranchHierarchy() {
    OnlyBranchOfficeHierarchyDto hierarchy = this.officeServiceFacade.retrieveBranchOnlyOfficeHierarchy();
    List<BranchOnlyHierarchyBean> branchOnlyHierarchyList = new ArrayList<BranchOnlyHierarchyBean>();
    for (OfficeHierarchyDto office : hierarchy.getBranchOnlyOfficeHierarchy()) {
        BranchOnlyHierarchyBean branchOnlyHierarchyBean = new BranchOnlyHierarchyBean();
        branchOnlyHierarchyBean.setId(office.getOfficeId().intValue());
        branchOnlyHierarchyBean.setName(office.getOfficeName());
        List<ListElement> branches = new ArrayList<ListElement>();
        for (OfficeHierarchyDto child : office.getChildren()) {
            branches.add(new ListElement(child.getOfficeId().intValue(), child.getOfficeName()));
        }
        branchOnlyHierarchyBean.setChildren(branches);
        branchOnlyHierarchyList.add(branchOnlyHierarchyBean);
    }
    List<OfficeDto> nonBranchOffices = this.officeServiceFacade.retrieveAllNonBranchOfficesApplicableToLoggedInUser();
    List<ListElement> nonBranches = new ArrayList<ListElement>();
    for (OfficeDto office : nonBranchOffices) {
        nonBranches.add(new ListElement(office.getId().intValue(), office.getName()));
    }
    OfficeHierarchyFormBean bean = new OfficeHierarchyFormBean();
    bean.setNonBranches(nonBranches);
    bean.setBranchOnlyOfficeHierarchy(branchOnlyHierarchyList);
    return bean;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeDto(org.mifos.dto.domain.OfficeDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement)

Example 30 with ListElement

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

the class LoanProductFormBeanAssembler method populateInterestRateDropdown.

private void populateInterestRateDropdown(LoanProductFormDto loanProductRefData, LoanProductFormBean loanProductFormBean) {
    Map<String, String> interestRateCalculationTypeOptions = new LinkedHashMap<String, String>();
    for (ListElement interestCalculationType : loanProductRefData.getInterestCalculationTypes()) {
        interestRateCalculationTypeOptions.put(interestCalculationType.getId().toString(), interestCalculationType.getName());
    }
    loanProductFormBean.setInterestRateCalculationTypeOptions(interestRateCalculationTypeOptions);
}
Also used : ListElement(org.mifos.dto.screen.ListElement) LinkedHashMap(java.util.LinkedHashMap)

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