Search in sources :

Example 16 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientServiceFacadeWebTier method retrieveFamilyInfoForEdit.

@Override
public ClientFamilyInfoDto retrieveFamilyInfoForEdit(String clientGlobalCustNum) {
    ClientBO client = this.customerDao.findClientBySystemId(clientGlobalCustNum);
    ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
    ClientRulesDto clientRules = retrieveClientRules();
    CustomerDetailDto customerDetail = client.toCustomerDetailDto();
    ClientDetailDto clientDetail = client.toClientDetailDto(clientRules.isFamilyDetailsRequired());
    List<ClientNameDetailDto> familyMembers = new ArrayList<ClientNameDetailDto>();
    Map<Integer, List<ClientFamilyDetailDto>> clientFamilyDetails = new HashMap<Integer, List<ClientFamilyDetailDto>>();
    int familyMemberCount = 0;
    for (ClientNameDetailEntity clientNameDetailEntity : client.getNameDetailSet()) {
        if (clientNameDetailEntity.isNotClientNameType()) {
            ClientNameDetailDto nameView1 = clientNameDetailEntity.toDto();
            familyMembers.add(nameView1);
            for (ClientFamilyDetailEntity clientFamilyDetailEntity : client.getFamilyDetailSet()) {
                if (clientNameDetailEntity.matchesCustomerId(clientFamilyDetailEntity.getClientName().getCustomerNameId())) {
                    ClientFamilyDetailDto clientFamilyDetail = clientFamilyDetailEntity.toDto();
                    addFamilyDetailsDtoToMap(clientFamilyDetails, familyMemberCount, clientFamilyDetail);
                }
            }
            familyMemberCount++;
        }
    }
    return new ClientFamilyInfoDto(clientDropdowns, customerDetail, clientDetail, familyMembers, clientFamilyDetails);
}
Also used : HashMap(java.util.HashMap) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientNameDetailEntity(org.mifos.customers.client.business.ClientNameDetailEntity) ClientRulesDto(org.mifos.dto.domain.ClientRulesDto) ClientDetailDto(org.mifos.dto.screen.ClientDetailDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) List(java.util.List) ClientDropdownsDto(org.mifos.dto.screen.ClientDropdownsDto) ClientFamilyDetailEntity(org.mifos.customers.client.business.ClientFamilyDetailEntity) ClientFamilyInfoDto(org.mifos.dto.screen.ClientFamilyInfoDto)

Example 17 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientBO method updateFamilyAndNameDetails.

/**
     * This method is used to update the Client Family and Name Details
     */
public void updateFamilyAndNameDetails(ClientFamilyInfoUpdate clientFamilyInfoUpdate) {
    List<Integer> primaryKeys = clientFamilyInfoUpdate.getFamilyPrimaryKey();
    for (int key = 0; key < primaryKeys.size(); key++) {
        if (primaryKeys.get(key) != null) {
            List<ClientNameDetailDto> clientNameDetailDto = clientFamilyInfoUpdate.getFamilyNames();
            for (ClientNameDetailEntity clientNameDetailEntity : getNameDetailSet()) {
                if (clientNameDetailEntity.getCustomerNameId().intValue() == primaryKeys.get(key).intValue()) {
                    ClientNameDetailDto nameView = clientNameDetailDto.get(key);
                    if (nameView != null) {
                        clientNameDetailEntity.updateNameDetails(nameView);
                        // details table.
                        if (ClientRules.isFamilyDetailsRequired()) {
                            List<ClientFamilyDetailDto> clientFamilyDetailDto = clientFamilyInfoUpdate.getFamilyDetails();
                            // familyDetails
                            for (ClientFamilyDetailDto clientFamilyDetail : clientFamilyDetailDto) {
                                if (familyDetailsDoesNotAlreadyContain(clientNameDetailEntity.getCustomerNameId())) {
                                    ClientFamilyDetailEntity clientFamilyEntity = new ClientFamilyDetailEntity(this, clientNameDetailEntity, clientFamilyDetail);
                                    familyDetailSet.add(clientFamilyEntity);
                                }
                            }
                        }
                    }
                }
                List<ClientFamilyDetailDto> clientFamilyDetailDto = clientFamilyInfoUpdate.getFamilyDetails();
                for (ClientFamilyDetailEntity clientFamilyDetailEntity : familyDetailSet) {
                    if (clientFamilyDetailEntity.getClientName().getCustomerNameId().intValue() == primaryKeys.get(key).intValue()) {
                        clientFamilyDetailEntity.updateClientFamilyDetails(clientFamilyDetailDto.get(key));
                    }
                }
            }
        }
    }
}
Also used : ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Example 18 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientBO method setFamilyAndNameDetailSets.

