Search in sources :

Example 21 with CloseSession

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

the class PersonAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm actionForm = (PersonActionForm) form;
    try {
        CreateOrUpdatePersonnelInformation perosonnelInfo = translateFormToCreatePersonnelInformationDto(request, actionForm);
        UserDetailDto userDetails = this.personnelServiceFacade.updatePersonnel(perosonnelInfo);
        String globalPersonnelNum = userDetails.getSystemId();
        Name name = new Name(actionForm.getFirstName(), actionForm.getMiddleName(), actionForm.getSecondLastName(), actionForm.getLastName());
        request.setAttribute("displayName", name.getDisplayName());
        request.setAttribute("globalPersonnelNum", globalPersonnelNum);
        //refresh user context roles if active
        Set<Short> roles = new HashSet<Short>();
        for (ListElement userNewRole : perosonnelInfo.getRoles()) {
            roles.add(userNewRole.getId().shortValue());
        }
        refreshUserContextIfActive(request, perosonnelInfo.getId(), perosonnelInfo.getUserName(), roles);
        return mapping.findForward(ActionForwards.update_success.toString());
    } catch (BusinessRuleException e) {
        throw new PersonnelException(e.getMessageKey(), e.getMessageValues());
    }
}
Also used : PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) BusinessRuleException(org.mifos.service.BusinessRuleException) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) UserDetailDto(org.mifos.dto.domain.UserDetailDto) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersonnelException(org.mifos.customers.personnel.exceptions.PersonnelException) Name(org.mifos.framework.business.util.Name) HashSet(java.util.HashSet) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 22 with CloseSession

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

the class ClientTransferAction method transferToBranch.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToBranch(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.transferClientToBranch(clientInSession.getGlobalCustNum(), actionForm.getOfficeIdValue());
    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 23 with CloseSession

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

the class CustHistoricalDataAction method updateHistoricalData.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateHistoricalData(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerBO customerBO = this.customerDao.findCustomerById(customerBOInSession.getCustomerId());
    checkVersionMismatch(customerBOInSession.getVersionNo(), customerBO.getVersionNo());
    customerBO.setUserContext(getUserContext(request));
    CustHistoricalDataActionForm historicalActionForm = (CustHistoricalDataActionForm) form;
    CustomerHistoricalDataUpdateRequest historicalData = createHistoricalDataUpdateRequest(historicalActionForm, getUserContext(request));
    this.groupServiceFacade.updateCustomerHistoricalData(customerBO.getGlobalCustNum(), historicalData);
    return mapping.findForward(ActionForwards.updateHistoricalData_success.toString());
}
Also used : CustomerHistoricalDataUpdateRequest(org.mifos.dto.domain.CustomerHistoricalDataUpdateRequest) CustHistoricalDataActionForm(org.mifos.customers.struts.actionforms.CustHistoricalDataActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 24 with CloseSession

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

the class PictureFormFile method updateMfiInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer clientId = clientInSession.getCustomerId();
    Integer oldVersionNumber = clientInSession.getVersionNo();
    boolean trained = false;
    if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        trained = true;
    }
    DateTime trainedDate = null;
    try {
        java.sql.Date inputDate = trainedDate(actionForm);
        if (inputDate != null) {
            trainedDate = new DateTime(trainedDate(actionForm));
        }
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY);
    }
    Short personnelId = Short.valueOf("-1");
    if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) {
        if (actionForm.getLoanOfficerIdValue() != null) {
            personnelId = actionForm.getLoanOfficerIdValue();
        }
    } else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) {
        // TODO for an urgent fix this reads client to get personnelId.
        // Client is read again in updateClientMfiInfo. Refactor to only read in
        // updateClientMfiInfo.
        ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
        personnelId = client.getPersonnel().getPersonnelId();
    }
    ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate);
    this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate);
    return mapping.findForward(ActionForwards.updateMfiInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) CustomerException(org.mifos.customers.exceptions.CustomerException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientMfiInfoUpdate(org.mifos.dto.domain.ClientMfiInfoUpdate) ClientBO(org.mifos.customers.client.business.ClientBO) DateTime(org.joda.time.DateTime) Date(java.sql.Date) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 25 with CloseSession

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

the class GroupTransferAction method transferToCenter.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToCenter(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
    GroupBO groupInSession = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerDetailDto groupDetail = this.groupServiceFacade.transferGroupToCenter(groupInSession.getGlobalCustNum(), actionForm.getCenterSystemId(), groupInSession.getVersionNo());
    GroupBO group = this.customerDao.findGroupBySystemId(groupDetail.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : GroupTransferActionForm(org.mifos.customers.group.struts.actionforms.GroupTransferActionForm) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) 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