Search in sources :

Example 1 with GroupInformationDto

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;
}
Also used : HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) CreateGroupCreationDetailDto(org.mifos.application.servicefacade.CreateGroupCreationDetailDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with GroupInformationDto

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);
}
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 3 with GroupInformationDto

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());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) GroupBO(org.mifos.customers.group.business.GroupBO) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with GroupInformationDto

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());
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with GroupInformationDto

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;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

GroupInformationDto (org.mifos.dto.screen.GroupInformationDto)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 GroupBO (org.mifos.customers.group.business.GroupBO)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 IncludePage (freemarker.ext.servlet.IncludePage)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CreateGroupCreationDetailDto (org.mifos.application.servicefacade.CreateGroupCreationDetailDto)1 CustomerPositionEntity (org.mifos.customers.business.CustomerPositionEntity)1 PositionEntity (org.mifos.customers.business.PositionEntity)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1