public void setFamilyAndNameDetailSets(final List<ClientNameDetailDto> familyNameDetailView, final List<ClientFamilyDetailDto> familyDetailView) {
    Iterator<ClientFamilyDetailDto> iterator2 = familyDetailView.iterator();
    familyDetailSet = new HashSet<ClientFamilyDetailEntity>();
    for (Object element : familyNameDetailView) {
        ClientNameDetailDto clientNameDetailView2 = (ClientNameDetailDto) element;
        ClientFamilyDetailDto clientFamilyDetailView2 = iterator2.next();
        ClientNameDetailEntity nameEntity = new ClientNameDetailEntity(this, null, clientNameDetailView2);
        this.addNameDetailSet(nameEntity);
        this.addFamilyDetailSet(new ClientFamilyDetailEntity(this, nameEntity, clientFamilyDetailView2));
    }
}
Also used : ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Example 19 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientBO method updatePersonalInfo.

public void updatePersonalInfo(ClientPersonalInfoUpdate personalInfo) throws CustomerException {
    this.governmentId = personalInfo.getGovernmentId();
    try {
        setDateOfBirth(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth()));
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.INVALID_DOB_EXCEPTION);
    }
    ClientNameDetailDto clientName = personalInfo.getClientNameDetails();
    this.getClientName().updateNameDetails(clientName);
    this.firstName = clientName.getFirstName();
    this.lastName = clientName.getLastName();
    this.secondLastName = clientName.getSecondLastName();
    if (personalInfo.getSpouseFather() != null) {
        // can be null when family details configuration is turned on
        if (this.getSpouseName() != null) {
            this.getSpouseName().updateNameDetails(personalInfo.getSpouseFather());
        } else {
            ClientNameDetailEntity spouseFatherNameDetailEntity = new ClientNameDetailEntity(this, personalInfo.getSpouseFather().getSecondLastName(), personalInfo.getSpouseFather());
            addNameDetailSet(spouseFatherNameDetailEntity);
        }
    }
    this.updateClientDetails(personalInfo.getClientDetail());
    setDisplayName(personalInfo.getClientDisplayName());
    Address address = null;
    if (personalInfo.getAddress() != null) {
        ;
    }
    {
        address = new Address(personalInfo.getAddress().getLine1(), personalInfo.getAddress().getLine2(), personalInfo.getAddress().getLine3(), personalInfo.getAddress().getCity(), personalInfo.getAddress().getState(), personalInfo.getAddress().getCountry(), personalInfo.getAddress().getZip(), personalInfo.getAddress().getPhoneNumber());
        updateAddress(address);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) Address(org.mifos.framework.business.util.Address) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Example 20 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientBO method toClientDetailDto.

public ClientDetailDto toClientDetailDto(boolean isFamilyDetailsRequired) {
    ClientPersonalDetailDto customerDetailView = this.getCustomerDetail().toDto();
    String dateOfBirthAsString = "";
    if (this.dateOfBirth != null) {
        dateOfBirthAsString = DateUtils.makeDateAsSentFromBrowser(this.dateOfBirth);
    }
    List<ClientNameDetailDto> clientNameViews = toClientNameDetailViews();
    ClientNameDetailDto clientName = null;
    ClientNameDetailDto spouseName = null;
    for (ClientNameDetailDto nameView : clientNameViews) {
        if (nameView.getNameType() != null) {
            if (nameView.getNameType().equals(ClientConstants.CLIENT_NAME_TYPE)) {
                clientName = nameView;
            } else if (!isFamilyDetailsRequired) {
                spouseName = nameView;
            }
        } else {
            spouseName = new ClientNameDetailDto();
        }
    }
    boolean groupFlagIsSet = false;
    Integer parentGroupId = Integer.valueOf(0);
    if (isClientUnderGroup()) {
        groupFlagIsSet = true;
        parentGroupId = getParentCustomer().getCustomerId();
    }
    boolean trained = isTrained();
    String trainedDate = "";
    if (getTrainedDate() != null) {
        trainedDate = DateUtils.makeDateAsSentFromBrowser(getTrainedDate());
    }
    return new ClientDetailDto(this.governmentId, dateOfBirthAsString, customerDetailView, clientName, spouseName, groupFlagIsSet, parentGroupId, trained, trainedDate);
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientDetailDto(org.mifos.dto.screen.ClientDetailDto)

Aggregations

ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)41 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)26 CustomerException (org.mifos.customers.exceptions.CustomerException)15 Test (org.junit.Test)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 ArrayList (java.util.ArrayList)12 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)10 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)9 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)8 Address (org.mifos.framework.business.util.Address)8 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 AddressDto (org.mifos.dto.domain.AddressDto)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 DateTime (org.joda.time.DateTime)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 UserContext (org.mifos.security.util.UserContext)6 InputStream (java.io.InputStream)5 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)5 MeetingDto (org.mifos.dto.domain.MeetingDto)5