Search in sources :

Example 1 with GroupDisplayDto

use of org.mifos.dto.screen.GroupDisplayDto 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);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) GroupDisplayDto(org.mifos.dto.screen.GroupDisplayDto) ArrayList(java.util.ArrayList) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) CustomerFlagDto(org.mifos.dto.domain.CustomerFlagDto) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) GroupPerformanceHistoryDto(org.mifos.dto.screen.GroupPerformanceHistoryDto) AccountException(org.mifos.accounts.exceptions.AccountException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with GroupDisplayDto

use of org.mifos.dto.screen.GroupDisplayDto in project head by mifos.

the class CustomerDaoHibernate method getGroupDisplayDto.

@SuppressWarnings("unchecked")
@Override
public GroupDisplayDto getGroupDisplayDto(Integer groupId, UserContext userContext) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("GROUP_ID", groupId);
    List<Object[]> queryResult = (List<Object[]>) genericDao.executeNamedQuery("getGroupDisplayDto", queryParameters);
    if (queryResult.size() == 0) {
        throw new MifosRuntimeException("Group not found: " + groupId);
    }
    if (queryResult.size() > 1) {
        throw new MifosRuntimeException("Error finding Group id: " + groupId + " - Number found: " + queryResult.size());
    }
    final Integer customerId = (Integer) queryResult.get(0)[0];
    final String globalCustNum = (String) queryResult.get(0)[1];
    final String displayName = (String) queryResult.get(0)[2];
    final String parentCustomerDisplayName = (String) queryResult.get(0)[3];
    final Short branchId = (Short) queryResult.get(0)[4];
    final String externalId = (String) queryResult.get(0)[5];
    final String customerFormedByDisplayName = (String) queryResult.get(0)[6];
    final Date customerActivationDate = (Date) queryResult.get(0)[7];
    final Short customerLevelId = (Short) queryResult.get(0)[8];
    final Short customerStatusId = (Short) queryResult.get(0)[9];
    final String lookupName = (String) queryResult.get(0)[10];
    final Boolean trained = (Boolean) queryResult.get(0)[11];
    final Date trainedDate = (Date) queryResult.get(0)[12];
    final Boolean blackListed = (Boolean) queryResult.get(0)[13];
    final Short loanOfficerId = (Short) queryResult.get(0)[14];
    final String loanOfficerName = (String) queryResult.get(0)[15];
    final String customerStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
    return new GroupDisplayDto(customerId, globalCustNum, displayName, parentCustomerDisplayName, branchId, externalId, customerFormedByDisplayName, customerActivationDate, customerLevelId, customerStatusId, customerStatusName, trained, trainedDate, blackListed, loanOfficerId, loanOfficerName);
}
Also used : HashMap(java.util.HashMap) GroupDisplayDto(org.mifos.dto.screen.GroupDisplayDto) Date(java.util.Date) BigInteger(java.math.BigInteger) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) List(java.util.List) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ArrayList (java.util.ArrayList)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 GroupDisplayDto (org.mifos.dto.screen.GroupDisplayDto)2 BigInteger (java.math.BigInteger)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 MessageLookup (org.mifos.application.master.MessageLookup)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)1 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 CustomerFlagDto (org.mifos.dto.domain.CustomerFlagDto)1 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)1 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)1 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)1