public TrxMessageHeader createProcessMessageHeader(MessageDetailTarget recMessageDetailTarget, String strMessageTransport)
    {
        if ((this.getEditMode() != DBConstants.EDIT_CURRENT) && (this.getEditMode() != DBConstants.EDIT_IN_PROGRESS))
            return null;    // Must have a valid record
        TrxMessageHeader trxMessageHeader = new TrxMessageHeader(null, null);
        // Add properties from this process info
        MessageInfo recMessageInfo = (MessageInfo)((ReferenceField)this.getField(MessageProcessInfo.MESSAGE_INFO_ID)).getReference();
        if (recMessageInfo == null)
            return null;    // Impossible
        trxMessageHeader = recMessageInfo.addMessageProperties(trxMessageHeader);
        trxMessageHeader = this.addMessageProperties(trxMessageHeader);
        
        if (recMessageDetailTarget != null)
        {
            if (m_recMessageDetail == null)
            {
                RecordOwner recordOwner = this.findRecordOwner();
                m_recMessageDetail = new MessageDetail(recordOwner);
                recordOwner.removeRecord(m_recMessageDetail);
                this.addListener(new FreeOnFreeHandler(m_recMessageDetail));
            }
            Vector<MessageDetailTarget> vMessageDetailTarget = new Vector<MessageDetailTarget>();
            while (recMessageDetailTarget != null)
            {
                vMessageDetailTarget.addElement(recMessageDetailTarget);
                recMessageDetailTarget = recMessageDetailTarget.getNextMessageDetailTarget();
            }
            for (int i = vMessageDetailTarget.size() - 1; i >= 0; i--)
            {
                recMessageDetailTarget = vMessageDetailTarget.get(i);
                trxMessageHeader = recMessageDetailTarget.addMessageProperties(trxMessageHeader);
            }
            MessageTransport recMessageTransport = null;
            if ((strMessageTransport == null) || (strMessageTransport.length() == 0))
                strMessageTransport = (String)trxMessageHeader.get(MessageTransport.SEND_MESSAGE_BY_PARAM);
            if ((strMessageTransport != null) && (strMessageTransport.length() != 0))
                recMessageTransport = this.getMessageTransport(strMessageTransport);
            if (recMessageTransport == null)
            { // Still no transport, see if there is a default transport in the MessageDetail
                for (int i = 0; i < vMessageDetailTarget.size(); i++)
                {
                    recMessageDetailTarget = vMessageDetailTarget.get(i);
                    recMessageTransport = m_recMessageDetail.getDefaultMessageTransport(recMessageDetailTarget, this);
                    if (recMessageTransport != null)
                        break;
                }
            }
            if (recMessageTransport == null)
            { // See if there is a default transport specified in this record
                if (!this.getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID).isNull())
                    recMessageTransport = (MessageTransport)((ReferenceField)this.getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID)).getReference();
            }
            if (recMessageTransport == null)
            { // See if there is a default transport in the MessageDetailTarget chain.
                for (int i = 0; i < vMessageDetailTarget.size(); i++)
                {
                    recMessageDetailTarget = vMessageDetailTarget.get(i);
                    recMessageTransport = recMessageDetailTarget.getMessageTransport(trxMessageHeader);
                    if (recMessageTransport != null)
                        if ((recMessageTransport.getEditMode() == DBConstants.EDIT_CURRENT) || (recMessageTransport.getEditMode() == DBConstants.EDIT_IN_PROGRESS))
                            break;
                }
            }
            if ((recMessageTransport == null)
                || ((recMessageTransport.getEditMode() != DBConstants.EDIT_CURRENT) && (recMessageTransport.getEditMode() != DBConstants.EDIT_IN_PROGRESS)))
                    recMessageTransport = this.getMessageTransport(MessageTransport.DIRECT);
            trxMessageHeader = recMessageTransport.addMessageProperties(trxMessageHeader);
            for (int i = vMessageDetailTarget.size() - 1; i >= 0; i--)
            {
                recMessageDetailTarget = vMessageDetailTarget.get(i);
                trxMessageHeader = m_recMessageDetail.addMessageProperties(trxMessageHeader, recMessageDetailTarget, this, recMessageTransport);
            }
            for (int i = vMessageDetailTarget.size() - 1; i >= 0; i--)
            {
                recMessageDetailTarget = vMessageDetailTarget.get(i);
                trxMessageHeader = recMessageDetailTarget.addDestInfo(trxMessageHeader);
            }
        }
        else
        { // If there is no target detail, at least try to get the transport
            MessageTransport recMessageTransport = null;
            if ((strMessageTransport == null) || (strMessageTransport.length() == 0))
                strMessageTransport = (String)trxMessageHeader.get(MessageTransport.SEND_MESSAGE_BY_PARAM);
            if ((strMessageTransport != null) && (strMessageTransport.length() != 0))
                recMessageTransport = this.getMessageTransport(strMessageTransport);
            if (recMessageTransport != null) if (true)
                trxMessageHeader = recMessageTransport.addMessageProperties(trxMessageHeader);          
        }
        trxMessageHeader = this.addTransportProperties(trxMessageHeader, null);
        if (trxMessageHeader.get(MessageConstants.QUEUE_NAME) != null)
            trxMessageHeader.setQueueName((String)trxMessageHeader.get(MessageConstants.QUEUE_NAME));
        if (trxMessageHeader.get(MessageConstants.QUEUE_TYPE) != null)
            trxMessageHeader.setQueueType((String)trxMessageHeader.get(MessageConstants.QUEUE_TYPE));
        
        return trxMessageHeader;
    }
