Creating data binding using an Ant Script

You can use the CICS/IMS Data binding wizard to create an Ant script simply by selecting Save session as Ant script.

Before you begin

Data Discovery Task
  • Discovery agents perform the actual import of data (see the performImport task in the script example) to produce data that is called import result.
  • Resource writers consume the import result (see the writeToWorkspace task in the example script) to produce appropriate application artifacts.

About this task

During the import and generation steps, the discovery agent and the resource writer require a set of user input to be provided. The discovery agent and the resource writer can be paired invarious ways to import and generate the artifact that you want. They are identified by their name (QName). For example, the Cobol discovery agent is identified by the following name: {com/ibm/adapter}CobolDiscoveryAgent.

The following example describes the data discovery section of the Ant script used to generate J2C Data Binding:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:adapter="http://com.ibm.adapter" default="DataBinding1" name="/Test1/DFHCOMMAREA.xml">
    <delete file="error.txt"/>
    <property name="debug" value="true"/>
    <property name="project1" value="Test1"/>
    <target name="DataBinding1">
        <adapter:createProject projectName="${project1}" projectType="Java"/>
        <adapter:discover>
            <adapter:performImport agent="{com/ibm/adapter}CobolDiscoveryAgent">
                <adapter:importResource>
                    <adapter:propertyGroup name="CobolFileGroup">
                        <adapter:propertyElement name="CobolFile" value="D:\samples\CICS\taderc99\taderc99.cbl"/>
                    </adapter:propertyGroup>
                </adapter:importResource>
                <adapter:queryProperties>
                    <adapter:propertyGroup name="ImportProperties">
                        <adapter:propertyElement name="Platform" value="Win32"/>
                        <adapter:propertyElement name="Codepage" value="ISO-8859-1"/>
                        <adapter:propertyElement name="Numproc" value="PFD"/>
                        <adapter:propertyElement name="FloatingPointFormat" value="IEEE 754"/>
                        <adapter:propertyGroup name="ExternalDecimalSignGroup">
                            <adapter:propertyElement name="ExternalDecimalSign" value="ASCII"/>
                        </adapter:propertyGroup>
                        <adapter:propertyGroup name="EndianGroup">
                            <adapter:propertyElement name="Endian" value="Little"/>
                            <adapter:propertyElement name="RemoteEndian" value="Little"/>
                        </adapter:propertyGroup>
                        <adapter:propertyGroup name="CompileOptions">
                            <adapter:propertyElement name="Quote" value="DOUBLE"/>
                            <adapter:propertyElement name="Trunc" value="STD"/>
                            <adapter:propertyElement name="Nsymbol" value="DBCS"/>
                        </adapter:propertyGroup>
                    </adapter:propertyGroup>
                </adapter:queryProperties>
                <adapter:queryResult>
                    <adapter:selectElement name="DFHCOMMAREA"/>
                </adapter:queryResult>
            </adapter:performImport>
            <adapter:writeToWorkspace writer="{com/ibm/adapter/cobol/writer}JAVA_WRITER">
                <adapter:propertyGroup name="COBOLToJavaResourceWriter">
                    <adapter:propertyGroup name="Java Type Name">
                        <adapter:propertyElement name="Project Name" value="${project1}"/>
                        <adapter:propertyElement name="Package Name" value="sample.mm"/>
                        <adapter:propertyElement name="Class Name" value="DFHCOMMAREA"/>
                        <adapter:propertyElement name="Overwrite existing class" value="true"/>
                        <adapter:propertyElement name="GenerationStyle" value="Default"/>
                    </adapter:propertyGroup>
                </adapter:propertyGroup>
            </adapter:writeToWorkspace>
        </adapter:discover>
        <eclipse.refreshLocal depth="infinite" resource="${project1}"/>
        <eclipse.incrementalBuild project="${project1}"/>
        <condition property="errorexist">
            <available file="error.txt" property="errorexist"/>
        </condition>
        <fail if="errorexist" message="BUILD Failed: please see workspace log file or error.txt for details."/>
    </target>
</project>

Here are the details for two tasks in the script:

Procedure

  1. The ant script reports a BUILD FAILED message in the overall status if any of the Ant task fail. An error.txt file reports the failure if the error is propagated up to our ant tasks.
  2. performImport
    • importResource is the resource to be imported. such as a COBOL source.
    • queryProperties is a list of parameters that represent the information required to form a query.
    • importResource is the resource to be imported. such as a COBOL source.
    • queryResult is the selected nodes on the result tree that are used for import as application artifacts.
    • propertyGroup is the structure containing the properties and their values.
  3. writeToWorkspace
    • workspaceResourceWriter is the name of the writer that is used to generate the application artifacts.
    • propertyElement is a list (pairs of property name and property value) that the writer uses for generation.

Feedback