INSERT INTO MWCONFIG.CODEX (ID, XML, MODIFIED_BY, TIMESTAMP) VALUES ('iso-8583-sms', 
'<codex id="iso-8583-sms" escape="true">
	<field id="packetLength" type="groupLengthBinary" decimal-format="binary" length="2" />
	<field id="messageType" type="string" length="4" padding-mode="right" padding-char=" " />
	<field id="bitmap" type="bitmap">
		<field id="primaryAccountNumber" bit="2" type="string" length="19" format="llvar" />
		<field id="processingCode" bit="3" type="string" length="6" />
		<field id="amountTransaction" bit="4" type="string" length="12" padding-mode="left" padding-char="0" />
		<field id="amountSettlement" bit="5" type="string" length="12" padding-mode="left" padding-char="0" />
		<field id="amountCardholderBilling" bit="6" type="string" length="12" padding-mode="left" padding-char="0" />
		<field id="transmissionDateTime" bit="7" type="string" length="10" />
		<field id="amountCardholderBillingFee" bit="8" type="string" length="8" padding-mode="left" padding-char="0" />
		<field id="conversionRateSettlement" bit="9" type="string" length="8" padding-mode="left" padding-char="0" />
		<field id="conversionRateCardholderBilling" bit="10" type="string" length="8" padding-mode="left" padding-char="0" />
		<field id="systemsTraceAuditNumber" bit="11" type="string" length="6" />
		<field id="timeLocalTransaction" bit="12" type="string" length="6" />
		<field id="dateLocalTransaction" bit="13" type="string" length="4" />
		<field id="dateExpiration" bit="14" type="string" length="4" />
		<field id="dateSettlement" bit="15" type="string" length="4" />
		<field id="dateConversion" bit="16" type="string" length="4" />
		<field id="dateCapture" bit="17" type="string" length="4" />
		<field id="merchantType" bit="18" type="string" length="4" padding-mode="left" padding-char="0" />
		<field id="acquiringInstitutionCountryCode" bit="19" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="panExtendedCountryCode" bit="20" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="forwardingInstitutionCountryCode" bit="21" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="pointOfServiceEntryMode" bit="22" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="applicationPanNumber" bit="23" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="networkInternationalIdentifier" bit="24" type="string" length="3" padding-mode="left" padding-char="0" />
		<field id="pointOfServiceConditionCode" bit="25" type="string" length="2" padding-mode="left" padding-char="0" />
		<field id="pointOfServiceCaptureCode" bit="26" type="string" length="2" padding-mode="left" padding-char="0" />
		<field id="authorisingIdentificationResponseLength" bit="27" type="string" length="1" padding-mode="left" padding-char="0" />
		<field id="amountTransactionFee" bit="28" type="string" length="9" padding-mode="left" padding-char="0" />
		<field id="amountSettlementFee" bit="29" type="string" length="9" padding-mode="left" padding-char="0" />
		<field id="amountTransactionProcessingFee" bit="30" type="string" length="9" padding-mode="left" padding-char="0" />
		<field id="amountSettlementProcessingFee" bit="31" type="string" length="9" padding-mode="left" padding-char="0" />
		<field id="acquiringInstitutionIdentificationCode" bit="32" type="string" length="11" format="llvar" />
		<field id="forwardingInstitutionIdentificationCode" bit="33" type="string" length="11" format="llvar" />
		<field id="primaryAccountNumberExtended" bit="34" type="string" length="28" format="llvar" />
		<field id="track2Data" bit="35" type="string" length="37" format="llvar" />
		<field id="track3Data" bit="36" type="string" length="104" format="lllvar" />
		<field id="retrievalReferenceNumber" bit="37" type="string" length="12" />
		<field id="authorisationIdentificationResponse" bit="38" type="string" length="6" />  
		<field id="responseCode" bit="39" type="string" length="2" padding-mode="left" />
		<field id="serviceRestrictionCode" bit="40" type="string" length="3" />
		<field id="cardAcceptorTerminalIdentification" bit="41" type="string" length="16" />
		<field id="cardAcceptorIdentificationCode" bit="42" type="string" length="15" />
		<field id="cardAcceptorName" bit="43" type="string" length="40" />
		<field id="additionalResponseData" bit="44" type="string" length="25" format="llvar" />
		<field id="track1Data" bit="45" type="string" length="76" format="llvar" />
		<field id="additionalDataIso" bit="46" type="string" length="999" format="lllvar" />
		<field id="additionalDataNational" bit="47" type="string" length="999" format="lllvar" />
		<field id="additionalDataPrivate" bit="48" type="string" length="999" format="lllvar" />
		<field id="currencyCodeTransaction" bit="49" type="string" length="3" />
		<field id="currencyCodeSettlement" bit="50" type="string" length="3" />
		<field id="currencyCodeCardholderBilling" bit="51" type="string" length="3" />
		<field id="personalIdentificationNumberData" bit="52" type="string" length="16" />
		<field id="securityRelatedControlInformation" bit="53" type="string" length="18" padding-mode="left" padding-char="0" />
		<field id="additionalAmounts" bit="54" type="string" length="999" format="lllvar" />
		<field id="reservedIso1" bit="55" type="string" length="999" format="lllvar" />
		<field id="reservedIso2" bit="56" type="string" length="999" format="lllvar" />
		<field id="reservedNational1" bit="57" type="string" length="999" format="lllvar" />
		<field id="reservedNational2" bit="58" type="string" length="999" format="lllvar" />
		<field id="reservedNational3" bit="59" type="string" length="999" format="lllvar" />
		<field id="reasonCode" bit="60" type="string" length="999" format="lllvar" />
		<field id="reservedPrivate1" bit="61" type="string" length="999" format="lllvar" />
		<field id="reservedPrivate2" bit="62" type="string" length="999" format="lllvar" />
		<field id="reservedPrivate3" bit="63" type="string" length="999" format="lllvar" />
		<field id="messageAuthenticationCode" bit="64" type="string" length="16" />
		<field id="bitMapTertiary" bit="65" type="string" length="16" />
		<field id="settlementCode" bit="66" type="string" length="1" padding-mode="left" padding-char="0" />
		<field id="extendedPaymentCode" bit="67" type="string" length="2" padding-mode="left" padding-char="0" />
		<field id="receivingInstitutionCountryCode" bit="68" type="string" length="3" />
		<field id="settlementInstitutionCountyCode" bit="69" type="string" length="3" />
		<field id="networkManagementInformationCode" bit="70" type="string" length="3" />
		<field id="messageNumber" bit="71" type="string" length="4" padding-mode="left" padding-char="0" />
		<field id="messageNumberLast" bit="72" type="string" length="4" padding-mode="left" padding-char="0" />
		<field id="dateAction" bit="73" type="string" length="6" />
		<field id="creditsNumber" bit="74" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="creditsReversalNumber" bit="75" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="debitsNumber" bit="76" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="debitsReversalNumber" bit="77" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="transferNumber" bit="78" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="transferReversalNumber" bit="79" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="inquiriesNumber" bit="80" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="authorisationsNumber" bit="81" type="string" length="10" padding-mode="left" padding-char="0" />
		<field id="creditsProcesssingFeeAmount" bit="82" type="string" length="14" padding-mode="left" padding-char="0" />
		<field id="creditsTransactionFeeAmount" bit="83" type="string" length="14" padding-mode="left" padding-char="0" />
		<field id="debitsProcessingFeeAmount" bit="84" type="string" length="14" padding-mode="left" padding-char="0" />
		<field id="debitsTransactionFeeAmount" bit="85" type="string" length="14" padding-mode="left" padding-char="0" />
		<field id="creditsAmount" bit="86" type="string" length="15" padding-mode="left" padding-char="0" />
		<field id="creditsReversalAmount" bit="87" type="string" length="15" padding-mode="left" padding-char="0" />
		<field id="debitsAmount" bit="88" type="string" length="15" padding-mode="left" padding-char="0" />
		<field id="debitsReversalAmount" bit="89" type="string" length="15" padding-mode="left" padding-char="0" />
		<field id="originalDataElements" bit="90" type="string" length="42" padding-mode="left" />
		<field id="fileUpdateCode" bit="91" type="string" length="1" />
		<field id="fileSecurityCode" bit="92" type="string" length="2" padding-mode="left" padding-char="0" />
		<field id="responseIndicator" bit="93" type="string" length="5" padding-mode="left" padding-char="0" />
		<field id="serviceIndicator" bit="94" type="string" length="7" />
		<field id="replacementAmounts" bit="95" type="string" length="42" />
		<field id="messageSecurityCode" bit="96" type="string" length="8" />
		<field id="amountNetSettlement" bit="97" type="string" length="16" padding-mode="left" padding-char="0" />
		<field id="payee" bit="98" type="string" length="25" />
		<field id="settlementInstitutionIdentificationCode" bit="99" type="string" length="11" format="llvar" />
		<field id="receivingInstitutionIdentificationCode" bit="100" type="string" length="11" format="llvar" />
		<field id="slipNumber" bit="101" type="string" length="11" format="llvar" />
		<field id="fromAccount" bit="102" type="string" length="28" format="llvar" />
		<field id="toAccount" bit="103" type="string" length="28" format="llvar" />
		<field id="transactionDescription" bit="104" type="string" length="100" format="lllvar" />
		<field id="reservedForIsoUse1" bit="105" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse2" bit="106" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse3" bit="107" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse4" bit="108" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse5" bit="109" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse6" bit="110" type="string" length="999" format="lllvar" />
		<field id="reservedForIsoUse7" bit="111" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse" bit="112" type="string" length="999" format="lllvar" />
		<field id="authorisingAgentInstitutionIdCode" bit="113" type="string" length="11" format="llvar" />
		<field id="reservedForNationalUse1" bit="114" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse2" bit="115" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse3" bit="116" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse4" bit="117" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse5" bit="118" type="string" length="999" format="lllvar" />
		<field id="reservedForNationalUse6" bit="119" type="string" length="999" format="lllvar" />
		<field id="reservedForPrivateUse1" bit="120" type="string" length="999" format="lllvar" />
		<field id="reservedForPrivateUse2" bit="121" type="string" length="999" format="lllvar" />
		<field id="reservedForPrivateUse3" bit="122" type="string" length="999" format="lllvar" />
		<field id="reservedForPrivateUse4" bit="123" type="string" length="999" format="lllvar" />
		<field id="infoText" bit="124" type="string" length="255" format="lllvar" />
		<field id="networkManagementInformation" bit="125" type="string" length="50" format="lllvar" />
		<field id="issuerTraceId" bit="126" type="string" length="6" format="lllvar" />
		<field id="reservedForPrivateUse" bit="127" type="string" length="11" format="lllvar" />
		<field id="messageAuthenticationCode2" bit="128" type="string" length="16" />
	</field>
	<field id="!type" type="script" encode="true">iso-8583-itm</field>
	<field id="!mid" type="script" encode="true">${msg.transmissionDateTime}.${msg.systemsTraceAuditNumber}</field>
	<field id="!code" type="script" encode="true">${dtree("SMS-CODE", "messageType")}</field>
</codex>', CURRENT USER, CURRENT TIMESTAMP);

INSERT INTO MWCONFIG.ADAPTOR (ID, DESCRIPTION, ASYNCHRONOUS, MODIFIED_BY, TIMESTAMP)
	VALUES 
		('sms-20801', 'SMS Adaptor', 1, CURRENT USER, CURRENT TIMESTAMP),
		('sms-60802', 'BIS Adaptor', 1, CURRENT USER, CURRENT TIMESTAMP),
		('core-sms', 'Core Adaptor from SMS channel', 0, CURRENT USER, CURRENT TIMESTAMP);

INSERT INTO MWCONFIG.ADAPTOR_CODEX (ADAPTOR_ID, ID, CODEX_ID)
	VALUES 
		('sms-20801', 'incoming','iso-8583-sms'),
		('sms-20801', 'outgoing','iso-8583-sms'),
        ('sms-60802', 'incoming','iso-8583-sms'),
		('sms-60802', 'outgoing','iso-8583-sms'),
		('core-sms', 'incoming', 'dsp-response'),
		('core-sms', 'outgoing', 'dsp');


INSERT INTO MWCONFIG.ADAPTOR_PARAM (ADAPTOR_ID, NAME, VALUE)
	VALUES 
        ('sms-20801', 'maxConnection', '1'),
        ('sms-60802', 'maxConnection', '1'),
        ('core-sms', 'timeout', '40000'),
        ('core-sms', 'closeOnReply', 'true'),
        ('core-sms', 'maxConnection', '50');

INSERT INTO MWCONFIG.SERVER_PORT (ADAPTOR_ID, PORT, SERVER, GROUP)
	VALUES 
		('sms-20801', 20801, 'server-1', 'sms'),
		('sms-60802', 60802, 'server-1', 'sms');

INSERT INTO MWCONFIG.CLIENT (ADAPTOR_ID, IDLE_WAIT, TIMEOUT, CLOSE_QUEUE, CONTROL_QUEUE, KEEP_CONN, REUSE_DELAY, NODE)
    VALUES  
        ('core-sms', 30000, NULL, NULL, NULL, 0, NULL, 'core-client');

INSERT INTO MWCONFIG.CLIENT_TARGET (CLIENT_ID, ID, HOST, SEQ, WEIGHT)
    VALUES
        ('core-sms', 'core-sms', 'BTNCOREKONVEN:13000', 1, NULL);

INSERT INTO MWCONFIG.DTREE(GROUP, PATH, VALUE, MODIFIED_BY, TIMESTAMP, MODULE) 
    VALUES 
        ('SMS-CODE', '0800', '0800.${msg.networkManagementInformationCode?.padLeft(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0810', '0810.${msg.networkManagementInformationCode?.padLeft(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0200', '0200.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0210', '0210.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0400', '0400.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0410', '0410.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0220', '0220.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0420', '0420.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0230', '0230.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0430', '0430.${msg.processingCode?.startsWith("1")||msg.processingCode?.startsWith("3")?msg.processingCode?.padLeft(6, "0"):msg.processingCode?.substring(0,2).padRight(6, "0")}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0200.800000', '0200.${msg.processingCode.substring(0,6)}.${msg.reservedPrivate2.substring(0,6)}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]'),
        ('SMS-CODE', '0210.800000', '0200.${msg.processingCode.substring(0,6)}.${msg.reservedPrivate2.substring(0,6)}', CURRENT USER, CURRENT TIMESTAMP, '[smsro]');

INSERT INTO MWCONFIG.ROUTING_TABLE (CODE_START, CODE_END, CHANNEL, START_DATE, QUEUE, STATUS, REPLY_TO, REPLY_TO_QMGR, CREATE_BY, CREATE_DATE)
	VALUES 
		('0800.000000', '0800.999999', 'sms', CURRENT TIMESTAMP, 'ISO_NETWORK_IN', 'ACTIVE', 'ROUTER_OUT', 'SMSBROKER.QM', CURRENT USER, CURRENT TIMESTAMP),
        ('*', '*', 'sms', CURRENT TIMESTAMP, 'MDW_IN', 'ACTIVE', 'ROUTER_OUT', 'SMSBROKER.QM', CURRENT USER, CURRENT TIMESTAMP);


INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('res-core.sms', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
    VALUES ('res-core.sms', 1, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('res-core.sms', 1, '@', 'copyMessage("../body", "request/data/body/original")', 10),
        ('res-core.sms', 1, '!CorrelId', '${head.CorrelId}', 20),
        ('res-core.sms', 1, '!connid', '${head.connid}', 20),
        ('res-core.sms', 1, '!group', '${head.request.data.group}', 20),
        ('res-core.sms', 1, '!mid', '${head.request.data.mid}', 20),
        ('res-core.sms', 1, '!reqtimestamp', '${head.reqtimestamp}', 20),
        ('res-core.sms', 1, '!sid', '${head.sid}', 20),
        ('res-core.sms', 1, '!source', '${head.request.data.source}', 20),
        ('res-core.sms', 1, '!timestamp', '${head.timestamp}', 20),
        ('res-core.sms', 1, 'acquiringInstitutionIdentificationCode', '${head.request.data.body.original.acquiringInstitutionIdentificationCode}', 20),
        ('res-core.sms', 1, 'additionalDataPrivate', '${head.request.data.body.original.additionalDataPrivate}', 20),
        ('res-core.sms', 1, 'amountCardholderBilling', '${head.request.data.body.original.amountCardholderBilling}', 20),
        ('res-core.sms', 1, 'amountTransaction', '${head.request.data.body.original.amountTransaction}', 20),
        ('res-core.sms', 1, 'amountTransactionFee', '${head.request.data.body.original.amountTransactionFee}', 20),
        ('res-core.sms', 1, 'cardAcceptorIdentificationCode', '${head.request.data.body.original.cardAcceptorIdentificationCode}', 20),
        ('res-core.sms', 1, 'cardAcceptorName', '${head.request.data.body.original.cardAcceptorName}', 20),
        ('res-core.sms', 1, 'cardAcceptorTerminalIdentification', '${head.request.data.body.original.cardAcceptorTerminalIdentification}', 20),
        ('res-core.sms', 1, 'conversionRateCardholderBilling', '${head.request.data.body.original.conversionRateCardholderBilling}', 20),
        ('res-core.sms', 1, 'currencyCodeTransaction', '${head.request.data.body.original.currencyCodeTransaction}', 20),
        ('res-core.sms', 1, 'dateCapture', '${head.request.data.body.original.dateCapture}', 20),
        ('res-core.sms', 1, 'dateLocalTransaction', '${head.request.data.body.original.dateLocalTransaction}', 20),
        ('res-core.sms', 1, 'forwardingInstitutionIdentificationCode', '${head.request.data.body.original.forwardingInstitutionIdentificationCode}', 20),
        ('res-core.sms', 1, 'fromAccount', '${head.request.data.body.original.fromAccount}', 20),
        ('res-core.sms', 1, 'merchantType', '${head.request.data.body.original.merchantType}', 20),
        ('res-core.sms', 1, 'messageType', '0210', 20),
        ('res-core.sms', 1, 'networkManagementInformation', '${head.request.data.body.original.networkManagementInformation}', 20),
        ('res-core.sms', 1, 'primaryAccountNumber', '${head.request.data.body.original.primaryAccountNumber}', 20),
        ('res-core.sms', 1, 'processingCode', '${head.request.data.body.original.processingCode}', 20),
        ('res-core.sms', 1, 'reasonCode', '${head.request.data.body.original.reasonCode}', 20),
        ('res-core.sms', 1, 'receivingInstitutionIdentificationCode', '${head.request.data.body.original.receivingInstitutionIdentificationCode}', 20),
        ('res-core.sms', 1, 'reservedForPrivateUse', '${head.request.data.body.original.reservedForPrivateUse}', 20),
        ('res-core.sms', 1, 'reservedForPrivateUse1', '${head.request.data.body.original.reservedForPrivateUse1}', 20),
        ('res-core.sms', 1, 'reservedPrivate1', '${head.request.data.body.original.reservedPrivate1}', 20),
        ('res-core.sms', 1, 'reservedPrivate2', '${head.request.data.body.original.reservedPrivate2}', 20),
        ('res-core.sms', 1, 'responseCode', '00', 20),
        ('res-core.sms', 1, 'retrievalReferenceNumber', '${head.request.data.body.original.retrievalReferenceNumber}', 20),
        ('res-core.sms', 1, 'systemsTraceAuditNumber', '${head.request.data.body.original.systemsTraceAuditNumber}', 20),
        ('res-core.sms', 1, 'timeLocalTransaction', '${head.request.data.body.original.timeLocalTransaction}', 20),
        ('res-core.sms', 1, 'toAccount', '${head.request.data.body.original.toAccount}', 20),
        ('res-core.sms', 1, 'track2Data', '${head.request.data.body.original.track2Data}', 20),
        ('res-core.sms', 1, 'transmissionDateTime', '${head.request.data.body.original.transmissionDateTime}', 20);


INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('res-core.sms.error', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
    VALUES ('res-core.sms.error', 1, '/data/body', '/data/body', 'res-core.sms', '1');
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('res-core.sms.error', 1, 'messageType', '0210', 10),
         ('res-core.sms.error', 1, '!code', '${head.request.data.body.original.processingCode?."!value".startsWith("1")||head.request.data.body.original.processingCode?."!value".startsWith("3")?head.request.data.code:tar.messageType."!value"+"."+tar.processingCode."!value"}', 20),
         ('res-core.sms.error', 1, '!error', '${head.error}', null),
         ('res-core.sms.error', 1, '!errorDetail', '${head.errorDetail}', null),
         ('res-core.sms.error', 1, 'responseCode', '${getParamValue("error_map|".concat(head.adaptor==null?head.destination."!value":head.adaptor."!value"), msg.responseCode."!value", "99")}', null);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('res-core.sms.0200.error', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('res-core.sms.0200.error', 1, '/data/body', '/data/body', 'res-core.sms.error', '1');
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('res-core.sms.0200.error', 1, '!CorrelId', '${head.CorrelId!=null?head.CorrelId:head.request.data.CorrelId}', 10),
        ('res-core.sms.0200.error', 1, '!connid', '${head.connid!=null?head.connid:head.request.data.connid}', 10),
        ('res-core.sms.0200.error', 1, 'check_rc', '${head.adaptor!=null?head.adaptor."!value"=="bi-conn-konven"||head.adaptor."!value"=="bi-conn-syariah"?(msg.reasonCode?msg.reasonCode."!value"!=null?msg.reasonCode."!value":msg.responseCode."!value":msg.responseCode."!value"):msg.responseCode."!value":msg.responseCode."!value"}', 10),
        ('res-core.sms.0200.error', 1, 'responseCode', '${head.request.data.source."!value".substring(0,6).equals("sms-10")?"B1":getParamValue("error_map|".concat(head.adaptor==null?head.destination."!value":head.adaptor."!value"), tar.check_rc."!value", "99")}', 20),
        ('res-core.sms.0200.error', 1, 'reservedForPrivateUse2', '${getParamValue("error_map_detail|".concat(head.adaptor==null?head.destination."!value":head.adaptor."!value"), tar.check_rc."!value", null)}', 50),
        ('res-core.sms.0200.error', 1, '!ReplyToQ', '${head.request.data.body.ReplyToQ}', null),
        ('res-core.sms.0200.error', 1, '!ReplyToQmgr', '${head.request.data.body.ReplyToQmgr}', null),
        ('res-core.sms.0200.error', 1, 'messageType', '0210', null),
        ('res-core.sms.0200.error', 1, 'reservedForPrivateUse1', '${msg.reservedForPrivateUse1==null||msg.reservedForPrivateUse1."!value"==null||msg.reservedForPrivateUse1."!value"==""?null:msg.reservedForPrivateUse1."!value"}', null),
        ('res-core.sms.0200.error', 1, 'reservedPrivate3', '${head.request.data.body.original.reservedPrivate3!=null?head.request.data.body.original.reservedPrivate3."!value":(msg.reservedPrivate3!=null?msg.reservedPrivate3."!value":null)}', null);

INSERT INTO MWCONFIG.MAPPING(ID, DESCRIPTION, MODIFIED_BY, TIMESTAMP, MODULE) VALUES ('checkRepeat', NULL, CURRENT USER, CURRENT TIMESTAMP, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP(MAPPING_ID, ID, "SOURCE", TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('checkRepeat', 1, '/data', '/data', null, null);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE(MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('checkRepeat', 1, '@', 'copyMessage()', null);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE(MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('checkRepeat', 1, 'isRepeat', '${getParamValue("isRepeat."+msg.source."!value",  head.body.messageType."!value"+"."+head.body.responseCode."!value","no")}', null);


INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('itm-conn-cms-req.master', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
    VALUES ('itm-conn-cms-req.master', 1, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('itm-conn-cms-req.master', 1, '@', 'copyMessage();copyMessageToChild("original");', 10),
        ('itm-conn-cms-req.master', 1, '!CorrelId', '${head.CorrelId} ', null),
        ('itm-conn-cms-req.master', 1, '!ReplyToQ', 'MDW_CORE_REPLY.SMS', null),
        ('itm-conn-cms-req.master', 1, '!ReplyToQMgr', 'ISOBROKER.QM', null),
        ('itm-conn-cms-req.master', 1, '!code', '${head.code}', null),
        ('itm-conn-cms-req.master', 1, '!connid', '${head.connid}', null),
        ('itm-conn-cms-req.master', 1, '!destination', 'itm-conn-cms', null),
        ('itm-conn-cms-req.master', 1, '!group', '${head.group}', null),
        ('itm-conn-cms-req.master', 1, '!mappingCode', '${head.code}', null),
        ('itm-conn-cms-req.master', 1, '!mid', '${head.mid}', null),
        ('itm-conn-cms-req.master', 1, '!queueName', 'BACKEND_ISO_IN.SMS', null),
        ('itm-conn-cms-req.master', 1, '!raw', '${head.raw}', null),
        ('itm-conn-cms-req.master', 1, '!reqtimestamp', '${head.reqtimestamp}', null),
        ('itm-conn-cms-req.master', 1, '!sid', '${head.sid}', null),
        ('itm-conn-cms-req.master', 1, '!source', '${head.source}', null),
        ('itm-conn-cms-req.master', 1, '!timestamp', '${head.timestamp}', null),
        ('itm-conn-cms-req.master', 1, '!type', 'iso-8583-itmibft', null),
        ('itm-conn-cms-req.master', 1, 'acquiringInstitutionIdentificationCode', '200', null),
        ('itm-conn-cms-req.master', 1, 'fullReverse', 'false', null),
        ('itm-conn-cms-req.master', 1, 'isMultipleRequest', '${null}', null);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('itm-conn-cms-res.master', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
    VALUES  ('itm-conn-cms-res.master', 1, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES
        ('itm-conn-cms-res.master', 1, '@', 'copyMessage("../body", "request/data/body/original")', 10),
        ('itm-conn-cms-res.master', 1, 'messageType', '${head.request.data.body.original.messageType."!value".substring(0,2).concat("10")}', 20),
        ('itm-conn-cms-res.master', 1, 'responseCode', '${getParamValue("error_map|"+head.source."!value", msg.responseCode."!value","99")}', 20),
        ('itm-conn-cms-res.master', 1, '!CorrelId', '${head.CorrelId}', null),
        ('itm-conn-cms-res.master', 1, '!code', '${head.code}', null),
        ('itm-conn-cms-res.master', 1, '!connid', '${head.connid}', null),
        ('itm-conn-cms-res.master', 1, '!group', '${head.request.data.group}', null),
        ('itm-conn-cms-res.master', 1, '!mid', '${head.request.data.mid}', null),
        ('itm-conn-cms-res.master', 1, '!reqtimestamp', '${head.reqtimestamp}', null),
        ('itm-conn-cms-res.master', 1, '!sid', '${head.request.data.sid}', null),
        ('itm-conn-cms-res.master', 1, '!source', '${head.request.data.source}', null),
        ('itm-conn-cms-res.master', 1, '!timestamp', '${head.reqtimestamp}', null);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('req-core.sms.0200.801000.001001', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
VALUES ('req-core.sms.0200.801000.001001', 1, '/data/body', '/data/body', 'itm-conn-cms-req.master', '1');
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('req-core.sms.0200.801000.001001', 1, '@', 'copyMessage("frontOriginal", ".");', 10),
        ('req-core.sms.0200.801000.001001', 1, 'isMultipleRequest', 'true', null),
        ('req-core.sms.0200.801000.001001', 1, 'mappingCodeMultiple', 'konven', null),
        ('req-core.sms.0200.801000.001001', 1, 'processingCode', '101000', null);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('req-core.sms.0200.801000.001001.konven', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) 
    VALUES ('req-core.sms.0200.801000.001001.konven', 1, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('req-core.sms.0200.801000.001001.konven', 1, '@', 'copyMessage("original", "request/data/body/original");copyMessage("resitm", "body");', 10),
        ('req-core.sms.0200.801000.001001.konven', 1, '!CorrelId', '${head.request.data.CorrelId}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!ReplyToQ', 'MDW_CORE_REPLY.SMS', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!ReplyToQMgr', 'PAYBROKER.QM', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!RequestURL', '${getParamValue("sms-api-core","InqRegisMB","http://localhost:8094")}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!code', '${head.request.data.mappingCode}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!connid', '${head.request.data.connid}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!destination', 'ActiveCardAndRegisMB', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!dir', 'O', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!group', '${head.request.data.group}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!mappingCode', '${head.request.data.mappingCode}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!mid', '${head.request.data.mid}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!queueName', 'BACKEND_REST_IN', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!remaining', 'AAA=', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!remainingPos', '1268', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!reqtimestamp', '${head.request.data.reqtimestamp}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!sid', '${head.request.data.sid}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!source', '${head.request.data.source}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!timestamp', '${head.request.data.timestamp}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, '!type', '${head.request.data.type}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'card', '${msg.primaryAccountNumber."!value".trim()}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'dob', '${msg.reservedForPrivateUse1."!value".substring(15,21).trim()}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'hp', '${msg.reservedForPrivateUse1."!value".substring(0,15).trim()}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'isMultipleRequest', 'false', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'ref', '${msg.retrievalReferenceNumber."!value".padRight(12," ").trim()}', null),
        ('req-core.sms.0200.801000.001001.konven', 1, 'user', '${msg.cardAcceptorTerminalIdentification."!value".trim()}', null);


INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('res-core.sms.0200.801000.001001', '[smsmd]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('res-core.sms.0200.801000.001001', 1, '/data/body', '/data/body', 'itm-conn-cms-res.master', '1');
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) 
    VALUES 
        ('res-core.sms.0200.801000.001001', 1, 'responseCode', '${getParamValue("error_map|api-error-code",msg.rsp."!value","99")}', 10),
        ('res-core.sms.0200.801000.001001', 1, 'additionalDataNational', '${msg.cif==null||msg.cif."!value"==null?"".padRight(7," "):msg.cif."!value".padRight(7," ")}${msg.nid==null||msg.nid."!value"==null?"".padRight(12," "):msg.nid."!value".padRight(12," ")}${msg.cardtype==null||msg.cardtype."!value"==null?"".padRight(10," "):msg.cardtype."!value".padRight(10," ")}${msg.rsp==null||msg.rsp."!value"==null?"".padRight(3,"999"):msg.rsp."!value"}${msg.rspdesc==null||msg.rspdesc."!value"==null?"".padRight(50," "):msg.rspdesc."!value".padRight(50," ")}', null),
        ('res-core.sms.0200.801000.001001', 1, 'reservedForPrivateUse3', '${head.request.data.body.resitm.reservedForPrivateUse3==null||head.request.data.body.resitm.reservedForPrivateUse3."!value"==null?"":head.request.data.body.resitm.reservedForPrivateUse3."!value"}', null);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('resp-ln.sms', '[sms]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-ln.sms', 1, '/data', '/data', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-ln.sms', 2, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-ln.sms', 1, '@', 'copyMessage()', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-ln.sms', 2, 'messageType', '0210', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-ln.sms', 2, 'responseCode', '${head.source."!value".substring(0,6).equals("sms-10") && head.code."!value".substring(0,7) == "0200.1." && head.source."!value".substring(0,9) != "sms-10802"?"B1":"89"}', 2);


INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('resp-sp.sms', '[sms]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-sp.sms', 1, '/data', '/data', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-sp.sms', 2, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-sp.sms', 1, '@', 'copyMessage()', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-sp.sms', 2, 'messageType', '0210', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-sp.sms', 2, 'responseCode', '68', 2);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('resp-to.sms', '[sms]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-to.sms', 1, '/data', '/data', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('resp-to.sms', 2, '/data/body', '/data/body', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-to.sms', 1, '@', 'copyMessage()', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-to.sms', 2, 'messageType', '0210', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('resp-to.sms', 2, 'responseCode', '${head.source."!value".substring(0,6).equals("sms-10") && head.code."!value".substring(0,7) == "0200.1." && head.source."!value".substring(0,9) != "sms-10802"?"B1":"68"}', 2);

INSERT INTO MWCONFIG.MAPPING (ID, MODULE, MODIFIED_BY, TIMESTAMP) VALUES ('checkBillerResp', '[sms]', CURRENT USER, CURRENT TIMESTAMP);
INSERT INTO MWCONFIG.MAPPING_GROUP (MAPPING_ID, ID, SOURCE, TARGET, INCLUDE_MAPPING_ID, INCLUDE_ID) VALUES ('checkBillerResp', 1, '/data', '/data', NULL, NULL);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('checkBillerResp', 1, '@', 'copyMessage();', 1);
INSERT INTO MWCONFIG.MAPPING_GROUP_LINE (MAPPING_ID, MAPPING_GROUP_ID, NAME, TEXT, SEQ) VALUES ('checkBillerResp', 1, 'coreAct', '${getParamValue("biller.rc.toReverse", msg.type."!value".startsWith("dsp")?msg.body.dspTransactionCode."!value"+"."+msg.body.TLBERR_F2?."!value":(msg.body.reservedPrivate3==null?msg.body.processingCode."!value":msg.body.reservedPrivate3?."!value")+"."+msg.body.messageType?."!value"+"."+msg.body.responseCode?."!value","not")}', 10);