<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of HCL
- UrbanCode Deploy
- (c) Copyright HCL Technologies Ltd. 2022. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- Trademark of HCL Technologies Limited
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.plugin.datasetWriter.zos" name="zOS Dataset Writer" version="4"/>
    <description>
      The zOS Dataset Writer plug-in copies input text, dataset or USS file to a mainframe dataset.
	  </description>
    <tag>Utilities/zOS Dataset Writer</tag>
  </header>
  <step-type name="Write to Sequential Dataset">
    <description>Writes input text or dataset or USS file data to a Sequential Dataset.</description>
    <properties>
      <property name="sourceType" required="true">
                <property-ui default-value="TEXT"
                             description="Source of data for writing into Output sequential dataset. Select DATASET to write from a PDS member or sequential dataset, FILE to write from a USS file, or TEXT to write text to output sequential dataset."
                             hidden="false" label="Source Type" type="selectBox"/>
                <value label="TEXT">TEXT</value>
                <value label="DATASET">DATASET</value>
                <value label="FILE">FILE</value>
                <value label="${p?:dataset.writer.source.type}">${p?:dataset.writer.source.type}</value>
      </property>
      <property name="inputText" required="true">
        <property-ui description="Text or PDS member or Sequential Dataset or USS File to be written into a Sequential dataset. If the single quotation marks are omitted, the user's data set prefix from the TSO profile is automatically appended to the front of the data set name. Add encoding of USS File after a comma(,). For example - /path/to/file,UTF-8. If no file encoding is specified, file is considered to be in IBM-1047 encoding. Multiple files or datasets can be passed separated by a newline."
                     label="Source Value" type="textAreaBox"/>
      </property>
      <property name="zDataset" required="true">
        <property-ui description="Name of the output Sequential Dataset. If the single quotation marks are omitted, the user's data set prefix from the TSO profile is automatically appended to the front of the data set name."
                     label="Dataset Name" type="textBox"/>
      </property>
      <property name="isAppend">
                <property-ui default-value="false" label="Append" type="checkBox"
                description="Select to append data to the output dataset" />
            </property>
      <property name="allocateDataset">
         <property-ui default-value="TRUE" description="Specify TRUE to allocate output sequential dataset with passed parameters"
                     label="Allocate Dataset" type="textBox"/>
      </property>
      <property name="deleteExistingDataset">
         <property-ui default-value="TRUE" description="Specify TRUE to delete output Sequential dataset if already exist before allocation"
                     label="Delete Existing Dataset" type="textBox"/>
      </property>
      <property name="volumeSerial" required="false">
                <property-ui default-value="" description="Leave blank to use the system default volume."
                label="Volume Serial" type="textBox"/>
      </property>
      <property name="spaceUnit" required="true">
                <property-ui default-value="TRACKS" description="Dataset space units. Tracks or Cylinders"
                             label="Space Units" type="selectBox"/>
                <value label="TRACKS">TRACKS</value>
                <value label="CYLINDERS">CYL</value>
      </property>
      <property name="averRecUnit" required="false">
                <property-ui default-value="---"
                             description="Select the unit to use when allocating average record length. U specifies single-record units (bytes). K specifies thousand-record units (kilobytes). M specifies million-record units (megabytes). (---) specifies the system default value."
                             hidden="false" label="Average Record Unit" type="selectBox"/>
                <value label="---">---</value>
                <value label="K">K</value>
                <value label="M">M</value>
                <value label="U">U</value>
      </property>
      <property name="primaryQuantity" required="true">
                <property-ui default-value="200" description="Specify the primary quantity in average record units." hidden="false" label="Primary Quantity"
                             type="textBox"/>
      </property>
      <property name="secondaryQuantity" required="true">
                <property-ui default-value="100" description="Specify the secondary quantity in average record units." hidden="false" label="Secondary Quantity"
                             type="textBox"/>
      </property>
      <property name="recordFormat" required="true">
                <property-ui default-value="F,B" description="" hidden="false" label="Record Format" type="selectBox"/>
                <value label="FB">F,B</value>

                <value label="F">F</value>

                <value label="VB">V,B</value>

                <value label="V">V</value>

                <value label="FBA">F,B,A</value>

                <value label="VBA">V,B,A</value>

                <value label="FBM">F,B,M</value>

                <value label="FM">F,M</value>

                <value label="VBM">V,B,M</value>

                <value label="VM">V,M</value>
       </property>
       <property name="recordLength" required="true">
                <property-ui default-value="400" hidden="false" label="Record Length" type="textBox"/>
       </property>
       <property name="blockSize" required="true">
                <property-ui default-value="0"
                             description="Specify the number of bytes of data to place in each block, based on the record length."
                             hidden="false" label="Block Size" type="textBox"/>
       </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${PLUGIN_HOME}/runjava.sh">
      <arg value="-cp"/>
      <arg file="lib/plugins-zos-dataset-writer.jar"/>
      <arg value="com.urbancode.air.plugin.command.DatasetWriter"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
