use of org.mifos.dto.screen.GroupInformationDto in project head by mifos.
the class GroupRESTController method createGroup.
@RequestMapping(value = "group/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createGroup(@RequestBody String request) throws Throwable {
ObjectMapper om = createGroupMapping();
CreateGroupCreationDetailDto creationDetail = null;
MeetingBO meetingBO = null;
try {
creationDetail = om.readValue(request, CreateGroupCreationDetailDto.class);
} catch (JsonMappingException e) {
throw e.getCause();
}
validate(creationDetail);
meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
GroupCreationDetail group = createGroup(creationDetail);
CustomerDetailsDto groupDetails = groupServiceFacade.createNewGroup(group, meetingBO.toDto());
GroupInformationDto groupInfo = groupServiceFacade.getGroupInformationDto(groupDetails.getGlobalCustNum());
Map<String, String> map = new HashMap<String, String>();
map.put("status", "success");
map.put("globalCusNum", groupInfo.getGroupDisplay().getGlobalCustNum());
map.put("accountNum", groupInfo.getCustomerAccountSummary().getGlobalAccountNum());
map.put("address", groupInfo.getAddress().getDisplayAddress());
map.put("city", groupInfo.getAddress().getCity());
map.put("state", groupInfo.getAddress().getState());
map.put("country", groupInfo.getAddress().getCountry());
map.put("postal code", groupInfo.getAddress().getZip());
map.put("phone", groupInfo.getAddress().getPhoneNumber());
map.put("dispalyName", groupInfo.getGroupDisplay().getDisplayName());
map.put("externalId", groupInfo.getGroupDisplay().getExternalId());
map.put("loanOfficer", groupInfo.getGroupDisplay().getLoanOfficerName());
return map;
}
use of org.mifos.dto.screen.GroupInformationDto 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.screen.GroupInformationDto in project head by mifos.
the class GroupCustAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In GroupCustAction get method ");
// John W - UserContext object passed because some status' need to be looked up for internationalisation based
// on UserContext info
String groupSystemId = ((GroupCustActionForm) form).getGlobalCustNum();
GroupInformationDto groupInformationDto;
try {
groupInformationDto = this.groupServiceFacade.getGroupInformationDto(groupSystemId);
} catch (MifosRuntimeException e) {
if (e.getCause() instanceof ApplicationException) {
throw (ApplicationException) e.getCause();
}
throw e;
}
SessionUtils.removeThenSetAttribute("groupInformationDto", groupInformationDto, request);
// John W - - not sure whether to leave these rules as is or do something else like bake the logic into the main
// dto and out of the jsp
SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
// John W - 'BusinessKey' attribute linked to GroupBo is still used by other actions (e.g. meeting related)
// further on and also breadcrumb.
GroupBO groupBO = (GroupBO) this.customerDao.findCustomerById(groupInformationDto.getGroupDisplay().getCustomerId());
SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, groupBO, request);
setCurrentPageUrl(request, groupBO);
setQuestionGroupInstances(request, groupBO);
logger.debug("Exiting GroupCustAction get method ");
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.dto.screen.GroupInformationDto in project head by mifos.
the class GroupActionStrutsTest method testGet.
@Ignore
@Test
public void testGet() throws Exception {
createCustomers();
CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(new PositionEntity((short) 1), client, client.getParentCustomer());
group.addCustomerPosition(customerPositionEntity);
savingsBO = getSavingsAccount("fsaf6", "ads6");
loanBO = getLoanAccount();
group.update();
StaticHibernateUtil.flushAndClearSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "get");
addRequestParameter("globalCustNum", group.getGlobalCustNum());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.get_success.toString());
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.getGroup(group.getCustomerId());
client = TestObjectFactory.getClient(client.getCustomerId());
loanBO = (LoanBO) legacyAccountDao.getAccount(loanBO.getAccountId());
savingsBO = (SavingsBO) legacyAccountDao.getAccount(savingsBO.getAccountId());
GroupInformationDto groupInformationDto = (GroupInformationDto) SessionUtils.getAttribute("groupInformationDto", request);
Assert.assertEquals("Size of active loan accounts should be 1", 1, groupInformationDto.getLoanAccountsInUse().size());
Assert.assertEquals("Size of active savings accounts should be 1", 1, groupInformationDto.getSavingsAccountsInUse().size());
Assert.assertEquals("No of active (or on hold) clients should be 1", "1", groupInformationDto.getGroupPerformanceHistory().getActiveClientCount());
Assert.assertEquals("No of clients that are not closed or cancelled should be 1", 1, groupInformationDto.getClientsOtherThanClosedAndCancelled().size());
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertEquals("Center Leader", customerPosition.getPosition().getName());
break;
}
TestObjectFactory.removeCustomerFromPosition(group);
StaticHibernateUtil.flushAndClearSession();
center = TestObjectFactory.getCenter(Integer.valueOf(center.getCustomerId()).intValue());
group = TestObjectFactory.getGroup(Integer.valueOf(group.getCustomerId()).intValue());
client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
loanBO = (LoanBO) legacyAccountDao.getAccount(loanBO.getAccountId());
savingsBO = (SavingsBO) legacyAccountDao.getAccount(savingsBO.getAccountId());
}
use of org.mifos.dto.screen.GroupInformationDto in project head by mifos.
the class ViewCustomerDetailsController method showGroupDetails.
@RequestMapping(value = "/viewGroupDetails", method = RequestMethod.GET)
public ModelAndView showGroupDetails(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
sitePreferenceHelper.resolveSiteType(modelAndView, "viewGroupDetails", request);
modelAndView.addObject("include_page", new IncludePage(request, response));
String groupSystemId = request.getParameter("globalCustNum");
GroupInformationDto groupInformationDto = this.groupServiceFacade.getGroupInformationDto(groupSystemId);
modelAndView.addObject("groupInformationDto", groupInformationDto);
boolean isGroupLoanAllowed = configurationServiceFacade.getBooleanConfig("ClientRules.GroupCanApplyLoans");
modelAndView.addObject("isGroupLoanAllowed", isGroupLoanAllowed);
boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
modelAndView.addObject("currentPageUrl", UrlHelper.constructCurrentPageUrl(request));
request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
groupServiceFacade.putGroupBusinessKeyInSession(groupSystemId, request);
return modelAndView;
}
Aggregations