Search in sources :

Example 1 with CenterDisplayDto

use of org.mifos.dto.domain.CenterDisplayDto 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);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) CenterPerformanceHistoryDto(org.mifos.dto.domain.CenterPerformanceHistoryDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) AccountException(org.mifos.accounts.exceptions.AccountException) CenterDisplayDto(org.mifos.dto.domain.CenterDisplayDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with CenterDisplayDto

use of org.mifos.dto.domain.CenterDisplayDto in project head by mifos.

the class CustomerDaoHibernate method getCenterDisplayDto.

@SuppressWarnings("unchecked")
@Override
public CenterDisplayDto getCenterDisplayDto(Integer centerId, UserContext userContext) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("CENTER_ID", centerId);
    List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("getCenterDisplayDto", queryParameters);
    if (queryResult.size() == 0) {
        throw new MifosRuntimeException("Center not found: " + centerId);
    }
    if (queryResult.size() > 1) {
        throw new MifosRuntimeException("Error finding Center id: " + centerId + " - 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 Short branchId = (Short) queryResult.get(0)[3];
    final Date mfiJoiningDate = (Date) queryResult.get(0)[4];
    final Date createdDate = (Date) queryResult.get(0)[5];
    final Integer versionNo = (Integer) queryResult.get(0)[6];
    final String externalId = (String) 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 Short loanOfficerId = (Short) queryResult.get(0)[11];
    final String loanOfficerName = (String) queryResult.get(0)[12];
    final String customerStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
    return new CenterDisplayDto(customerId, globalCustNum, displayName, branchId, mfiJoiningDate, createdDate, versionNo, externalId, customerLevelId, customerStatusId, customerStatusName, loanOfficerId, loanOfficerName);
}
Also used : BigInteger(java.math.BigInteger) CenterDisplayDto(org.mifos.dto.domain.CenterDisplayDto) HashMap(java.util.HashMap) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ArrayList (java.util.ArrayList)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CenterDisplayDto (org.mifos.dto.domain.CenterDisplayDto)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 MessageLookup (org.mifos.application.master.MessageLookup)1 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CenterInformationDto (org.mifos.dto.domain.CenterInformationDto)1 CenterPerformanceHistoryDto (org.mifos.dto.domain.CenterPerformanceHistoryDto)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 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)1 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)1