I'm trying to nest a forloop container within another. I keep getting error that child element is not allowed.
How do I nest for loop?
<ForLoop Name="For loop for Year">
<PrecedenceConstraints>
<Inputs>
<Input OutputPathName="Find count of rows.Output" SsisName="No data exist" PathAnnotation="ConstraintName" EvaluationOperation="Expression" EvaluationValue="Success" Expression="#[User::CountRows]==0" />
</Inputs>
</PrecedenceConstraints>
<InitializerExpression>#StartYear</InitializerExpression>
<LoopTestExpression><![CDATA[#StartYear <= #EndYear]]></LoopTestExpression>
<CountingExpression><![CDATA[#StartYear = #StartYear + 1]]></CountingExpression>
<ForLoop Name="For loop for Month">
<InitializerExpression>#StartMonth</InitializerExpression>
<LoopTestExpression><![CDATA[#StartMonth <= #EndMonth]]></LoopTestExpression>
<CountingExpression>#StartMonth = #StartMonth + 1</CountingExpression>
</ForLoop>
</ForLoop>
A ForLoop is a member of the Tasks collection. You have specified that your inner ForLoop is a member of the outer ForLoop. Instead, it should be a member of the outer ForLoop's Task collection.
Thus
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="so_46415142">
<Variables>
<Variable Name="StartYear" DataType="Int32">2014</Variable>
<Variable Name="EndYear" DataType="Int32">2014</Variable>
<Variable Name="StartMonth" DataType="Int32">1</Variable>
<Variable Name="EndMonth" DataType="Int32">6</Variable>
</Variables>
<Tasks>
<ForLoop Name="For loop for Year">
<!--
<PrecedenceConstraints>
<Inputs>
<Input OutputPathName="Find count of rows.Output" SsisName="No data exist" PathAnnotation="ConstraintName" EvaluationOperation="Expression" EvaluationValue="Success" Expression="#[User::CountRows]==0" />
</Inputs>
</PrecedenceConstraints>
-->
<InitializerExpression>#StartYear</InitializerExpression>
<LoopTestExpression><![CDATA[#StartYear <= #EndYear]]></LoopTestExpression>
<CountingExpression><![CDATA[#StartYear = #StartYear + 1]]></CountingExpression>
<Tasks>
<ForLoop Name="For loop for Month">
<InitializerExpression>#StartMonth</InitializerExpression>
<LoopTestExpression><![CDATA[#StartMonth <= #EndMonth]]></LoopTestExpression>
<CountingExpression>#StartMonth = #StartMonth + 1</CountingExpression>
</ForLoop>
</Tasks>
</ForLoop>
</Tasks>
</Package>
</Packages>
</Biml>
Related
I load this DMN file (dmnFile):
<definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns:ns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/">
<itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<typeRef>NumberDefinition</typeRef>
</itemComponent>
</itemDefinition>
<itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<typeRef>number</typeRef>
</itemDefinition>
<inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="MyItemDefinition" />
</inputData>
<decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<informationRequirement>
<requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</informationRequirement>
<context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<contextEntry>
<variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</text>
</literalExpression>
</contextEntry>
<contextEntry>
<literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<text>containsMyNumber</text>
</literalExpression>
</contextEntry>
</context>
</decision>
</definitions>
like this:
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.2"), ks.getResources().newFileSystemResource(dmnFile));
and I get an exception with the following error message:
[Message [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1
text=DMN: Unable to resolve type reference '{http://www.omg.org/spec/DMN/20180521/MODEL/}NumberDefinition' on node 'MyItemDefinition' (resource: C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, DMN id: _29d92e98-3c97-67a3-22f1-d342622424f7, The listed type definition was not found) ]]
Type reference with prefix ("ns:NumberDefinition") results in the following error message:
[Message [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1
text=DMN: Unable to resolve type reference '{http://www.omg.org/spec/DMN/20180521/MODEL/}ns:NumberDefinition' on node 'MyItemDefinition' (resource: C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, DMN id: _29d92e98-3c97-67a3-22f1-d342622424f7, The listed type definition was not found) ]]
What do I do wrong?
When using DMN 1.1 (xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd") and type references as QNames (with prefixes) I get the expected result.
Since DMNv1.2, the idiomatic way to reference is ns.<itemDef>.
In your original DMN xml file this happens on line 7 and 14.
In summary the file in the idiomatic DMNv1.2 form should be:
<definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns:ns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/">
<itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<typeRef>ns.NumberDefinition</typeRef>
</itemComponent>
</itemDefinition>
<itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<typeRef>number</typeRef>
</itemDefinition>
<inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="ns.MyItemDefinition" />
</inputData>
<decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<informationRequirement>
<requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</informationRequirement>
<context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<contextEntry>
<variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</text>
</literalExpression>
</contextEntry>
<contextEntry>
<literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<text>containsMyNumber</text>
</literalExpression>
</contextEntry>
</context>
</decision>
</definitions>
That said, with your report we uncovered a bug when the DMN xml file is using the DMN namespace as the default namespace, which we are addressing with
DROOLS-4797.
Thank you for the report !
There is a way to avoid being forced to use ns.<itemDef> and simply use <itemDef>, and that is by setting the default namespace in the DMN xml to be the model's namespace, and just prefixing the DMN xml element with the namespace prefix targeting the DMN namespace.
In other words, the file can make use of <itemDef> reference without having to ns. prefix them:
<semantic:definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns:semantic="http://www.omg.org/spec/DMN/20180521/MODEL/">
<semantic:itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<semantic:itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<semantic:typeRef>NumberDefinition</semantic:typeRef>
</semantic:itemComponent>
</semantic:itemDefinition>
<semantic:itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<semantic:typeRef>number</semantic:typeRef>
</semantic:itemDefinition>
<semantic:inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<semantic:variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="MyItemDefinition" />
</semantic:inputData>
<semantic:decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<semantic:variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<semantic:informationRequirement>
<semantic:requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</semantic:informationRequirement>
<semantic:context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<semantic:contextEntry>
<semantic:variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<semantic:literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<semantic:text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</semantic:text>
</semantic:literalExpression>
</semantic:contextEntry>
<semantic:contextEntry>
<semantic:literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<semantic:text>containsMyNumber</semantic:text>
</semantic:literalExpression>
</semantic:contextEntry>
</semantic:context>
</semantic:decision>
</semantic:definitions>
In this other variant, the default namespace in the xml is the DMN model's namespace, so any itemDef reference does not need any prefix.
Because the default namespace in the xml is the DMN model's namespace, the xml element need to be prefixed with the namespace prefix targeting now the DMN namespace.
Hope this clarifies and provide an insightful explanation!
I am including a .properties file, which has a list of properties:
configuration.files = file1, file2
configuration.files.file1.source = config/filename1
configuration.files.file2.source = config/filename2
Now I need the paths for each file changed to something like this:
vendor/project/config/filename1
vendor/project/config/filename2
To achieve that, I tried to foreach this list and prepend that suffix and overriding the existing property:
<foreach list="${configuration.files}" target="_prepend-vendor-path" param="file" >
<property name="configuration.files.${file}.source" value="/vendor/project/${configuration.files.${file}.source}" override="true"/>
</foreach>
<target name="_prepend-vendor-path" >
<echo msg="${configuration.files.${file}.source}" />
</target>
This doesn't work and I can't figure out why. Is it even possible to use target names like ${suffix}.name ? If not, how could I achive my goal here?
I just did some workaround for this, writing out the properties and their values to a file and readin them after the loop has finished with override = true:
<target name="_prepend-vendor-path" >
<exec dir="${project.basedir}" command="echo configuration.files.${file}.source = /vendor/project/${configuration.files.${file}.source} >> ${project.temp.config}" passthru="true" checkreturn="true" />
</target>
and after the foreach simply:
<property file="${project.temp.config}" override="true"/>
For some reason the properties won't be overridden in the foreach and I just can't figgure out why, but this little trick made it for me.
You can suffix your property values from your file with the property task using a filterchain and a regular expression replacement:
<?xml version="1.0"?>
<project name="Phing Build Tests" default="append-custom-path" basedir=".">
<target name="append-custom-path">
<property file="prop.properties">
<filterchain>
<replaceregexp>
<regexp pattern="^(.*)" replace="vendor/project/$1"/>
</replaceregexp>
</filterchain>
</property>
<echo>${configuration.files.file1.source}</echo>
<echo>${configuration.files.file2.source}</echo>
</target>
</project>
When I use GetDropAndCreateDdl to generate CREATE scripts for tables, I get datatypes for columns that are different than what the datatypes actually are.
This results in a package validation error that "the error output has properties that do not match the properties of its corresponding data source column" and a validation status of "VS_NEEDSNEWMETADATA".
If I right-click the connection source, select Show Advanced Editor, and take a look at the Column Mappings, I can see that [Column1] in the Available External Columns list has a different Length than the datatype that was generated in the GetDropAndCreateDdl. I can delete and re-create the metadata mappings, but that is not a viable solution since there are many dataflow tasks.
How do I get GetDropAndCreateDdl to create the correct datatypes with correct lengths?
I am using ImportDB to get the list of tables, metadata, etc.
Environment.biml
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OdbcConnection Name="OdbcSrc_DV" ConnectionString="Dsn=Source-32bit-test;" />
<OleDbConnection Name="OleDbDst_Staging" ConnectionString="Provider=SQLNCLI11;Server=SQL-DEV;Initial Catalog=Source_Staging;Integrated Security=SSPI;" />
</Connections>
<Databases>
<Database Name="Source" ConnectionName="OdbcSrc_DV" />
<Database Name="Source_Staging" ConnectionName="OleDbDst_Staging" />
</Databases>
<Schemas>
<Schema Name="dbo" DatabaseName="Source" />
<Schema Name="dbo" DatabaseName="Source_Staging" />
</Schemas>
</Biml>
CreateTableMetadata.biml
<## import namespace="System.Data" #>
<## import namespace="Varigence.Biml.CoreLowerer.SchemaManagement" #>
<#
var sourceConnection = RootNode.DbConnections["OdbcSrc_DV"];
var importResult = sourceConnection.ImportDB("", "", ImportOptions.ExcludeForeignKey | ImportOptions.ExcludeColumnDefault | ImportOptions.ExcludeViews);
var tableNamesToImport = new List<string>() { "Test_Table" };
#>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Tables>
<# foreach (var table in importResult.TableNodes.Where(item => tableNamesToImport.Contains(item.Name)).OrderBy(item => item.Name)) { #>
<Table Name="<#=table.Name#>" SchemaName="Source.dbo">
<Columns>
<#=table.Columns.GetBiml()#>
</Columns>
<Annotations>
<Annotation AnnotationType="Tag" Tag="SourceSchemaQualifiedName"><#=table.SchemaQualifiedName#></Annotation>
</Annotations>
</Table>
<# } #>
</Tables>
</Biml>
DeployTargetTables.biml
<## template tier="2" #>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="MasterTableDeploy" ConstraintMode="Parallel">
<Tasks>
<# foreach (var table in RootNode.Tables) { #>
<ExecuteSQL Name="SQL CREATE <#=table.Name#>" ConnectionName="OleDbDst_Staging">
<DirectInput><#=table.GetDropAndCreateDdl()#></DirectInput>
</ExecuteSQL>
<# } #>
</Tasks>
</Package>
</Packages>
</Biml>
CreateLoadPackages.biml
<## template tier="2" #>
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="Copy Data" ConstraintMode="Parallel">
<Tasks>
<# foreach (var table in RootNode.Tables) { #>
<ExecuteSQL Name="SQL TRUNCATE <#=table.Name#>" ConnectionName="OleDbDst_Staging">
<DirectInput>TRUNCATE TABLE <#=table.Name#></DirectInput>
</ExecuteSQL>
<Dataflow Name="DFT LOAD <#=table.Schema.Name#>_<#=table.Name#>">
<PrecedenceConstraints>
<Inputs>
<Input OutputPathName="SQL TRUNCATE <#=table.Name#>.Output" />
</Inputs>
</PrecedenceConstraints>
<Transformations>
<OdbcSource Name="ODBC_SRC <#=table.Name#>" Connection="OdbcSrc_DV">
<DirectInput>SELECT <#=table.GetColumnList()#> FROM <#=table.GetTag("SourceSchemaQualifiedName")#></DirectInput>
</OdbcSource>
<OleDbDestination Name="ODBC_DST <#=table.Name#>" ConnectionName="OleDbDst_Staging">
<TableOutput TableName="<#=table.ScopedName#>" />
</OleDbDestination>
</Transformations>
</Dataflow>
<# } #>
</Tasks>
</Package>
</Packages>
</Biml>
Here is the script that gets created from the ODBC source -
And here are the results from INFORMATION_SCHEMA.COLUMNS for the same table -
Have you tried using the newer method: GetDatabaseSchema? I've found it to be much more reliable across different connection types.
http://www.cathrinewilhelmsen.net/2015/07/12/biml-extension-methods-getdatabaseschema/
I have an sql file containing triggers. I want to execute this file using Ant script:
<target name="exec-sql-proc_db2" depends="init">
<property name="project.sql.dir" value="${project.metadata.dir}/sql" />
<property name="triggerFile" value="${project.sql.dir}/triggers_db2.sql" />
<echo message="${triggerFile}" />
<sql rdbms="DB2" driver="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://localhost:50000/project:currentSchema=mySchema;"
userid="root" password="root"
classpath="C:\projects\myProject\lib\db2jcc.jar"
src="${triggerFile}"
onerror="${sql.onerror}"
keepformat="true" delimiter="/" />
</target>
I get build successful, but the triggers are not executed !
Is there any other solution?
my trigger is :
CREATE or REPLACE TRIGGER PRODUCT_HISTORY_AFTER_UPDATE
AFTER UPDATE ON PRODUCT
REFERENCING NEW AS N
FOR EACH ROW
BEGIN
INSERT INTO productHistory ( id_h, id_product , name) values (id_h_seq.nextval, N.id_product , N.name );
END
/
<sql rdbms="DB2" driver="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://localhost:50000/project:currentSchema=mySchema;"
userid="root" password="root"
classpath="C:\projects\myProject\lib\db2jcc.jar"
src="${triggerFile}"
onerror="${sql.onerror}"
delimiter="/" >
SET SCHEMA mySchema
</sql>
I tried this part of code, that solves my problem
In phing i can set this:
<property name="build.myArray" value="something1, something2, something3" />
And then retrieve each value like this:
<foreach list="${build.myArray}" param="replace.me" target="build:create-vhost" />
<target name="build:create-vhost">
<filterchain>
<replacetokens begintoken="#" endtoken="#">
<token key="REPLACE_ME" value="${replace.me}" />
</replacetokens>
</filterchain>
</target>
My question is can i do the same this but using array with keys and values?
Something like that:
<property name="build.myArray" value="myKey = something1, myKey2 => something2, myKey3 => something3" />
and use that key names later
Is is possible to do it?
No, you cannot use properties as array in phing.