Skip to content

Commit

Permalink
Updated ExampleDWH model to enable exporting SQL Expression for expre…
Browse files Browse the repository at this point in the history
…ssion business rule source objects.

Updated Calculate_Order_Age so the parameter names are overlapping, to verify RegExp replace behavriour.
  • Loading branch information
harmen-xb committed May 22, 2024
1 parent 20c3476 commit d2c99c3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 50 deletions.
23 changes: 14 additions & 9 deletions decomposed/models/ExampleDWH/EXAMPLEDWH.model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,20 @@
</Mappings>
</CustomBusinessRule>
<ScalarBusinessRule Id="5C9CA8A8-333C-4FC6-9C9A-84546F24EDE0" Code="Calculate_Order_Age" Name="Calculate_Order_Age" Stereotype="mdde_ScalarBusinessRule">
<Comment>Calculate the age of order</Comment>
<Comment>Calculate the age of order

Note: the Date_ and Date_Order attribute names are like this to verify the behaviour of the RegExp replacement for the resolved SQL Expression in source objects where expression business rules are used.</Comment>
<Attributes>
<InputAttribute Id="53DE74F2-F420-48D6-A2A7-176CC3150818" Code="ORDER_DATE" Name="Order Date" Stereotype="mdde_InputAttribute" Ordinal="1" PdDataType="DT" PdLength="0" PdPrecision="0"></InputAttribute>
<InputAttribute Id="7B8233A5-359F-4372-9693-5AA2D4A3E458" Code="CURRENT_DATE" Name="Current Date" Stereotype="mdde_InputAttribute" Ordinal="2" PdDataType="DT" PdLength="0" PdPrecision="0"></InputAttribute>
<InputAttribute Id="7B8233A5-359F-4372-9693-5AA2D4A3E458" Code="DATE_" Name="Date_" Stereotype="mdde_InputAttribute" Ordinal="1" PdDataType="DT" PdLength="0" PdPrecision="0"></InputAttribute>
<InputAttribute Id="53DE74F2-F420-48D6-A2A7-176CC3150818" Code="DATE_ORDER" Name="Date_Order" Stereotype="mdde_InputAttribute" Ordinal="2" PdDataType="DT" PdLength="0" PdPrecision="0"></InputAttribute>
<OutputAttribute Id="742B3F05-D053-4323-9052-6D641E3BF52F" Code="ORDER_AGE_IN_DAYS" Name="Order Age In Days" Stereotype="mdde_OutputAttribute" Ordinal="3" PdDataType="I" PdLength="0" PdPrecision="0"></OutputAttribute>
</Attributes>
<SqlExpression>DATEDIFF(DAY, @ORDER_DATE, @CURRENT_DATE) AS ORDER_AGE_IN_DAYS</SqlExpression>
<SqlExpression>DATEDIFF(DAY, @DATE_ORDER, @DATE_) AS ORDER_AGE_IN_DAYS</SqlExpression>
<Examples>
<Example Id="3A317AF5-67EA-441F-B1EE-014074A069BE" Code="Example_Order_Age" Name="Example Order Age" Stereotype="mdde_Example">
<ExampleInput>
<ExampleInputAttributeValue Attribute="ORDER_DATE" Value="&#39;2023-04-01&#39;" />
<ExampleInputAttributeValue Attribute="CURRENT_DATE" Value="&#39;2023&#39;" />
<ExampleInputAttributeValue Attribute="DATE_ORDER" Value="&#39;2023-04-01&#39;" />
<ExampleInputAttributeValue Attribute="DATE_" Value="&#39;2023&#39;" />
</ExampleInput>
<ExpectedScalarOutput>
<ExpectedOutputAttributeValue Attribute="ORDER_AGE_IN_DAYS" Value="2" />
Expand Down Expand Up @@ -190,12 +192,14 @@
<JoinCondition ChildAttribute="FIRST_NAME" JoinOperator="=" ParentAttribute="&quot;Customer&quot;.&quot;FIRSTNAME&quot;" ParentIsLiteralValue="false" />
<JoinCondition ChildAttribute="LAST_NAME" JoinOperator="=" ParentAttribute="&quot;Customer&quot;.&quot;LASTNAME&quot;" ParentIsLiteralValue="false" />
</JoinConditions>
<SqlExpression>Customer.FirstName || &#39; &#39; || Customer.LastName AS FULL_NAME</SqlExpression>
</SourceObject>
<SourceObject Id="6DB43891-22B1-48D1-8BDC-27987FA6D4D0" Code="Filter_FromNL" Name="Filter_FromNL" Stereotype="mdde_SourceObject" JoinedObject="Filter_FromNL" JoinedObjectModel="EXAMPLEDWH" JoinType="APPLY">
<FilterBusinessRule Id="E1395C49-53C1-4F30-A69D-5E523DF67CD1" Code="Filter_FromNL" Name="Filter_FromNL" Stereotype="mdde_FilterBusinessRule" />
<JoinConditions>
<JoinCondition ChildAttribute="COUNTRY_CODE" JoinOperator="=" ParentAttribute="&quot;Country&quot;.&quot;CODE&quot;" ParentIsLiteralValue="false" />
</JoinConditions>
<SqlExpression>Country.Code = &#39;NL&#39;</SqlExpression>
</SourceObject>
</SourceObjects>
<AttributeMappings>
Expand Down Expand Up @@ -268,7 +272,7 @@
<InputAttribute Id="01123E25-DC0F-4396-A487-1328F1D44134" Code="LAST_NAME" Name="Last Name" Stereotype="mdde_InputAttribute" Ordinal="2" PdDataType="VA55" PdLength="55" PdPrecision="0"></InputAttribute>
<OutputAttribute Id="C979CF59-70EA-4B3F-B2FE-2919D9BABF85" Code="FULL_NAME" Name="Full Name" Stereotype="mdde_OutputAttribute" Ordinal="3" PdDataType="VA110" PdLength="110" PdPrecision="0"></OutputAttribute>
</Attributes>
<SqlExpression>FIRST_NAME || &#39; &#39; || LAST_NAME AS FULL_NAME</SqlExpression>
<SqlExpression>@FIRST_NAME || &#39; &#39; || @LAST_NAME AS FULL_NAME</SqlExpression>
<Examples>
<Example Id="6AB09887-AA4D-4A92-BD85-34A26EF2DAEF" Code="Example_full_name" Name="Example full name" Stereotype="mdde_Example">
<ExampleInput>
Expand Down Expand Up @@ -364,9 +368,10 @@
<SourceObject Id="0F2EE1DB-8E68-424B-BBF5-0342A9EFE195" Code="Calculate_Order_Age" Name="Calculate_Order_Age" Stereotype="mdde_SourceObject" JoinedObject="Calculate_Order_Age" JoinedObjectModel="EXAMPLEDWH" JoinType="APPLY">
<ScalarBusinessRule Id="5C9CA8A8-333C-4FC6-9C9A-84546F24EDE0" Code="Calculate_Order_Age" Name="Calculate_Order_Age" Stereotype="mdde_ScalarBusinessRule" />
<JoinConditions>
<JoinCondition ChildAttribute="ORDER_DATE" JoinOperator="=" ParentAttribute="&quot;SalesOrder&quot;.&quot;ORDERDATE&quot;" ParentIsLiteralValue="false" />
<JoinCondition ChildAttribute="CURRENT_DATE" JoinOperator="=" ParentAttribute="'2023-12-31'" ParentIsLiteralValue="true" />
<JoinCondition ChildAttribute="DATE_" JoinOperator="=" ParentAttribute="'2023-12-31'" ParentIsLiteralValue="true" />
<JoinCondition ChildAttribute="DATE_ORDER" JoinOperator="=" ParentAttribute="&quot;SalesOrder&quot;.&quot;ORDERDATE&quot;" ParentIsLiteralValue="false" />
</JoinConditions>
<SqlExpression>DATEDIFF(DAY, SalesOrder.OrderDate, &#39;2023-12-31&#39;) AS ORDER_AGE_IN_DAYS</SqlExpression>
</SourceObject>
</SourceObjects>
<AttributeMappings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<a:Code>Calculate_Order_Age</a:Code>
<a:CreationDate>1680508903</a:CreationDate>
<a:Creator>MooOthman</a:Creator>
<a:Comment>Calculate the age of order</a:Comment>
<a:Comment>Calculate the age of order

Note: the Date_ and Date_Order attribute names are like this to verify the behaviour of the RegExp replacement for the resolved SQL Expression in source objects where expression business rules are used.</a:Comment>
<a:History>ORG {41D1B62B-F9B1-4135-AF2D-439AFB15F96E}
DAT 1680508903
ATT STRN
Expand All @@ -18,7 +20,7 @@ ATT LABL</a:History>
</a:Description>
<a:ExtendedAttributesText>{2B8936D7-8688-4269-BCA9-64EBA2E802A8},XBreeze_Model_Extension,66={29131F46-42B1-4DD8-9C6B-A955E3CD33F4},xm_stereotype,9=calculate

{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,125={38253E88-8698-4A5B-8398-0FA2B14556C0},mdde_SqlExpression,62=DATEDIFF(DAY, @ORDER_DATE, @CURRENT_DATE) AS ORDER_AGE_IN_DAYS
{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,118={38253E88-8698-4A5B-8398-0FA2B14556C0},mdde_SqlExpression,55=DATEDIFF(DAY, @DATE_ORDER, @DATE_) AS ORDER_AGE_IN_DAYS

</a:ExtendedAttributesText>
<c:ExtendedCompositions>
Expand Down Expand Up @@ -130,10 +132,19 @@ ATT LABL</a:History>
</o:ExtendedComposition>
</c:ExtendedCompositions>
<c:Attributes>
<o:EntityAttribute Id="7B8233A5-359F-4372-9693-5AA2D4A3E458">
<a:ObjectID>7B8233A5-359F-4372-9693-5AA2D4A3E458</a:ObjectID>
<a:Name>Date_</a:Name>
<a:Code>DATE_</a:Code>
<a:CreationDate>1680525535</a:CreationDate>
<a:Creator>MooOthman</a:Creator>
<a:Stereotype>mdde_InputAttribute</a:Stereotype>
<a:DataType>DT</a:DataType>
</o:EntityAttribute>
<o:EntityAttribute Id="53DE74F2-F420-48D6-A2A7-176CC3150818">
<a:ObjectID>53DE74F2-F420-48D6-A2A7-176CC3150818</a:ObjectID>
<a:Name>Order Date</a:Name>
<a:Code>ORDER_DATE</a:Code>
<a:Name>Date_Order</a:Name>
<a:Code>DATE_ORDER</a:Code>
<a:CreationDate>1680508903</a:CreationDate>
<a:Creator>MooOthman</a:Creator>
<a:History>ORG {87D08732-95C1-401E-9FFF-33AB904D3D4B}
Expand All @@ -144,15 +155,6 @@ ATT STRN</a:History>
<a:Stereotype>mdde_InputAttribute</a:Stereotype>
<a:DataType>DT</a:DataType>
</o:EntityAttribute>
<o:EntityAttribute Id="7B8233A5-359F-4372-9693-5AA2D4A3E458">
<a:ObjectID>7B8233A5-359F-4372-9693-5AA2D4A3E458</a:ObjectID>
<a:Name>Current Date</a:Name>
<a:Code>CURRENT_DATE</a:Code>
<a:CreationDate>1680525535</a:CreationDate>
<a:Creator>MooOthman</a:Creator>
<a:Stereotype>mdde_InputAttribute</a:Stereotype>
<a:DataType>DT</a:DataType>
</o:EntityAttribute>
<o:EntityAttribute Id="742B3F05-D053-4323-9052-6D641E3BF52F">
<a:ObjectID>742B3F05-D053-4323-9052-6D641E3BF52F</a:ObjectID>
<a:Name>Order Age In Days</a:Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a:Creator>MooOthman</a:Creator>
<a:Comment>Merge the firstname and lastname of a customer.</a:Comment>
<a:Stereotype>mdde_ScalarBusinessRule</a:Stereotype>
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,106={38253E88-8698-4A5B-8398-0FA2B14556C0},mdde_SqlExpression,43=FIRST_NAME || &#39; &#39; || LAST_NAME AS FULL_NAME
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,108={38253E88-8698-4A5B-8398-0FA2B14556C0},mdde_SqlExpression,45=@FIRST_NAME || &#39; &#39; || @LAST_NAME AS FULL_NAME

</a:ExtendedAttributesText>
<c:ExtendedCompositions>
Expand Down
5 changes: 2 additions & 3 deletions decomposed/models/ExampleDWH/ExampleDWH.ldm
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ DLD {CA5B68AA-5F42-423A-BA26-0A3F9DE54F2F}
ATT DEFTXEM
ATT OBJEXA</a:History>
<xi:include href="Model/a_ModelOptionsText.xml" />
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,96={3CB69645-4260-4DBC-A602-0536A9D4E6B3},mdde_Export_Extension_Initialization_Successful,5=false

{0297A8FE-93C4-4612-A9E0-CD7292BFF652},MDDE_LDM_Export_Extension,70={AB204437-943D-4423-B8E6-E31186F8B700},mddex_Model_Export_Content,0=
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,205={A3455CE1-6457-40F7-9C0B-599E355AF4DE},mdde_Export_SourceObject_ExpressionBusinessRule_SqlExpression,4=true
{3CB69645-4260-4DBC-A602-0536A9D4E6B3},mdde_Export_Extension_Initialization_Successful,5=false

</a:ExtendedAttributesText>
<c:GenerationOrigins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Entity.Comment 0</a:SymbolContent>
<o:EntitySymbol Id="o26">
<a:CreationDate>1712049767</a:CreationDate>
<a:IconMode>-1</a:IconMode>
<a:Rect>((28875,824), (42075,6600))</a:Rect>
<a:Rect>((28876,825), (42074,6599))</a:Rect>
<a:LineColor>16512</a:LineColor>
<a:FillColor>60416</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@
<a:CreationDate>1690285644</a:CreationDate>
<a:Creator>WesselsH1</a:Creator>
<c:ExtendedComposition.Content>
<o:ExtendedSubObject Id="2B08F648-7DE4-4F5D-B0CC-5BE0F94729DF">
<a:ObjectID>2B08F648-7DE4-4F5D-B0CC-5BE0F94729DF</a:ObjectID>
<a:Name>Join condition_2</a:Name>
<a:Code>Join_condition_2</a:Code>
<a:CreationDate>1709911284</a:CreationDate>
<a:Creator>HarmenWessels</a:Creator>
<a:Stereotype>mdde_JoinCondition</a:Stereotype>
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,80={E9D50277-1E36-464C-9842-5008646943AB},mdde_ParentLiteralValue,12=&#39;2023-12-31&#39;

</a:ExtendedAttributesText>
<c:ExtendedCollections>
<o:ExtendedCollection Id="C41485A7-B110-438D-A20F-9E5950576C5D">
<a:ObjectID>C41485A7-B110-438D-A20F-9E5950576C5D</a:ObjectID>
<a:Name>mdde_ChildAttribute</a:Name>
<a:ExtendedBaseCollection.CollectionName>mdde_ChildAttribute</a:ExtendedBaseCollection.CollectionName>
<a:CreationDate>1709911291</a:CreationDate>
<a:Creator>HarmenWessels</a:Creator>
<c:Content>
<o:EntityAttribute Ref="7B8233A5-359F-4372-9693-5AA2D4A3E458"/>
</c:Content>
</o:ExtendedCollection>
</c:ExtendedCollections>
</o:ExtendedSubObject>
<o:ExtendedSubObject Id="2B91D851-B4F2-45B4-9762-0340E02D5CB2">
<a:ObjectID>2B91D851-B4F2-45B4-9762-0340E02D5CB2</a:ObjectID>
<a:Name>Join condition_1</a:Name>
Expand Down Expand Up @@ -106,29 +129,6 @@
</o:ExtendedCollection>
</c:ExtendedCollections>
</o:ExtendedSubObject>
<o:ExtendedSubObject Id="2B08F648-7DE4-4F5D-B0CC-5BE0F94729DF">
<a:ObjectID>2B08F648-7DE4-4F5D-B0CC-5BE0F94729DF</a:ObjectID>
<a:Name>Join condition_2</a:Name>
<a:Code>Join_condition_2</a:Code>
<a:CreationDate>1709911284</a:CreationDate>
<a:Creator>HarmenWessels</a:Creator>
<a:Stereotype>mdde_JoinCondition</a:Stereotype>
<a:ExtendedAttributesText>{1626A879-DBAC-4E54-8A36-28FCB761FF3A},MDDE_LDM,80={E9D50277-1E36-464C-9842-5008646943AB},mdde_ParentLiteralValue,12=&#39;2023-12-31&#39;

</a:ExtendedAttributesText>
<c:ExtendedCollections>
<o:ExtendedCollection Id="C41485A7-B110-438D-A20F-9E5950576C5D">
<a:ObjectID>C41485A7-B110-438D-A20F-9E5950576C5D</a:ObjectID>
<a:Name>mdde_ChildAttribute</a:Name>
<a:ExtendedBaseCollection.CollectionName>mdde_ChildAttribute</a:ExtendedBaseCollection.CollectionName>
<a:CreationDate>1709911291</a:CreationDate>
<a:Creator>HarmenWessels</a:Creator>
<c:Content>
<o:EntityAttribute Ref="7B8233A5-359F-4372-9693-5AA2D4A3E458"/>
</c:Content>
</o:ExtendedCollection>
</c:ExtendedCollections>
</o:ExtendedSubObject>
</c:ExtendedComposition.Content>
</o:ExtendedComposition>
</c:ExtendedCompositions>
Expand Down

0 comments on commit d2c99c3

Please sign in to comment.