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));
}
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());
}
}
}
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;
}
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));
}
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);
}
}
Aggregations