Search in sources :

Example 1 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class PictureFormFile method updateFamilyInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer customerId = clientInSession.getCustomerId();
    ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdate(customerId, clientInSession.getVersionNo(), actionForm.getFamilyPrimaryKey(), actionForm.getFamilyNames(), actionForm.getFamilyDetails());
    this.clientServiceFacade.updateFamilyInfo(clientFamilyInfoUpdate);
    actionForm.setFamilyDateOfBirth();
    actionForm.constructFamilyDetails();
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    return mapping.findForward(ActionForwards.updateFamilyInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class PictureFormFile method updatePersonalInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer oldClientVersionNumber = clientInSession.getVersionNo();
    Integer customerId = clientInSession.getCustomerId();
    String clientStatus = clientInSession.getCustomerStatus().getName();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    short loanOfficerId = clientInSession.getCreatedBy();
    final String clientSystemId = clientInSession.getGlobalCustNum();
    ClientPersonalInfoDto clientPersonalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    if (clientPersonalInfo.getCustomerDetail() != null) {
        if (clientPersonalInfo.getCustomerDetail().getAddress() != null) {
            if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() != null && (!clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber().equals(address.getPhoneNumber()))) {
                UserContext userContext = getUserContext(request);
                if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                    throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
                }
            } else if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() == null && address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
                UserContext userContext = getUserContext(request);
                if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                    throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
                }
            }
        } else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
            UserContext userContext = getUserContext(request);
            if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
                throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
            }
        }
    } else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
        UserContext userContext = getUserContext(request);
        if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
            throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
        }
    }
    ClientNameDetailDto spouseFather = null;
    if (!ClientRules.isFamilyDetailsRequired()) {
        spouseFather = actionForm.getSpouseName();
    }
    InputStream picture = null;
    if (actionForm.getPicture() != null && StringUtils.isNotBlank(actionForm.getPicture().getFileName())) {
        picture = actionForm.getCustomerPicture();
    }
    ClientNameDetailDto clientNameDetails = actionForm.getClientName();
    ClientPersonalDetailDto clientDetail = actionForm.getClientDetailView();
    String governmentId = actionForm.getGovernmentId();
    String clientDisplayName = actionForm.getClientName().getDisplayName();
    String dateOfBirth = actionForm.getDateOfBirth();
    ClientPersonalInfoUpdate personalInfo = new ClientPersonalInfoUpdate(customerId, oldClientVersionNumber, customFields, address, clientDetail, clientNameDetails, spouseFather, picture, governmentId, clientDisplayName, dateOfBirth);
    this.clientServiceFacade.updateClientPersonalInfo(personalInfo, clientStatus, loanOfficerId);
    return mapping.findForward(ActionForwards.updatePersonalInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ClientPersonalInfoUpdate(org.mifos.dto.domain.ClientPersonalInfoUpdate) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalInfoDto(org.mifos.dto.screen.ClientPersonalInfoDto) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class ChkListAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ChkListActionForm chkListActionForm = (ChkListActionForm) form;
    Short stateId = getShortValue(chkListActionForm.getStateId());
    String checklistName = chkListActionForm.getChecklistName();
    Short checklistStatus = getShortValue(chkListActionForm.getChecklistStatus());
    List<String> details = chkListActionForm.getValidCheckListDetails();
    if (chkListActionForm.getIsCustomer()) {
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        Short levelId = getShortValue(chkListActionForm.getMasterTypeId());
        this.checkListServiceFacade.updateCustomerChecklist(customerCheckList.getChecklistId(), levelId, stateId, checklistStatus, checklistName, details);
    } else {
        AccountCheckListBO accountCheckList = (AccountCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        Short productId = getShortValue(chkListActionForm.getMasterTypeId());
        this.checkListServiceFacade.updateAccountChecklist(accountCheckList.getChecklistId(), productId, stateId, checklistStatus, checklistName, details);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) ChkListActionForm(org.mifos.customers.checklist.struts.actionforms.ChkListActionForm) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class ClientTransferAction method updateParent.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientTransferActionForm actionForm = (ClientTransferActionForm) form;
    ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    String globalCustNum = this.clientServiceFacade.transferClientToGroup(actionForm.getParentGroupIdValue(), clientInSession.getGlobalCustNum(), clientInSession.getVersionNo());
    ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : ClientTransferActionForm(org.mifos.customers.client.struts.actionforms.ClientTransferActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class MeetingAction method update.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MeetingActionForm actionForm = (MeetingActionForm) form;
    MeetingBO meeting = createMeeting(actionForm);
    CustomerBO customerInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    MeetingDto meetingDto = null;
    if (meeting != null) {
        meetingDto = meeting.toDto();
    }
    meetingServiceFacade.updateCustomerMeeting(meetingDto, customerInSession.getCustomerId());
    ActionForwards forward = forwardForUpdate(actionForm.getCustomerLevelValue());
    return mapping.findForward(forward.toString());
}
Also used : ActionForwards(org.mifos.application.util.helpers.ActionForwards) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerBO(org.mifos.customers.business.CustomerBO) MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) MeetingDto(org.mifos.dto.domain.MeetingDto) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CloseSession (org.mifos.framework.util.helpers.CloseSession)35 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)35 UserContext (org.mifos.security.util.UserContext)13 ClientBO (org.mifos.customers.client.business.ClientBO)7 BusinessRuleException (org.mifos.service.BusinessRuleException)7 CustomerBO (org.mifos.customers.business.CustomerBO)6 BigDecimal (java.math.BigDecimal)5 ActionForward (org.apache.struts.action.ActionForward)5 LocalDate (org.joda.time.LocalDate)5 AccountBO (org.mifos.accounts.business.AccountBO)5 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)4 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)4 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)4 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Locale (java.util.Locale)3 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3