PrecedenceConstraints using Transformers

gravatar

Peter Avenant

A follow up on the power of using Transformers in Mist

published 05.20.14

last updated 05.21.14


Share

Tags

  • Transformers

Introduction

I'm currently working with one of our partners to convert the "BidsHelper" framework to Mist and secure their IP using Transformers. I'll post detailed instruction on that subject in the next week or two. One of the things that they do in the first task in every ControlFlow is to check a repository if the package should execute. I have seen similar approaches in various frameworks out there and provide the following code as a demonstration of how you can achieve this using a single transformer. If you are new to Transformers please refer to the BimlScript Transformers Primer.

A Simple DataFlow

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Packages>
        <Package Name="DummyPackage" ConstraintMode="Parallel">
            <Tasks>
                <Dataflow Name="DFT - Dummy">
                    <Annotations>
                        <Annotation AnnotationType="Tag" Tag="AddExecuteCheck">AddExecuteCheck</Annotation>
                    </Annotations>
                </Dataflow>
            </Tasks>
        </Package>
    </Packages>
</Biml>

Add Variables to Package

<#@ target type="Package" mergemode="LocalMerge" #>
<Package>
    <Variables>
        <Variable Name="IsExecutable" DataType="String" Namespace="User">"N"</Variable>
    </Variables>
</Package>

Add Execute SQL Task to DataFlow

<#@ target type="DataflowTask" mergemode="LocalReplace" #>
<#  if (TargetNode.Annotations["AddExecuteCheck"] != null) { #>
<Transformations>
    <ExecuteSQL Name="SQL - Execute Check" ForcedExecutionValueDataType="Empty" ConnectionName="AW" ResultSet="SingleRow">
        <Results>
            <Result Name="0" VariableName="User.IsExecutable" />
        </Results>
        <DirectInput>SELECT 'Y'</DirectInput>
    </ExecuteSQL>
    <#=TargetNode.GetBiml()#>
</Transformations>
<#  } #>
<#@ import namespace="System.Data"

Add PrecedenceConstraint to DataFlow

<#@ target type="DataflowTask" mergemode="LocalMerge" #>
<#  if (TargetNode.Annotations["AddExecuteCheck"] != null) { #>
<DataFlow>
    <PrecedenceConstraints LogicalType="And">
        <Inputs>
            <Input OutputPathName="SQL - Execute Check.Output" EvaluationOperation="ExpressionAndConstraint" Expression="@IsExecutable == &quot;Y&quot;" />
        </Inputs>
    </PrecedenceConstraints>
</DataFlow>
<#  } #>
<#@ import namespace="System.Data" #>
You are not authorized to comment. A verification email has been sent to your email address. Please verify your account.

Comments

There are no comments yet.