Search in sources :

Example 1 with BranchReportStaffingLevelSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO in project head by mifos.

the class BranchReportStaffingLevelSummaryHelperIntegrationTest method assertStaffingLevelSummaries.

private void assertStaffingLevelSummaries(BranchReportBO branchReport) {
    Set<BranchReportStaffingLevelSummaryBO> staffingLevelSummaries = branchReport.getStaffingLevelSummaries();
    Assert.assertEquals(1, staffingLevelSummaries.size());
    Collection retrievedRolenames = CollectionUtils.collect(staffingLevelSummaries, new Transformer() {

        @Override
        public Object transform(Object input) {
            return ((BranchReportStaffingLevelSummaryBO) input).getTitleName();
        }
    });
    Assert.assertEquals(1, retrievedRolenames.size());
    Assert.assertTrue(retrievedRolenames.contains(BranchReportStaffingLevelSummaryBO.TOTAL_STAFF_ROLE_NAME));
}
Also used : Transformer(org.apache.commons.collections.Transformer) Collection(java.util.Collection) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO)

Example 2 with BranchReportStaffingLevelSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO in project head by mifos.

the class BranchReportPersistenceIntegrationTest method testExtractStaffingSummaryLevels.

@Test
public void testExtractStaffingSummaryLevels() throws Exception {
    List<BranchReportStaffingLevelSummaryBO> staffingLevels = branchReportPersistence.extractBranchReportStaffingLevelSummary(LOAN_OFFICER_ID_SHORT);
    Assert.assertEquals(2, staffingLevels.size());
    Assert.assertNull("Should not extract roles with zero personnel count", org.apache.commons.collections.CollectionUtils.find(staffingLevels, new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            BranchReportStaffingLevelSummaryBO summary = (BranchReportStaffingLevelSummaryBO) arg0;
            return !TOTAL_STAFF_ROLENAME_STR.equals(summary.getTitleName()) && Integer.valueOf(0).equals((summary).getPersonnelCount());
        }
    }));
    for (BranchReportStaffingLevelSummaryBO summaryBO : staffingLevels) {
        if (TOTAL_STAFF_ROLENAME_STR.equals(summaryBO.getTitleName())) {
            Assert.assertEquals(Integer.valueOf(2), summaryBO.getPersonnelCount());
        }
    }
}
Also used : BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Example 3 with BranchReportStaffingLevelSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO in project head by mifos.

the class BranchReportPersistence method extractBranchReportStaffingLevelSummary.

public List<BranchReportStaffingLevelSummaryBO> extractBranchReportStaffingLevelSummary(Short branchId) throws PersistenceException {
    List<BranchReportStaffingLevelSummaryBO> staffingLevelSummaries = new ArrayList<BranchReportStaffingLevelSummaryBO>();
    List<Object[]> resultSet = executeNamedQuery("branchReport.extractStaffingLevelSummaryForBranchByTitle", populateQueryParams(branchId));
    int totalStaff = 0;
    for (Object[] result : resultSet) {
        int staffCountForThisTitle = (Integer) result[0];
        String messageKeyForTitleName = (String) result[1];
        String messageValueOverrideForTitleName = (String) result[2];
        String titleName = "No Title";
        if (messageValueOverrideForTitleName != null) {
            titleName = messageValueOverrideForTitleName;
        } else if (messageKeyForTitleName != null) {
            titleName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(messageKeyForTitleName);
        }
        totalStaff += staffCountForThisTitle;
        staffingLevelSummaries.add(new BranchReportStaffingLevelSummaryBO(IS_NOT_TOTAL, titleName, staffCountForThisTitle));
    }
    staffingLevelSummaries.add(new BranchReportStaffingLevelSummaryBO(IS_TOTAL, TOTAL_STAFF_ROLE_NAME, totalStaff));
    return staffingLevelSummaries;
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO)

Example 4 with BranchReportStaffingLevelSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO in project head by mifos.

the class BranchReportServiceIntegrationTest method testResultsForStaffingLevelAreSorted.

@Test
public void testResultsForStaffingLevelAreSorted() throws PersistenceException, ServiceException {
    BranchReportPersistence branchReportPersistenceMock = createMock(BranchReportPersistence.class);
    branchReportService = new BranchReportService(officeBusinessServiceMock, new PersonnelBusinessService(), branchReportPersistenceMock);
    ArrayList<BranchReportStaffingLevelSummaryBO> staffingLevelResult = new ArrayList<BranchReportStaffingLevelSummaryBO>();
    BranchReportStaffingLevelSummaryBO totalStaffSummaryBO = new BranchReportStaffingLevelSummaryBO(IS_TOTAL, "A", 1);
    staffingLevelResult.add(totalStaffSummaryBO);
    staffingLevelResult.add(new BranchReportStaffingLevelSummaryBO(IS_NOT_TOTAL, "A", 1));
    staffingLevelResult.add(new BranchReportStaffingLevelSummaryBO(IS_NOT_TOTAL, "B", 1));
    expect(branchReportPersistenceMock.getBranchReportStaffingLevelSummary(BRANCH_ID_SHORT, RUN_DATE)).andReturn(staffingLevelResult);
    replay(branchReportPersistenceMock);
    List<BranchReportStaffingLevelSummaryBO> retrievedStaffingLevel = branchReportService.getStaffingLevelSummary(BRANCH_ID, RUN_DATE_STR);
    verify(branchReportPersistenceMock);
    BranchReportStaffingLevelSummaryBO lastBO = null;
    for (BranchReportStaffingLevelSummaryBO summaryBO : retrievedStaffingLevel) {
        if (lastBO != null) {
            Assert.assertEquals(1, summaryBO.compareTo(lastBO));
        }
        lastBO = summaryBO;
    }
    Assert.assertEquals(0, totalStaffSummaryBO.compareTo(lastBO));
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ArrayList(java.util.ArrayList) BranchReportPersistence(org.mifos.reports.branchreport.persistence.BranchReportPersistence) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) Test(org.junit.Test)

Example 5 with BranchReportStaffingLevelSummaryBO

use of org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO in project head by mifos.

the class BranchReportService method getStaffingLevelSummary.

@Override
public List<BranchReportStaffingLevelSummaryBO> getStaffingLevelSummary(Integer branchId, String runDate) throws ServiceException {
    try {
        List<BranchReportStaffingLevelSummaryBO> staffingLevelSummary = branchReportPersistence.getBranchReportStaffingLevelSummary(convertIntegerToShort(branchId), ReportUtils.parseReportDate(runDate));
        Collections.sort(staffingLevelSummary);
        return staffingLevelSummary;
    } catch (PersistenceException e) {
        throw new ServiceException(e);
    } catch (ParseException e) {
        throw new ServiceException(e);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) ParseException(java.text.ParseException)

Aggregations

BranchReportStaffingLevelSummaryBO (org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO)5 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ParseException (java.text.ParseException)1 Collection (java.util.Collection)1 Predicate (org.apache.commons.collections.Predicate)1 Transformer (org.apache.commons.collections.Transformer)1 MessageLookup (org.mifos.application.master.MessageLookup)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 BranchReportPersistence (org.mifos.reports.branchreport.persistence.BranchReportPersistence)1