public TrxMessageHeader createProcessMessageHeader ( MessageDetailTarget recMessageDetailTarget , String strMessageTransport ) { if ( ( this . getEditMode ( ) != DBConstants . EDIT_CURRENT ) && ( this . getEditMode ( ) != DBConstants . EDIT_IN_PROGRESS ) ) return null ; TrxMessageHeader trxMessageHeader = new TrxMessageHeader ( null , null ) ; MessageInfo recMessageInfo = ( MessageInfo ) ( ( ReferenceField ) this . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) ; if ( recMessageInfo == null ) return null ; trxMessageHeader = recMessageInfo . addMessageProperties ( trxMessageHeader ) ; trxMessageHeader = this . addMessageProperties ( trxMessageHeader ) ; if ( recMessageDetailTarget != null ) { if ( m_recMessageDetail == null ) { RecordOwner recordOwner = this . findRecordOwner ( ) ; m_recMessageDetail = new MessageDetail ( recordOwner ) ; recordOwner . removeRecord ( m_recMessageDetail ) ; this . addListener ( new FreeOnFreeHandler ( m_recMessageDetail ) ) ; } Vector < MessageDetailTarget > vMessageDetailTarget = new Vector < MessageDetailTarget > ( ) ; while ( recMessageDetailTarget != null ) { vMessageDetailTarget . addElement ( recMessageDetailTarget ) ; recMessageDetailTarget = recMessageDetailTarget . getNextMessageDetailTarget ( ) ; } for ( int i = vMessageDetailTarget . size ( ) - 1 ; i >= 0 ; i -- ) { recMessageDetailTarget = vMessageDetailTarget . get ( i ) ; trxMessageHeader = recMessageDetailTarget . addMessageProperties ( trxMessageHeader ) ; } MessageTransport recMessageTransport = null ; if ( ( strMessageTransport == null ) || ( strMessageTransport . length ( ) == 0 ) ) strMessageTransport = ( String ) trxMessageHeader . get ( MessageTransport . SEND_MESSAGE_BY_PARAM ) ; if ( ( strMessageTransport != null ) && ( strMessageTransport . length ( ) != 0 ) ) recMessageTransport = this . getMessageTransport ( strMessageTransport ) ; if ( recMessageTransport == null ) { for ( int i = 0 ; i < vMessageDetailTarget . size ( ) ; i ++ ) { recMessageDetailTarget = vMessageDetailTarget . get ( i ) ; recMessageTransport = m_recMessageDetail . getDefaultMessageTransport ( recMessageDetailTarget , this ) ; if ( recMessageTransport != null ) break ; } } if ( recMessageTransport == null ) { if ( ! this . getField ( MessageProcessInfo . DEFAULT_MESSAGE_TRANSPORT_ID ) . isNull ( ) ) recMessageTransport = ( MessageTransport ) ( ( ReferenceField ) this . getField ( MessageProcessInfo . DEFAULT_MESSAGE_TRANSPORT_ID ) ) . getReference ( ) ; } if ( recMessageTransport == null ) { for ( int i = 0 ; i < vMessageDetailTarget . size ( ) ; i ++ ) { recMessageDetailTarget = vMessageDetailTarget . get ( i ) ; recMessageTransport = recMessageDetailTarget . getMessageTransport ( trxMessageHeader ) ; if ( recMessageTransport != null ) if ( ( recMessageTransport . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( recMessageTransport . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) break ; } } if ( ( recMessageTransport == null ) || ( ( recMessageTransport . getEditMode ( ) != DBConstants . EDIT_CURRENT ) && ( recMessageTransport . getEditMode ( ) != DBConstants . EDIT_IN_PROGRESS ) ) ) recMessageTransport = this . getMessageTransport ( MessageTransport . DIRECT ) ; trxMessageHeader = recMessageTransport . addMessageProperties ( trxMessageHeader ) ; for ( int i = vMessageDetailTarget . size ( ) - 1 ; i >= 0 ; i -- ) { recMessageDetailTarget = vMessageDetailTarget . get ( i ) ; trxMessageHeader = m_recMessageDetail . addMessageProperties ( trxMessageHeader , recMessageDetailTarget , this , recMessageTransport ) ; } for ( int i = vMessageDetailTarget . size ( ) - 1 ; i >= 0 ; i -- ) { recMessageDetailTarget = vMessageDetailTarget . get ( i ) ; trxMessageHeader = recMessageDetailTarget . addDestInfo ( trxMessageHeader ) ; } } else { MessageTransport recMessageTransport = null ; if ( ( strMessageTransport == null ) || ( strMessageTransport . length ( ) == 0 ) ) strMessageTransport = ( String ) trxMessageHeader . get ( MessageTransport . SEND_MESSAGE_BY_PARAM ) ; if ( ( strMessageTransport != null ) && ( strMessageTransport . length ( ) != 0 ) ) recMessageTransport = this . getMessageTransport ( strMessageTransport ) ; if ( recMessageTransport != null ) if ( true ) trxMessageHeader = recMessageTransport . addMessageProperties ( trxMessageHeader ) ; } trxMessageHeader = this . addTransportProperties ( trxMessageHeader , null ) ; if ( trxMessageHeader . get ( MessageConstants . QUEUE_NAME ) != null ) trxMessageHeader . setQueueName ( ( String ) trxMessageHeader . get ( MessageConstants . QUEUE_NAME ) ) ; if ( trxMessageHeader . get ( MessageConstants . QUEUE_TYPE ) != null ) trxMessageHeader . setQueueType ( ( String ) trxMessageHeader . get ( MessageConstants . QUEUE_TYPE ) ) ; return trxMessageHeader ; }
From this valid record and target record, create the proper message.
This must be valid and the recTarget must be valid.