<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Deploy
- (c) Copyright IBM Corporation 2011, 2017. All Rights Reserved.
- (c) Copyright HCL Technologies Ltd. 2020. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->

<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1"
        xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.air.plugin.multigenartifact.zos"
                name="zOS Utility Generate Artifact Information" version="5"/>
    <description>
      The z/OS Utility Generate Artifact Information plug-in generates one or more informational text based on defined templates. The information is sent to the output properties for use by later steps.
    </description>
    <tag>Utilities/zOS Utility Generate Artifact Information</tag>
  </header>
  <!-- ==================================== -->
  <!-- Generate Version Artifact Information -->
  <!-- ==================================== -->
  <step-type name="Generate Multiple Artifact Information">
    <description>
    Generate multiple text information for selected version artifacts. The information is sent to the output properties for use by later steps.
    </description>
    <properties>
      <property name="loopType" required="true">
        <property-ui type="selectBox"
                     default-value="Member"
                     description="Generate information for each of the selected artifact type."
                     label="For Each"/>
        <value label="PDS Member">Member</value>
        <value label="PDS">PDS</value>
        <value label="Sequential Data Set">Sequential</value>
        <value label="Deleted PDS Member">DeletedMember</value>
        <value label="Deleted PDS">DeletedPDS</value>
        <value label="Deleted Sequential Data Set">DeletedSequential</value>
      </property>
      <property name="orderBy" required="true">
        <property-ui type="selectBox"
                     default-value="ASC" label="Order By"/>
        <value label="ASC Order">ASC</value>
        <value label="DESC Order">DESC</value>
        <value label="Shiplist Order">SHIPLIST</value>
      </property>
      <property name="srcDatasetName" required="false">
        <property-ui type="textAreaBox" label="Container Name Filter JSON"
                     default-value=""
                     description="The filter to limit Source datasets in template for an output property. Specify the filter as a Java regular expression matching which must begin and end with a forward slash (/). For example, /.*LOAD/ matches any text that ends with LOAD. If the filter is not a regular expression, exact matching is used."/>
      </property>
      <property name="datasetName" required="false">
        <property-ui type="textAreaBox" label="Target Data Set Name Filter JSON"
                     default-value=""
                     description="The filter to limit Target datasets in template for an output property. Specify the filter as a Java regular expression matching which must begin and end with a forward slash (/). For example, /.*LOAD/ matches any text that ends with LOAD. If the filter is not a regular expression, exact matching is used."/>
                    </property>
      <property name="memberName" required="false">
        <property-ui type="textAreaBox" label="Resource Name Filter JSON"
                     default-value=""
                     description="The filter to limit PDS Members in template for an output property. Specify the filter as a Java regular expression matching which must begin and end with a forward slash (/). For example, /PGM.*/ matches any text that starts with PGM. If the filter is not a regular expression, exact matching is used."/>
      </property>
      <property name="deployTypeName" required="false">
        <property-ui type="textAreaBox" label="Deploy Type Filter JSON"
                     default-value=""
                     description="The filter to limit Deploy Types in template for an output property. Specify the filter as a Java regular expression matching which must begin and end with a forward slash (/). For example, specify /.*SRC.*/ to match any text that contains SRC. If the filter is not a regular expression, exact matching is used."/>
      </property>
      <property name="custProperties" required="false">
        <property-ui type="textAreaBox" label="Custom Properties Filter JSON"
                     default-value="" description="The filter to limit Custom properties in the template for an output property. Specify each filter in the format: propertyName=valueFilter and separate each filter with a newline character.  A property without a value selects all artifacts related to the specified property. Java regular expression matching is used if the filter begins and ends with a forward slash (/). For example, developer=/M.*/ matches artifacts for the developer property where the value of the property starts with M."/>
      </property>

      <property name="templateText" required="true">
        <property-ui type="textAreaBox"
                     description="Define template for each output property to generate customized text. Subsequent steps can access the customized text with ${p:Step-Name/output-property-name}. For example: If the step name is 'Bind Card Generator' and output property is 'CicsBindText' then the property can be referred in subsequent steps as ${p:Bind Card Generator/CicsBindText} . Add separators like comma or newline using character ',' or '\n' in the template as needed. 
                     Use ${propname} to access custom properties. 
                     The following built-in properties are available:
                     ${sourceDataset} for the source dataset name,
                     ${dataset} for the target dataset name,
                     ${member} for the member name and
                     ${deployType} for the deployment type.
                     All property names are case-sensitive. Do not use the built-in names for custom properties."
                     label="Template JSON" default-value='{ "prop1" : " ${dataset}, ", "prop2" : " ${member}, ", "prop3" : " ${dataset}(${member}), " }'/>
      </property>
      <property name="ignoreUnresolved">
         <property-ui default-value="false" description="Check this box to ignore unresolved properties in template. On Default(unchecked) this step will fail if any unresolved properties are found." label="Ignore unresolved properties" type="checkBox"/>
      </property>
      <property name="deployAction" required="false">
        <property-ui type="textAreaBox" label="Deployment action Filter JSON"
                     default-value="" description="The filter to limit target datasets and members based on type of deployment action performed. Possible action values are 'created' or 'updated'. For example: If the action value is set to 'created' then artifacts which are newly created in target environment are selected. Note: Action values are case insensitive. If value is empty or no value is passed then both 'created' and 'updated' artifacts are selected."/>
      </property>
      
      <property name="deployBasePath">
        <property-ui default-value="${BUZ_DEPLOY_BASE}"
                     description="The base location to store deployment results and backups for rollback. "
                     hidden="true" label="Deployment Base Path" type="textBox"/>
      </property>
      <property name="versionName">
        <property-ui default-value="${p:version.name}" hidden="true" label="Version Name" type="textBox"/>
      </property>
      <property name="componentName">
        <property-ui default-value="${p:component.name}" hidden="true" label="Component Name" type="textBox"/>
      </property>
      <property name="resourceId" required="true">
        <property-ui default-value="${p:resource.id}" hidden="true" label="Resource Id" 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="-jar"/>
      <arg file="plugins-zos-multi-generate-artifact-info.jar"/>
      <arg value="MultiGenerateArtifactInfo"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
