Search in sources :

Example 96 with TransactionDemarcate

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

the class PictureFormFile method editFamilyInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward editFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.clearMostButNotAllFieldsOnActionForm();
    ClientBO clientFromSession = getClientFromSession(request);
    ClientFamilyInfoDto clientFamilyInfo = this.clientServiceFacade.retrieveFamilyInfoForEdit(clientFromSession.getGlobalCustNum());
    SessionUtils.setCollectionAttribute(ClientConstants.LIVING_STATUS_ENTITY, clientFamilyInfo.getClientDropdowns().getLivingStatus(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.GENDER_ENTITY, clientFamilyInfo.getClientDropdowns().getGenders(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    UserContext userContext = getUserContext(request);
    List<SpouseFatherLookupEntity> spouseFather = legacyMasterDao.findMasterDataEntitiesWithLocale(SpouseFatherLookupEntity.class);
    SessionUtils.setCollectionAttribute(ClientConstants.SPOUSE_FATHER_ENTITY, spouseFather, request);
    SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isFamilyDetailsMandatory(), request);
    // customer specific
    actionForm.setCustomerId(clientFamilyInfo.getCustomerDetail().getCustomerId().toString());
    actionForm.setLoanOfficerId(clientFamilyInfo.getCustomerDetail().getLoanOfficerIdAsString());
    actionForm.setGlobalCustNum(clientFamilyInfo.getCustomerDetail().getGlobalCustNum());
    actionForm.setExternalId(clientFamilyInfo.getCustomerDetail().getExternalId());
    // client specific
    actionForm.setGovernmentId(clientFamilyInfo.getClientDetail().getGovernmentId());
    actionForm.setDateOfBirth(clientFamilyInfo.getClientDetail().getDateOfBirth());
    actionForm.initializeFamilyMember();
    actionForm.setClientDetailView(clientFamilyInfo.getClientDetail().getCustomerDetail());
    actionForm.setClientName(clientFamilyInfo.getClientDetail().getClientName());
    actionForm.setSpouseName(clientFamilyInfo.getClientDetail().getSpouseName());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    // client family specific
    int familyMemberCount = 0;
    for (ClientNameDetailDto familyMember : clientFamilyInfo.getFamilyMembers()) {
        actionForm.addFamilyMember();
        actionForm.setFamilyPrimaryKey(familyMemberCount, familyMember.getCustomerNameId());
        actionForm.setFamilyFirstName(familyMemberCount, familyMember.getFirstName());
        actionForm.setFamilyMiddleName(familyMemberCount, familyMember.getMiddleName());
        actionForm.setFamilyLastName(familyMemberCount, familyMember.getLastName());
        actionForm.setFamilySecondLastName(familyMemberCount, familyMember.getSecondLastName());
        actionForm.setFamilyRelationship(familyMemberCount, familyMember.getNameType());
        Map<Integer, List<ClientFamilyDetailDto>> clientFamilyDetailsMap = clientFamilyInfo.getClientFamilyDetails();
        Integer key = Integer.valueOf(familyMemberCount);
        List<ClientFamilyDetailDto> clientFamilyDetails = clientFamilyDetailsMap.get(key);
        if (clientFamilyDetails != null) {
            for (ClientFamilyDetailDto clientFamilyDetailDto : clientFamilyDetails) {
                Calendar cal = Calendar.getInstance();
                if (clientFamilyDetailDto.getDateOfBirth() != null) {
                    String date1 = DateUtils.makeDateAsSentFromBrowser(clientFamilyDetailDto.getDateOfBirth());
                    java.util.Date date = DateUtils.getDate(date1);
                    cal.setTime(date);
                    actionForm.setFamilyDateOfBirthDD(familyMemberCount, String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
                    actionForm.setFamilyDateOfBirthMM(familyMemberCount, String.valueOf(cal.get(Calendar.MONTH) + 1));
                    actionForm.setFamilyDateOfBirthYY(familyMemberCount, String.valueOf(cal.get(Calendar.YEAR)));
                }
                actionForm.setFamilyGender(familyMemberCount, clientFamilyDetailDto.getGender());
                actionForm.setFamilyLivingStatus(familyMemberCount, clientFamilyDetailDto.getLivingStatus());
            }
        }
        familyMemberCount++;
    }
    ClientBO client = this.customerDao.findClientBySystemId(clientFromSession.getGlobalCustNum());
    actionForm.setAddress(Address.toAddress(client.getAddress()));
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.editFamilyInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Calendar(java.util.Calendar) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) SpouseFatherLookupEntity(org.mifos.application.master.business.SpouseFatherLookupEntity) List(java.util.List) ArrayList(java.util.ArrayList) ClientFamilyInfoDto(org.mifos.dto.screen.ClientFamilyInfoDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 97 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate 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 98 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate 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 99 with TransactionDemarcate

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

the class PictureFormFile method editMfiInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward editMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.clearMostButNotAllFieldsOnActionForm();
    ClientBO clientFromSession = getClientFromSession(request);
    String clientSystemId = clientFromSession.getGlobalCustNum();
    ClientMfiInfoDto mfiInfoDto = this.clientServiceFacade.retrieveMfiInfoForEdit(clientSystemId);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, mfiInfoDto.getLoanOfficersList(), request);
    actionForm.setGroupDisplayName(mfiInfoDto.getGroupDisplayName());
    actionForm.setCenterDisplayName(mfiInfoDto.getCenterDisplayName());
    actionForm.setLoanOfficerId(mfiInfoDto.getCustomerDetail().getLoanOfficerIdAsString());
    actionForm.setCustomerId(mfiInfoDto.getCustomerDetail().getCustomerId().toString());
    actionForm.setGlobalCustNum(mfiInfoDto.getCustomerDetail().getGlobalCustNum());
    actionForm.setExternalId(mfiInfoDto.getCustomerDetail().getExternalId());
    actionForm.setGroupFlag(mfiInfoDto.getClientDetail().getGroupFlagAsString());
    actionForm.setParentGroupId(mfiInfoDto.getClientDetail().getParentGroupId().toString());
    actionForm.setTrained(mfiInfoDto.getClientDetail().getTrainedAsString());
    actionForm.setTrainedDate(mfiInfoDto.getClientDetail().getTrainedDate());
    actionForm.setDateOfBirth(clientFromSession.getDateOfBirth());
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.editMfiInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) ClientMfiInfoDto(org.mifos.dto.screen.ClientMfiInfoDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 100 with TransactionDemarcate

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

the class PictureFormFile method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    String governmentId = actionForm.getGovernmentId();
    ClientNameDetailDto clientNameDetail = actionForm.getClientName();
    clientNameDetail.setNames(ClientRules.getNameSequence());
    String clientName = clientNameDetail.getDisplayName();
    String givenDateOfBirth = actionForm.getDateOfBirth();
    ClientNameDetailDto spouseName = actionForm.getSpouseName();
    spouseName.setNames(ClientRules.getNameSequence());
    DateTime dateOfBirth = new DateTime(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth));
    ProcessRulesDto processRules = this.clientServiceFacade.previewClient(governmentId, dateOfBirth, clientName, actionForm.isDefaultFeeRemoved(), actionForm.getOfficeIdValue(), actionForm.getLoanOfficerIdValue());
    String pendingApprovalState = processRules.isClientPendingApprovalStateEnabled() ? CustomerConstants.YES : CustomerConstants.NO;
    SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, pendingApprovalState, request);
    Short officeId = actionForm.getOfficeIdValue();
    Short groupFlag = actionForm.getGroupFlagValue();
    String parentGroupId = actionForm.getParentGroupId();
    ClientFormCreationDto clientFormCreationDto = this.clientServiceFacade.retrieveClientFormCreationData(groupFlag, officeId, parentGroupId);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
    if (clientFormCreationDto.getFormedByPersonnelId() != null) {
        UserContext userContext = getUserContext(request);
        MeetingBO groupMeeting = customerDao.findCustomerById(Integer.valueOf(parentGroupId)).getCustomerMeetingValue();
        clientFormCreationDto.getParentCustomerMeeting().setMeetingSchedule(CustomerUIHelperFn.getMeetingSchedule(groupMeeting, userContext));
        SessionUtils.setAttribute("meeting", clientFormCreationDto.getParentCustomerMeeting(), request);
    }
    addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
    actionForm.setEditFamily("edit");
    actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
    actionForm.setClientName(clientNameDetail);
    actionForm.setSpouseName(spouseName);
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ProcessRulesDto(org.mifos.dto.domain.ProcessRulesDto) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientFormCreationDto(org.mifos.dto.screen.ClientFormCreationDto) DateTime(org.joda.time.DateTime) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)259 UserContext (org.mifos.security.util.UserContext)72 ArrayList (java.util.ArrayList)41 CloseSession (org.mifos.framework.util.helpers.CloseSession)35 LoanBO (org.mifos.accounts.loan.business.LoanBO)26 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)21 CustomerBO (org.mifos.customers.business.CustomerBO)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)19 AccountBO (org.mifos.accounts.business.AccountBO)18 ApplicationException (org.mifos.framework.exceptions.ApplicationException)17 ActionErrors (org.apache.struts.action.ActionErrors)14 LocalDate (org.joda.time.LocalDate)14 AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)13 List (java.util.List)12 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)12 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 ActionForward (org.apache.struts.action.ActionForward)11