Working with metadata

Often, while submitting a job or pushing it to a checkpoint’s connections, Switch will require metadata to be entered.  There are basically two types of metadata: metadata that is to be displayed to the user (read-only metadata), and metadata that the user has to provide.  The first is represented with MetadataToDisplayClass, the second with MetadataToFillClass.  For example, when getting information about a job in a checkpoint (using the GetCheckpointJobInfo method), we may get both display metadata and required metadata:
  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:GetCheckpointJobInfoResponse>
       <jobInfo>
         ...
         <jobMetadata>
           <mtdLabel>Metadata Field 1</mtdLabel>
           <mtdDescription/>
           <mtdDataType>string</mtdDataType>
           <mtdValue>hello</mtdValue>
         </jobMetadata>
         <jobRequiresMetadata>true</jobRequiresMetadata>
         <jobRequiredMetadata>
           <mtfLabel>Metadata Field 2</mtfLabel>
           <mtfDescription/>
           <mtfDataType>string</mtfDataType>
           <mtfDataFormat/>
           <mtfValueIsRequired>false</mtfValueIsRequired>
           <mtfRememberLastValue>false</mtfRememberLastValue>
           <mtfValue/>
         </jobRequiredMetadata>
       </jobInfo>    
    </butterfly:GetCheckpointJobInfoResponse>
  </soap:Body>  
Note: For brevity, part of the jobInfo element has been omitted.

Here we can see that there is a display metadata field “Metadata Field 1” with value “hello”, and a second field “Metadata Field 2”, for which we should provide the value.  When pushing the job using  PushCheckpointJob, we provide the value for this field:

  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:PushCheckpointJob>
       <flowId>7</flowId>
       <checkPointId>4</checkPointId>
       <jobId>0006M</jobId>
       <jobInfo href="#id0"/>    
        </butterfly:PushCheckpointJob>    
        <multiRef id="id0" soapenc:root="0"
       soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <jobRequiredMetadata href="#id1"/>
        <metadataXmlStr/>
        <connectionIds>7</connectionIds>
        <jobName>info.txt</jobName>    
         </multiRef>    
        <multiRef id="id1" soapenc:root="0"
       soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <mtfLabel>Metadata Field 2</mtfLabel>
        <mtfDescription/>      
        <mtfDataType>string</mtfDataType>
        <mtfDataFormat/>
        <mtfValueIsRequired>false</mtfValueIsRequired>
        <mtfRememberLastValue>false</mtfRememberLastValue>
        <mtfValue>world</mtfValue>    
       </multiRef>
  </soap:Body>