<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">

    <script><![CDATA[
    poolKey = ['INTAKE_OCR_JOIN_DOC_POOL_KEY'];
    ]]></script>

    <pool key="intake_ocr_join_doc" convert-to-map="false">
        <list>
            <script return="poolKey"/>
        </list>
        <body>
            <script><![CDATA[
                import com.workfusion.odf.core.Intake
                import com.workfusion.odf.impl.processor.DocumentOcrLinkProcessor;
                import com.workfusion.odf.service.SplitJoinService;


                String docId = _sys_doc_id.toString();
                Intake intake = Intake.init(binding).params(['_sys_doc_id': docId]).get();
                String transactionId = _sys_transaction_id.toString();
                intake.processTransaction(DocumentOcrLinkProcessor.class, transactionId);
                SplitJoinService splitJoinService = intake.getInstance(SplitJoinService.class);

                merged = splitJoinService.joinTransaction(transactionId, docId);
                ]]></script>
        </body>
    </pool>

    <export include-original-data="false">
        <single-column name="_sys_transaction_id" value="${merged ? _sys_transaction_id : ''}"/>
    </export>

</config>