LoadData Activity

Build 1501 on 14/Nov/2017  This topic last edited on: 21/Mar/2016, at 19:02

Improvements to the LoadData activity

The binary data content to load can be specified using the new 'DataIds' property that specifies directly the list of binary data ids.

'DataIds' can be bound to a list of ids (integers) or to an individual integer or to a string containing a comma-separated list of ids.

If 'DataIds' is not specified or it is empty - and only in this case - LoadData will use the object ids and the attribute name specified by the 'ObjectIds' and 'AttributeName' properties - i.e. revert to the old behavior.

The LoadData activity has a new (optional) property 'SrcPaths' that specifies the source paths to be assigned to the loaded binary data. This can be useful because other activities - like DataOp or Zip - use the source path to identify data content.

If 'SrcPaths' is not specified the system computes a source path based on either the attribute name or the data id and the data content MIME type (to assign an extension).

'SrcPaths' can be bound to a list of strings or to an individual string - that is considered as a list with a single item. If 'SrcPaths' contains fewer strings than the number of retrieved binary data the extra ones use their default source path.

The following sample demonstrates the use of 'DataIds' and 'SrcPaths' - it extracts the a specific variant from the objects passed to the workflow, and create a ZIP file containing all the resulting files

  <wfres:workFlow

    xmlns:inopt="http://www.teradp.com/schemas/GN4/1/XmlImportOptions.xsd"

    xmlns:wfres="http://www.teradp.com/schemas/GN4/1/WFRes.xsd">

 

    <SequentialWorkflow

      x:Name="mainWorkflow"

      xmlns="http://www.teradp.com/schemas/GN4/1/Workflow/Activity"

      xmlns:gn4wf="http://www.teradp.com/schemas/GN4/1/Workflow"

      xmlns:common="http://www.teradp.com/schemas/GN4/1/Common"

      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      xmlns:wf="http://schemas.microsoft.com/winfx/2006/xaml/workflow"

      xmlns:sys="clr-namespace:System;assembly=mscorlib"

      xmlns:coll="clr-namespace:System.Collections;assembly=mscorlib">

 

      <!-- process the objects one by one -->

      <ObjectsReplicator

        x:Name="replicator"

        ObjectIds="{wf:ActivityBind mainWorkflow, ObjectIds}">

 

        <!-- compute the variant id and output file name (from the object XML) -->

        <LoadObjects

          x:Name="loadFileNames"

          ObjectIds="{wf:ActivityBind replicator, ObjectIdsOut}">

 

          <!-- extract the variant id and output file name -->

          <TransformXml

            x:Name="getFileNames"

            XmlIn="{wf:ActivityBind loadFileNames, Path=XmlOut}">

            <TransformXml.XmlValues>

              <XmlDataArray>

                <XmlValue Key="variantId" XPath="/*/variantId" />

                <XmlValue Key="variantFileName" XPath="/*/variantFileName" />

              </XmlDataArray>

            </TransformXml.XmlValues>

          </TransformXml>

 

          <!-- load the variant - setting its source paths, that will be used as the name in the ZIP -->

          <LoadData

            x:Name="loadVariant"

            DataIds='{wf:ActivityBind getFileNames, Path=XmlValues["variantId"].Value}'

            SrcPaths='{wf:ActivityBind getFileNames, Path=XmlValues["variantFileName"].Value}'/>

 

          <!-- append the variant to the 'Data' list in the main workflow activity -->

          <DataOp

            x:Name="appendVariant"

            Data="{wf:ActivityBind loadVariant, Path=DataOut}"

            DataOut="{wf:ActivityBind mainWorkflow, Path=Data}" />

          

        </LoadObjects>

        

      </ObjectsReplicator>

 

      <!-- create the ZIP from the 'Data' list in the main workflow activity -->

      <Zip

        x:Name="zip"

        Data="{wf:ActivityBind mainWorkflow, Path=Data}"/>

 

      <!-- save the ZIP file -->

      <Save

        x:Name="save"

        Data="{wf:ActivityBind zip, Path=DataOut}"

        To="c:\temp\variants.zip"

        Mode="Overwrite"/>

      

    </SequentialWorkflow>

 

    <eop:XmlExportOptions

      wfres:activityName="loadFileNames"

      xmlns:eop="http://www.teradp.com/schemas/GN4/1/XmlExportOptions.xsd"

      DataMaxSize="0"

      AccessStrict="false"

      MimeType="application/xml">

      <eop:Xslt>

        <root xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

          <xsl:variable name="variantName" select="$pars/*/add[@key='variantName']/@value"/>

          <xsl:variable name="variant" select="gn4:variants/gn4:ref[nav:refObject/gn4:*/@name=$variantName]"/>

          <variantId>

            <xsl:value-of select="fn:dataIdFromString($variant/gn4:data/@id)"/>

          </variantId>

          <variantFileName>

            <xsl:value-of select="concat(@name,$variant/gn4:data/@nav:mimeExt)"/>

          </variantFileName>

        </root>

      </eop:Xslt>

    </eop:XmlExportOptions>

 

  </wfres:workFlow>

The variant to extract is specified by name by the 'variantName' parameter, and the ZIP files is always 'c:\temp\variants.zip'. Note that there is no error handling and that the workflow expects that all the objects have the specified variant. The name of the variant files in the ZIP is the name of the object plus the extension correspnding to the variant MIME type.