NdsBeisEsb/src/main/java/com/northgateps/nds/beis/esb/converter/ToMaintainPartyDetailsRequestConverter.java
/**
     * 
     * @param ndsAccountDetails - object containing account details to be converted
     * @param ndsContactAddressDetail - object containing address details to be converted
     * @param ndsUserDetails - object containing user details to be converted
     * @return the provided details converted to a MaintainPartyDetailsRequest object ready to send to the external
     *         service.
     */
@param ndsAccountDetails - object containing account details to be converted
@param ndsContactAddressDetail - object containing address details to be converted
@param ndsUserDetails - object containing user details to be converted
@return the provided details converted to a MaintainPartyDetailsRequest object ready to send to the external
service.
@param ndsAccountDetails - object containing account details to be converted @param ndsContactAddressDetail - object containing address details to be converted @param ndsUserDetails - object containing user details to be converted @return the provided details converted to a MaintainPartyDetailsRequest object ready to send to the external service .
private static MaintainPartyDetailsRequest convertUserAccountAndAddressToAMaintainPartyDetailsRequest(
            BeisAccountDetails ndsAccountDetails, BeisAddressDetail ndsContactAddressDetail, String userName,
            String userType, String email) {
        MaintainPartyDetailsRequest backOfficeMaintainPartyDetailsRequest = new MaintainPartyDetailsRequest();
        if (ndsAccountDetails == null || ndsAccountDetails.getAccountId() == null
                || ndsAccountDetails.getAccountId().isEmpty()) {
            logger.info("This is a create MaintainPartyDetails request");
            MaintainPartyDetailsRequest.Create createNode = new MaintainPartyDetailsRequest.Create();
            createNode.setUserName(userName);
            backOfficeMaintainPartyDetailsRequest.setCreate(createNode);
        } else {
            logger.info("This is an update MaintainPartyDetails request");
            MaintainPartyDetailsRequest.Update updateNode = new MaintainPartyDetailsRequest.Update();
            updateNode.setPartyRef( new BigInteger(ndsAccountDetails.getAccountId()));
            backOfficeMaintainPartyDetailsRequest.setUpdate(updateNode);
        }
        if (ndsAccountDetails != null) {
            backOfficeMaintainPartyDetailsRequest.setLanguageCode(ndsAccountDetails.getLanguageCode());
            if(userType !=null && userType.equals("Agent") && ndsAccountDetails.getAgentNameDetails() !=null){
                logger.info("This is an agent request");
                backOfficeMaintainPartyDetailsRequest.setOrganisationName(
                        ndsAccountDetails.getAgentNameDetails().getAgentName());
                }
            if (ndsAccountDetails.getOrganisationNameDetail() != null) {
                logger.info("This is an organisation request");
                backOfficeMaintainPartyDetailsRequest.setOrganisationName(
                        ndsAccountDetails.getOrganisationNameDetail().getOrgName());
            }else if (ndsAccountDetails.getPersonNameDetail() != null) {
                logger.info("This is a person request");
                backOfficeMaintainPartyDetailsRequest.setFirstName(
                        ndsAccountDetails.getPersonNameDetail().getFirstname());
                backOfficeMaintainPartyDetailsRequest.setLastName(ndsAccountDetails.getPersonNameDetail().getSurname());
            }
            backOfficeMaintainPartyDetailsRequest.setPhoneNumber(ndsAccountDetails.getTelNumber());
        }
        if (ndsContactAddressDetail != null) {
            AddressType addressNode = new AddressType();
            addressNode.setLine1(ndsContactAddressDetail.getLine().get(0));
            if (ndsContactAddressDetail.getLine().size() > 1) {
                addressNode.setLine2(ndsContactAddressDetail.getLine().get(1));
            }
            addressNode.setTown(ndsContactAddressDetail.getTown());
            addressNode.setCounty(ndsContactAddressDetail.getCounty());
            addressNode.setCountry(ndsContactAddressDetail.getCountry());
            addressNode.setPostcode(ndsContactAddressDetail.getPostcode());
            backOfficeMaintainPartyDetailsRequest.setAddress(addressNode);
            backOfficeMaintainPartyDetailsRequest.setAddressMoniker(ndsContactAddressDetail.getQasMoniker());
        }
        backOfficeMaintainPartyDetailsRequest.setUserType(userType);
        backOfficeMaintainPartyDetailsRequest.setEmailAddress(email);
        return backOfficeMaintainPartyDetailsRequest;
    }
