use of org.mifos.dto.domain.CustomerPositionOtherDto in project head by mifos.
the class CenterServiceFacadeWebTier method getCenterInformationDto.
@Override
public CenterInformationDto getCenterInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CenterBO center = customerDao.findCenterBySystemId(globalCustNum);
if (center == null) {
throw new MifosRuntimeException("Center not found for globalCustNum" + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
CenterDisplayDto centerDisplay = customerDao.getCenterDisplayDto(center.getCustomerId(), userContext);
Integer centerId = center.getCustomerId();
String searchId = center.getSearchId();
Short branchId = centerDisplay.getBranchId();
CustomerAccountSummaryDto customerAccountSummary = customerDao.getCustomerAccountSummaryDto(centerId);
CenterPerformanceHistoryDto centerPerformanceHistory = customerDao.getCenterPerformanceHistory(searchId, branchId);
CustomerAddressDto centerAddress = customerDao.getCustomerAddressDto(center);
List<CustomerDetailDto> groups = customerDao.getGroupsOtherThanClosedAndCancelledForGroup(searchId, branchId);
List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(centerId);
List<CustomerPositionOtherDto> customerPositions = customerDao.getCustomerPositionDto(centerId, userContext);
List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(centerId, userContext);
CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(center.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(centerId);
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.SAVINGS_ACCOUNT.getValue().intValue()) {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
//new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);
Boolean activeSurveys = Boolean.FALSE;
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
return new CenterInformationDto(centerDisplay, customerAccountSummary, centerPerformanceHistory, centerAddress, groups, recentCustomerNotes, customerPositions, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedSavingsAccounts);
}
use of org.mifos.dto.domain.CustomerPositionOtherDto in project head by mifos.
the class CustomerUIHelperFn method getClientPosition.
public static String getClientPosition(Object customerPositions, Object customer) {
logger.debug("Inside UI helper function getClientPositions");
StringBuilder stringBuilder = new StringBuilder();
if (customerPositions != null && customer != null) {
logger.debug("Iterating over customerPositions list");
List<CustomerPositionOtherDto> customerPositionList = (List<CustomerPositionOtherDto>) customerPositions;
String[] positionNames = new String[customerPositionList.size()];
int i = 0;
for (CustomerPositionOtherDto customerPosition : customerPositionList) {
CustomerDetailDto customerDetails = (CustomerDetailDto) customer;
if (null != customerPosition && customerPosition.getCustomerId() != null && customerDetails != null) {
if (customerPosition.getCustomerId().equals((customerDetails).getCustomerId())) {
String posName = customerPosition.getPositionName();
logger.debug("The position name is " + posName);
positionNames[i] = posName;
i++;
}
}
}
for (; i < positionNames.length; i++) {
positionNames[i] = null;
}
stringBuilder.append("(");
for (int j = 0; j < positionNames.length; j++) {
if (positionNames[j] != null && positionNames[j] != "") {
stringBuilder.append(positionNames[j]);
}
if (j + 1 < positionNames.length && positionNames[j + 1] != null && positionNames[j + 1] != "") {
stringBuilder.append(",");
}
}
stringBuilder.append(")");
}
if (stringBuilder.toString().equals("()")) {
return "";
}
return stringBuilder.toString();
}
use of org.mifos.dto.domain.CustomerPositionOtherDto in project head by mifos.
the class GroupServiceFacadeWebTier method getGroupInformationDto.
// private void checkPermissionForCreate(Short newState, UserContext userContext, Short recordOfficeId,
// Short recordLoanOfficerId) throws ApplicationException {
// if (!isPermissionAllowed(newState, userContext, recordOfficeId, recordLoanOfficerId)) {
// logger.info("permission not allowed: " + userContext.toString() + " officeId: " + recordLoanOfficerId + " loanOfficerId: " + recordLoanOfficerId);
// throw new AccountException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
// }
// }
// private boolean isPermissionAllowed(Short newState, UserContext userContext, Short recordOfficeId,
// Short recordLoanOfficerId) {
// return ActivityMapper.getInstance().isSavePermittedForCustomer(newState.shortValue(), userContext,
// recordOfficeId, recordLoanOfficerId);
// }
@Override
public GroupInformationDto getGroupInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
if (group == null) {
throw new MifosRuntimeException("Group not found for globalCustNum: " + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
GroupDisplayDto groupDisplay = this.customerDao.getGroupDisplayDto(group.getCustomerId(), userContext);
Integer groupId = group.getCustomerId();
String searchId = group.getSearchId();
Short branchId = groupDisplay.getBranchId();
CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(groupId);
GroupPerformanceHistoryDto groupPerformanceHistory = assembleGroupPerformanceHistoryDto(group.getGroupPerformanceHistory(), searchId, branchId, groupId);
CustomerAddressDto groupAddress = this.customerDao.getCustomerAddressDto(group);
List<CustomerDetailDto> clients = this.customerDao.findClientsThatAreNotCancelledOrClosedReturningDetailDto(searchId, branchId);
List<CustomerNoteDto> recentCustomerNotes = this.customerDao.getRecentCustomerNoteDto(groupId);
List<CustomerPositionOtherDto> customerPositions = this.customerDao.getCustomerPositionDto(groupId, userContext);
List<CustomerFlagDto> customerFlags = this.customerDao.getCustomerFlagDto(group.getCustomerFlags());
List<LoanDetailDto> loanDetail = this.customerDao.getLoanDetailDto(group.getOpenLoanAccountsAndGroupLoans());
List<SavingsDetailDto> savingsDetail = this.customerDao.getSavingsDetailDto(groupId, userContext);
CustomerMeetingDto customerMeeting = this.customerDao.getCustomerMeetingDto(group.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(groupId);
List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
} else {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
boolean activeSurveys = false;
// boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.GROUP);
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
return new GroupInformationDto(groupDisplay, customerAccountSummary, groupPerformanceHistory, groupAddress, clients, recentCustomerNotes, customerPositions, customerFlags, loanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedLoanAccounts, closedSavingsAccounts);
}
use of org.mifos.dto.domain.CustomerPositionOtherDto in project head by mifos.
the class CustomerDaoHibernate method getCustomerPositionDto.
@SuppressWarnings("unchecked")
@Override
public List<CustomerPositionOtherDto> getCustomerPositionDto(final Integer parentId, final UserContext userContext) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("PARENT_ID", parentId);
List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Customer.getCustomerPositionDto", queryParameters);
if (queryResult.size() == 0) {
return null;
}
List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
String lookupName;
Integer customerId;
String customerDisplayName;
String positionName;
for (Object[] customerPosition : queryResult) {
lookupName = (String) customerPosition[0];
customerId = (Integer) customerPosition[1];
customerDisplayName = (String) customerPosition[2];
positionName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
customerPositions.add(new CustomerPositionOtherDto(positionName, customerId, customerDisplayName));
}
return customerPositions;
}
use of org.mifos.dto.domain.CustomerPositionOtherDto in project head by mifos.
the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsNotAssignedPosition.
@Test
public void testUIHelperWhenClientIsNotAssignedPosition() throws CustomerException, PageExpiredException {
createInitialObjects();
PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
group.addCustomerPosition(customerPositionEntity);
group.update();
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
group.setUserContext(TestObjectFactory.getContext());
CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
}
String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
Assert.assertEquals("(Center Leader)", positionName);
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", client.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "6");
addRequestParameter("flagId", "7");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNotNull(customerPosition.getCustomer());
break;
}
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.client_detail_page.toString());
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
Assert.assertFalse(client.isActive());
for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
break;
}
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNull(customerPosition.getCustomer());
break;
}
}
Aggregations