Search in sources :

Example 11 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLoanOfficersAndPreviouslyPopulatedDataWithDto.

@SuppressWarnings("unchecked")
@Test
public void shouldPopulateDtoWithLoanOfficersAndPreviouslyPopulatedDataWithDto() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    final OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    final List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final ListItem<Short> paymentType1 = new ListItem<Short>(Short.valueOf("1"), "paymentType1");
    final CollectionSheetEntryFormDto previousCollectionSheetFormDto = new CollectionSheetEntryFormDto(onlyOneActiveBranch, Arrays.<ListItem<Short>>asList(paymentType1), new ArrayList<PersonnelDto>(), new ArrayList<CustomerDto>(), Constants.YES, Constants.YES, Constants.YES);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    final PersonnelDto loanOfficer2 = new PersonnelDto(Short.valueOf("2"), "LoanOfficer2");
    final List<PersonnelDto> loanOfficers = Arrays.asList(loanOfficer1, loanOfficer2);
    // stub interaction with DAO/Persistence layer.
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(loanOfficers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadLoanOfficersForBranch(branchId, userContext, previousCollectionSheetFormDto);
    // verification
    assertThat(formDto.getLoanOfficerList(), is(loanOfficers));
    // assert rest of data comes from previousDto
    assertThat(formDto.getActiveBranchesList(), is(previousCollectionSheetFormDto.getActiveBranchesList()));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Example 12 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class PentahoParamParser method updatePossibleValuesForParam.

private Map<String, String> updatePossibleValuesForParam(ListParameter paramDefEntry, ParameterContext paramContext, Map<String, AbstractPentahoParameter> selectedValues) throws ReportDataFactoryException {
    Map<String, String> result = new HashMap<String, String>();
    String id;
    if (parameterIsOffice(paramDefEntry.getName())) {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    } else if (parameterIsCenter(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer$)|(.*officer_id$)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderUser(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            keyValue = searchKey("(selected_office$)|(.*BRANCH_NAME.*)", selectedValues, paramDefEntry.getName());
            if (!keyValue.equals("")) {
                id = (String) selectedValues.get(keyValue).getParamValue();
                if (!id.equals("-1")) {
                    List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderBranch(new Short(id));
                    for (CustomerDetailDto office : customerList) {
                        String key = office.getCustomerId().toString();
                        String value = office.getDisplayName();
                        result.put(key, value);
                    }
                } else {
                    ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                    for (int i = 0; i < paramValues.getRowCount(); i++) {
                        String key = String.valueOf(paramValues.getKeyValue(i));
                        String value = String.valueOf(paramValues.getTextValue(i));
                        result.put(key, value);
                    }
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsGroup(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*officer*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveGroupForPentahoReport(new Short(id));
                for (CustomerDetailDto office : customerList) {
                    String key = office.getCustomerId().toString();
                    String value = office.getDisplayName();
                    result.put(key, value);
                }
            } else {
                ParameterValues paramValues = paramDefEntry.getValues(paramContext);
                for (int i = 0; i < paramValues.getRowCount(); i++) {
                    String key = String.valueOf(paramValues.getKeyValue(i));
                    String value = String.valueOf(paramValues.getTextValue(i));
                    result.put(key, value);
                }
            }
        } else {
            ParameterValues paramValues = paramDefEntry.getValues(paramContext);
            for (int i = 0; i < paramValues.getRowCount(); i++) {
                String key = String.valueOf(paramValues.getKeyValue(i));
                String value = String.valueOf(paramValues.getTextValue(i));
                result.put(key, value);
            }
        }
        String key = "-1";
        String value = "All";
        result.put(key, value);
    } else if (parameterIsOfficer(paramDefEntry.getName())) {
        String keyValue = searchKey("(.*office$)|(.*office_id$)|(.*branch_id$)|(.*office$)|(.*selectedBranch.*)", selectedValues, paramDefEntry.getName());
        if (!keyValue.equals("")) {
            id = (String) selectedValues.get(keyValue).getParamValue();
            if (!id.equals("-1")) {
                ChangeAccountStatusDto changeAccountStatusDto = ApplicationContextProvider.getBean(LoanAccountServiceFacade.class).retrieveLoanOfficerDetailsForBranch(new Short(id));
                List<PersonnelDto> officers = changeAccountStatusDto.getLoanOfficers();
                for (PersonnelDto officer : officers) {
                    String key = officer.getPersonnelId().toString();
                    String value = officer.getDisplayName();
                    result.put(key, value);
                }
            }
            String key = "-1";
            String value = "All";
            result.put(key, value);
        }
    } else {
        ParameterValues paramValues = paramDefEntry.getValues(paramContext);
        for (int i = 0; i < paramValues.getRowCount(); i++) {
            String key = String.valueOf(paramValues.getKeyValue(i));
            String value = String.valueOf(paramValues.getTextValue(i));
            result.put(key, value);
        }
    }
    return result;
}
Also used : ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) HashMap(java.util.HashMap) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) ArrayList(java.util.ArrayList) List(java.util.List) ParameterValues(org.pentaho.reporting.engine.classic.core.parameters.ParameterValues) CenterServiceFacade(org.mifos.application.servicefacade.CenterServiceFacade)

Example 13 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.

@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
    final Short branchId = userContext.getBranchId();
    final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
    List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
    Short reloadFormAutomatically = Constants.YES;
    final Short backDatedTransactionAllowed = Constants.NO;
    try {
        final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
        paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
        activeBranches = officePersistence.getActiveOffices(branchId);
        if (activeBranches.size() == 1) {
            loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
            if (loanOfficerList.size() == 1) {
                Short customerLevel;
                if (centerHierarchyExists.equals(Constants.YES)) {
                    customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
                } else {
                    customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
                }
                customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
                if (customerList.size() == 1) {
                    reloadFormAutomatically = Constants.YES;
                }
                reloadFormAutomatically = Constants.NO;
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 14 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class ClientServiceFacadeWebTier method retrieveMfiInfoForEdit.

@Override
public ClientMfiInfoDto retrieveMfiInfoForEdit(String clientSystemId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    String groupDisplayName = "";
    String centerDisplayName = "";
    if (client.getParentCustomer() != null) {
        groupDisplayName = client.getParentCustomer().getDisplayName();
        if (client.getParentCustomer().getParentCustomer() != null) {
            centerDisplayName = client.getParentCustomer().getParentCustomer().getDisplayName();
        }
    }
    List<PersonnelDto> loanOfficersList = new ArrayList<PersonnelDto>();
    if (!client.isClientUnderGroup()) {
        CenterCreation centerCreation = new CenterCreation(client.getOffice().getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        loanOfficersList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    }
    CustomerDetailDto customerDetail = client.toCustomerDetailDto();
    ClientDetailDto clientDetail = client.toClientDetailDto(ClientRules.isFamilyDetailsRequired());
    return new ClientMfiInfoDto(groupDisplayName, centerDisplayName, loanOfficersList, customerDetail, clientDetail);
}
Also used : UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) ClientBO(org.mifos.customers.client.business.ClientBO) ClientDetailDto(org.mifos.dto.screen.ClientDetailDto) ArrayList(java.util.ArrayList) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ClientMfiInfoDto(org.mifos.dto.screen.ClientMfiInfoDto)

Example 15 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.

@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
        client.updateDetails(userContext);
        client.checkIfClientIsATitleHolder();
        List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
        boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
        boolean isActive = client.isActive();
        Short loanOfficerId = client.getPersonnel().getPersonnelId();
        CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
        return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ClientRemovalFromGroupDto(org.mifos.dto.screen.ClientRemovalFromGroupDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) BusinessRuleException(org.mifos.service.BusinessRuleException) CenterCreation(org.mifos.dto.domain.CenterCreation)

Aggregations

PersonnelDto (org.mifos.dto.domain.PersonnelDto)27 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)19 ArrayList (java.util.ArrayList)15 CustomerDto (org.mifos.dto.domain.CustomerDto)12 MifosUser (org.mifos.security.MifosUser)9 UserContext (org.mifos.security.util.UserContext)9 CenterCreation (org.mifos.dto.domain.CenterCreation)8 Date (java.util.Date)7 Test (org.junit.Test)7 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)5 DateTime (org.joda.time.DateTime)4 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)3 ProductDto (org.mifos.application.servicefacade.ProductDto)3