private static MaintainPartyDetailsRequest convertUserAccountAndAddressToAMaintainPartyDetailsRequest ( BeisAccountDetails ndsAccountDetails , BeisAddressDetail ndsContactAddressDetail , String userName , String userType , String email ) { MaintainPartyDetailsRequest backOfficeMaintainPartyDetailsRequest = new MaintainPartyDetailsRequest ( ) ; if ( ndsAccountDetails == null || ndsAccountDetails . getAccountId ( ) == null || ndsAccountDetails . getAccountId ( ) . isEmpty ( ) ) { logger . info ( "This is a create MaintainPartyDetails request" ) ; MaintainPartyDetailsRequest . Create createNode = new MaintainPartyDetailsRequest . Create ( ) ; createNode . setUserName ( userName ) ; backOfficeMaintainPartyDetailsRequest . setCreate ( createNode ) ; } else { logger . info ( "This is an update MaintainPartyDetails request" ) ; MaintainPartyDetailsRequest . Update updateNode = new MaintainPartyDetailsRequest . Update ( ) ; updateNode . setPartyRef ( new BigInteger ( ndsAccountDetails . getAccountId ( ) ) ) ; backOfficeMaintainPartyDetailsRequest . setUpdate ( updateNode ) ; } if ( ndsAccountDetails != null ) { backOfficeMaintainPartyDetailsRequest . setLanguageCode ( ndsAccountDetails . getLanguageCode ( ) ) ; if ( userType != null && userType . equals ( "Agent" ) && ndsAccountDetails . getAgentNameDetails ( ) != null ) { logger . info ( "This is an agent request" ) ; backOfficeMaintainPartyDetailsRequest . setOrganisationName ( ndsAccountDetails . getAgentNameDetails ( ) . getAgentName ( ) ) ; } if ( ndsAccountDetails . getOrganisationNameDetail ( ) != null ) { logger . info ( "This is an organisation request" ) ; backOfficeMaintainPartyDetailsRequest . setOrganisationName ( ndsAccountDetails . getOrganisationNameDetail ( ) . getOrgName ( ) ) ; } else if ( ndsAccountDetails . getPersonNameDetail ( ) != null ) { logger . info ( "This is a person request" ) ; backOfficeMaintainPartyDetailsRequest . setFirstName ( ndsAccountDetails . getPersonNameDetail ( ) . getFirstname ( ) ) ; backOfficeMaintainPartyDetailsRequest . setLastName ( ndsAccountDetails . getPersonNameDetail ( ) . getSurname ( ) ) ; } backOfficeMaintainPartyDetailsRequest . setPhoneNumber ( ndsAccountDetails . getTelNumber ( ) ) ; } if ( ndsContactAddressDetail != null ) { AddressType addressNode = new AddressType ( ) ; addressNode . setLine1 ( ndsContactAddressDetail . getLine ( ) . get ( 0 ) ) ; if ( ndsContactAddressDetail . getLine ( ) . size ( ) > 1 ) { addressNode . setLine2 ( ndsContactAddressDetail . getLine ( ) . get ( 1 ) ) ; } addressNode . setTown ( ndsContactAddressDetail . getTown ( ) ) ; addressNode . setCounty ( ndsContactAddressDetail . getCounty ( ) ) ; addressNode . setCountry ( ndsContactAddressDetail . getCountry ( ) ) ; addressNode . setPostcode ( ndsContactAddressDetail . getPostcode ( ) ) ; backOfficeMaintainPartyDetailsRequest . setAddress ( addressNode ) ; backOfficeMaintainPartyDetailsRequest . setAddressMoniker ( ndsContactAddressDetail . getQasMoniker ( ) ) ; } backOfficeMaintainPartyDetailsRequest . setUserType ( userType ) ; backOfficeMaintainPartyDetailsRequest . setEmailAddress ( email ) ; return backOfficeMaintainPartyDetailsRequest ; }
@param ndsAccountDetails - object containing account details to be converted
 @param ndsContactAddressDetail - object containing address details to be converted
 @param ndsUserDetails - object containing user details to be converted
 @return the provided details converted to a MaintainPartyDetailsRequest object ready to send to the external
         service.
@param ndsAccountDetails - object containing account details to be converted @param ndsContactAddressDetail - object containing address details to be converted @param ndsUserDetails - object containing user details to be converted @return the provided details converted to a MaintainPartyDetailsRequest object ready to send to the external service .
// Test for account id to determine update or create look for exchange property // Set for create // Set for update //set agent name // Set the organisation name or person name // This need to be check since with update contact address details we are not setting person or organisation // object // Set the address details // We will have one or two lines of address // Email is mandatory on back office