Search in sources :

Example 1 with CenterDto

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

the class GroupServiceFacadeWebTier method retrieveGroupDetailsForUpdate.

@Override
public CenterDto retrieveGroupDetailsForUpdate(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    List<PersonnelDto> activeLoanOfficersForBranch = new ArrayList<PersonnelDto>();
    GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
    Short officeId = group.getOffice().getOfficeId();
    String searchId = group.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(group);
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (!isCenterHierarchyExists) {
        CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    }
    List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
    List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(group, userContext.getLocaleId());
    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (group.getMfiJoiningDate() != null) {
        mfiJoiningDate = new DateTime(group.getMfiJoiningDate());
        mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), group.getMfiJoiningDate().toString());
    }
    AddressDto address = null;
    if (group.getAddress() != null) {
        address = Address.toDto(group.getAddress());
    }
    return new CenterDto(loanOfficerId, group.getCustomerId(), group.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, group.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, isCenterHierarchyExists);
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) CenterDto(org.mifos.dto.domain.CenterDto) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CenterCreation(org.mifos.dto.domain.CenterCreation) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 2 with CenterDto

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

the class CenterCustAction method manage.

// NOTE edit center details
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    actionForm.clearActionFormFields();
    CenterBO center = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    final Integer centerId = center.getCustomerId();
    center = this.customerDao.findCenterBySystemId(center.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, null, request);
    CenterDto centerDto = this.centerServiceFacade.retrieveCenterDetailsForUpdate(centerId);
    actionForm.setLoanOfficerId(centerDto.getLoanOfficerIdAsString());
    actionForm.setCustomerId(centerDto.getCustomerIdAsString());
    actionForm.setGlobalCustNum(centerDto.getGlobalCustNum());
    actionForm.setExternalId(centerDto.getExternalId());
    actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDateAsString());
    actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDate().getDayOfMonth(), centerDto.getMfiJoiningDate().getMonthOfYear(), centerDto.getMfiJoiningDate().getYear());
    actionForm.setAddress(center.getAddress());
    actionForm.setCustomerPositions(centerDto.getCustomerPositionViews());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, center, request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerDto.getActiveLoanOfficersForBranch(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, centerDto.getCustomerPositionViews(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, centerDto.getClientList(), request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CenterBO(org.mifos.customers.center.business.CenterBO) CenterDto(org.mifos.dto.domain.CenterDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CenterDto

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

the class CenterServiceFacadeWebTier method retrieveCenterDetailsForUpdate.

@Override
public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO center = customerDao.findCustomerById(centerId);
    Short officeId = center.getOffice().getOfficeId();
    String searchId = center.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(center);
    CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
    List<PersonnelDto> activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
    List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(center, userContext.getLocaleId());
    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (center.getMfiJoiningDate() != null) {
        mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
        mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
    }
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    return new CenterDto(loanOfficerId, center.getCustomerId(), center.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, center.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, true);
}
Also used : UserContext(org.mifos.security.util.UserContext) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) CenterDto(org.mifos.dto.domain.CenterDto) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 4 with CenterDto

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

the class GroupCustAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    actionForm.cleanForm();
    // FIXME - store group identifier (id, globalCustNum) instead of entire business object
    GroupBO group = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    group = this.customerDao.findGroupBySystemId(group.getGlobalCustNum());
    logger.debug("Entering GroupCustAction manage method and customer id: " + group.getGlobalCustNum());
    CenterDto groupDto = this.groupServiceFacade.retrieveGroupDetailsForUpdate(group.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupDto.getActiveLoanOfficersForBranch(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupDto.isCenterHierarchyExists(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, groupDto.getCustomerPositionViews(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, groupDto.getClientList(), request);
    actionForm.setLoanOfficerId(String.valueOf(group.getLoanOfficerId()));
    actionForm.setDisplayName(group.getDisplayName());
    actionForm.setCustomerId(group.getCustomerId().toString());
    actionForm.setGlobalCustNum(group.getGlobalCustNum());
    actionForm.setExternalId(group.getExternalId());
    actionForm.setAddress(group.getAddress());
    actionForm.setCustomerPositions(groupDto.getCustomerPositionViews());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    if (group.isTrained()) {
        actionForm.setTrained(GroupConstants.TRAINED);
    } else {
        actionForm.setTrained(GroupConstants.NOT_TRAINED);
    }
    if (group.getTrainedDate() != null) {
        actionForm.setTrainedDate(DateUtils.getUserLocaleDate(getUserContext(request).getPreferredLocale(), group.getTrainedDate().toString()));
    }
    logger.debug("Exiting GroupCustAction manage method ");
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GroupBO(org.mifos.customers.group.business.GroupBO) CenterDto(org.mifos.dto.domain.CenterDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CenterDto (org.mifos.dto.domain.CenterDto)4 DateTime (org.joda.time.DateTime)2 GroupBO (org.mifos.customers.group.business.GroupBO)2 AddressDto (org.mifos.dto.domain.AddressDto)2 CenterCreation (org.mifos.dto.domain.CenterCreation)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)2 CustomerDto (org.mifos.dto.domain.CustomerDto)2 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)2 PersonnelDto (org.mifos.dto.domain.PersonnelDto)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 ArrayList (java.util.ArrayList)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CenterCustActionForm (org.mifos.customers.center.struts.actionforms.CenterCustActionForm)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1