Search in sources :

Example 1 with OfficeBusinessService

use of org.mifos.customers.office.business.service.OfficeBusinessService in project head by mifos.

the class GroupCustAction method search.

@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    UserContext userContext = getUserContext(request);
    ActionForward actionForward = super.search(mapping, form, request, response);
    String searchString = actionForm.getSearchString();
    if (searchString == null) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    addSeachValues(searchString, userContext.getBranchId().toString(), new OfficeBusinessService().getOffice(userContext.getBranchId()).getOfficeName(), request);
    final String normalizedSearchString = SearchUtils.normalizeSearchString(searchString);
    if (normalizedSearchString.equals("")) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    boolean searchForAddingClientsToGroup = (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_ADD_CLIENTS_TO_GROUPS));
    GroupSearchResultsDto searchResult = this.customerServiceFacade.searchGroups(searchForAddingClientsToGroup, normalizedSearchString, userContext.getId());
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResults(), request);
    if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
        return mapping.findForward(ActionForwards.transferSearch_success.toString());
    } else if (searchForAddingClientsToGroup) {
        SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchForAddingClientToGroupResults(), request);
        return mapping.findForward(ActionForwards.addGroupSearch_success.toString());
    } else {
        return actionForward;
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) UserContext(org.mifos.security.util.UserContext) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with OfficeBusinessService

use of org.mifos.customers.office.business.service.OfficeBusinessService in project head by mifos.

the class BranchReportHelperIntegrationTest method testBatchCreatesRowForBranchReportBatchBO.

@Test
public void testBatchCreatesRowForBranchReportBatchBO() throws PersistenceException, ServiceException, BatchJobException {
    branchReportHelper = new BranchReportHelper();
    OfficeBO office = new OfficeBusinessService().getOffice(BRANCH_ID_SHORT);
    BranchReportBO generatedBranchReport = branchReportHelper.createBranchReport(session, office, RUN_DATE);
    IBranchReportService branchReportService = new BranchReportService();
    BranchReportBO retrievedBranchReports = branchReportService.getBranchReport(BRANCH_ID_SHORT, RUN_DATE);
    assertBranchReport(generatedBranchReport, retrievedBranchReports);
    assertClientSummaryReport(generatedBranchReport.getClientSummaries(), branchReportService);
    assertLoanArrearsAging(generatedBranchReport.getLoanArrearsAging(), branchReportService);
    assertStaffSummary(generatedBranchReport.getStaffSummaries(), branchReportService);
    assertStaffingLevelSummary(generatedBranchReport.getStaffingLevelSummaries(), branchReportService);
    assertLoanDetails(generatedBranchReport.getLoanDetails(), branchReportService);
    assertLoanArrearsProfile(generatedBranchReport.getLoanArrearsProfile(), branchReportService);
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) BranchReportBO(org.mifos.reports.branchreport.BranchReportBO) IBranchReportService(org.mifos.reports.business.service.IBranchReportService) BranchReportService(org.mifos.reports.business.service.BranchReportService) IBranchReportService(org.mifos.reports.business.service.IBranchReportService) Test(org.junit.Test)

Aggregations

OfficeBusinessService (org.mifos.customers.office.business.service.OfficeBusinessService)2 ActionForward (org.apache.struts.action.ActionForward)1 Test (org.junit.Test)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 BranchReportBO (org.mifos.reports.branchreport.BranchReportBO)1 BranchReportService (org.mifos.reports.business.service.BranchReportService)1 IBranchReportService (org.mifos.reports.business.service.IBranchReportService)1 UserContext (org.mifos.security.util.UserContext)1