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