Search in sources :

Example 1 with CenterInformationDto

use of org.mifos.dto.domain.CenterInformationDto 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 CenterInformationDto

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

the class CenterCustAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterInformationDto centerInformationDto;
    try {
        centerInformationDto = this.centerServiceFacade.getCenterInformationDto(((CenterCustActionForm) form).getGlobalCustNum());
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    SessionUtils.removeThenSetAttribute("centerInformationDto", centerInformationDto, request);
    // John W - 'BusinessKey' attribute used by breadcrumb but is not in associated jsp
    CenterBO centerBO = (CenterBO) this.customerDao.findCustomerById(centerInformationDto.getCenterDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, centerBO, request);
    setCurrentPageUrl(request, centerBO);
    setQuestionGroupInstances(request, centerBO);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CenterInformationDto

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

the class ViewCustomerDetailsController method showCenterDetails.

@RequestMapping(value = "/viewCenterDetails", method = RequestMethod.GET)
public ModelAndView showCenterDetails(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewCenterDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String centerSystemId = request.getParameter("globalCustNum");
    CenterInformationDto centerInformationDto = this.centerServiceFacade.getCenterInformationDto(centerSystemId);
    modelAndView.addObject("centerInformationDto", centerInformationDto);
    modelAndView.addObject("currentPageUrl", UrlHelper.constructCurrentPageUrl(request));
    request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
    centerServiceFacade.putCenterBusinessKeyInSession(centerSystemId, request);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with CenterInformationDto

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

the class CenterActionStrutsTest method testGet.

@Test
public void testGet() throws Exception {
    setNonLoanOfficerMifosUser();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    savingsBO = getSavingsAccount("fsaf6", "ads6", center);
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", center.getGlobalCustNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.get_success.toString());
    CustomerBO centerBO = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Assert.assertNotNull(center);
    Assert.assertEquals(center.getCustomerId(), centerBO.getCustomerId());
    CenterInformationDto centerInformation = (CenterInformationDto) SessionUtils.getAttribute("centerInformationDto", request);
    List<CustomerDetailDto> children = centerInformation.getGroupsOtherThanClosedAndCancelled();
    Assert.assertNotNull(children);
    Assert.assertEquals(1, children.size());
    Assert.assertEquals("Size of the active accounts should be 1", 1, centerInformation.getSavingsAccountsInUse().size());
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Test(org.junit.Test)

Example 5 with CenterInformationDto

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

the class CenterRESTController method createCenter.

@RequestMapping(value = "/center/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createCenter(@RequestBody String request) throws Throwable {
    ObjectMapper om = createCenterMaping();
    CreateCenterDetailsDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateCenterDetailsDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    CenterCreationDetail center = createCenter(creationDetail);
    CustomerDetailsDto details = this.centerServiceFacade.createNewCenter(center, meetingBO.toDto());
    CenterInformationDto centerInfo = this.centerServiceFacade.getCenterInformationDto(details.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", centerInfo.getCenterDisplay().getGlobalCustNum());
    map.put("accountNum", centerInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("name", center.getDisplayName());
    map.put("externalId", center.getExternalId());
    map.put("mfiDate", center.getMfiJoiningDate().toString());
    map.put("address", center.getAddressDto().getDisplayAddress());
    map.put("city", center.getAddressDto().getCity());
    map.put("state", center.getAddressDto().getState());
    map.put("country", center.getAddressDto().getCountry());
    map.put("postal code", center.getAddressDto().getZip());
    map.put("phone", center.getAddressDto().getPhoneNumber());
    return map;
}
Also used : CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CreateCenterDetailsDto(org.mifos.application.servicefacade.CreateCenterDetailsDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CenterInformationDto (org.mifos.dto.domain.CenterInformationDto)5 CenterBO (org.mifos.customers.center.business.CenterBO)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)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 Test (org.junit.Test)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 CreateCenterDetailsDto (org.mifos.application.servicefacade.CreateCenterDetailsDto)1 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 CenterCustActionForm (org.mifos.customers.center.struts.actionforms.CenterCustActionForm)1 CenterCreationDetail (org.mifos.dto.domain.CenterCreationDetail)1