Skip to content

Commit

Permalink
Feature/merge various changes (#34)
Browse files Browse the repository at this point in the history
* Result of PD merge

* Added parent and child model to relationship export

* Add SQL Expression on attribute mapping level

* Update mdde_Mapping_Stereotyped_XmlExport_Template.xml

* process review comments

* process review comments

* Process review comments

* review comments

* review comments

* Updated upload artifacts action to v4.

---------

Co-authored-by: Willem Otten <willem.otten@rabobank.com>
Co-authored-by: Willem Otten <willem@crossbreeze.nl>
Co-authored-by: Harmen Wessels <harmen@x-breeze.com>
  • Loading branch information
4 people authored Jan 23, 2025
1 parent e652408 commit a6b7707
Show file tree
Hide file tree
Showing 49 changed files with 754 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .github/actions/compose_and_publish_artifacts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ runs:
run: ./compose.ps1
shell: pwsh
- name: Publish XEM
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: MDDE Extension
path: ./composed/extensions/*.xem
- name: Publish sample models
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Sample models
path: ./composed/models/*.ldm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,20 @@ Function GetRealObject(objItemOrShortcut)
Set GetRealObject = Nothing
Exit Function
End If
If (objItemOrShortcut.IsShortcut) Then
If (objItemOrShortcut.IsShortcut) Then
Set GetRealObject = Nothing
&#39; If the object is a shortcut, open the target model.
objItemOrShortcut.TargetModelDefinition.AskForLoad False
&#39; Return the TargetObject of the shortcut.
Set GetRealObject = objItemOrShortcut.TargetObject
If not objItemOrShortcut.TargetModelDefinition is Nothing Then
objItemOrShortcut.TargetModelDefinition.AskForLoad False
&#39; Return the TargetObject of the shortcut.
If not objItemOrShortcut.TargetObject Is Nothing Then
Set GetRealObject = objItemOrShortcut.TargetObject
Else
WriteError objectItemOrShortcut.DisplayName &amp; &quot; appears to be a broken shortcut, target object could not be found in target model&quot;
End if
Else
WriteError objectItemOrShortcut.DisplayName &amp; &quot; appears to be a broken shortcut, target model could not be resolved&quot;
End if
Else
&#39; If the object is not a shortcut, return the passed object.
Set GetRealObject = objItemOrShortcut
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<o:CustomCheckTargetItem Id="C234C787-E4C5-4E8B-BD58-432AA676EF37">
<a:ObjectID>C234C787-E4C5-4E8B-BD58-432AA676EF37</a:ObjectID>
<a:Name>Check window business rule not a source of a pivot business rule (MDDE)</a:Name>
<a:CreationDate>1725522003</a:CreationDate>
<a:Creator>DijkC1</a:Creator>
<a:Comment>A window business rule cannot be used as a source for a pivot business rule.</a:Comment>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<a:HelpMessage>This check ensures that window business rules cannot be used as a source for a pivot business rule. </a:HelpMessage>
<a:OutputMessage>The following objects have implemented window business rule where they are not allowed:</a:OutputMessage>
<a:CheckScript>Function %Check%(obj)
%Check% = True

&#39; Retrieve the source objects from the mapping.
Dim colSourceObjects : Set colSourceObjects = obj.GetExtendedCollection(&quot;mdde_SourceObjects&quot;)

&#39; If the mapping has no source objects, stop here.
If colSourceObjects.Count = 0 Then
Exit Function
End If

Dim objSourceObject
For Each objSourceObject In colSourceObjects
Dim joinedObject : Set joinedObject = GetRealObject(objSourceObject.GetExtendedAttribute(&quot;mdde_JoinedObject&quot;))
If Not joinedObject Is Nothing Then
If joinedObject.HasStereotype(&quot;mdde_WindowBusinessRule&quot;) Then
%Check% = False
WriteError joinedObject.DisplayName &amp; &quot; is a window business rule and cannot be used as source in a mapping on a pivot business rules.&quot;
End if
End If
Next

End Function</a:CheckScript>
<a:AutoFixScrpt>Function %Fix%(obj, outmsg)
&#39; Implement your automatic correction on &lt;obj&gt; here
&#39; filling &lt;outmsg&gt; as you wish
&#39; and return True if successful.

outmsg = &quot;Automatic correction not implemented&quot;

%Fix% = False
End Function</a:AutoFixScrpt>
</o:CustomCheckTargetItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<o:TypedCategoryTargetItem Id="CF376183-4E9E-435F-B877-E4333D72215E">
<a:TypePublicName>CustomCheckTargetItem</a:TypePublicName>
<a:ObjectID>CF376183-4E9E-435F-B877-E4333D72215E</a:ObjectID>
<a:Name>Custom Checks</a:Name>
<a:CreationDate>1736938699</a:CreationDate>
<a:Creator>OttenW</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="Check_window_business_rule_not_a_source_of_a_pivot_business_rule_(MDDE).xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a:Name>mdde_Mapping_Stereotyped_XmlExport_Template</a:Name>
<a:TemplateTargetItem.Value>&lt;PivotConfig
.if (%mdde_PivotHeaderAttributeSelector%)
PivotHeaderAttribute=&quot;&amp;quot;%mdde_PivotAggregatedAttribute_SourceObject.Code%&amp;quot;.&amp;quot;%mdde_PivotHeaderAttribute.Code%&amp;quot;&quot;
PivotHeaderAttribute=&quot;&amp;quot;%mdde_PivotHeaderAttribute_SourceObject.Code%&amp;quot;.&amp;quot;%mdde_PivotHeaderAttribute.Code%&amp;quot;&quot;
.endif()
.if (%mdde_PivotAggregatedAttributeSelector%)
PivotAggregatedAttribute=&quot;&amp;quot;%mdde_PivotAggregatedAttribute_SourceObject.Code%&amp;quot;.&amp;quot;%mdde_PivotAggregatedAttribute.Code%&amp;quot;&quot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<xi:include href="Extended_Compositions/Extended_Compositions.xml" />
<xi:include href="Methods/Methods.xml" />
<xi:include href="Templates/Templates.xml" />
<xi:include href="Custom_Checks/Custom_Checks.xml" />
</c:Categories>
</o:CriterionTargetItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<o:CustomCheckTargetItem Id="FCCA60D2-047C-4361-8030-B1CBEC8AA429">
<a:ObjectID>FCCA60D2-047C-4361-8030-B1CBEC8AA429</a:ObjectID>
<a:Name>Check window business rule not a source of another joined object (MDDE)</a:Name>
<a:CreationDate>1724147078</a:CreationDate>
<a:Creator>BuwaldaN</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<a:HelpMessage>This check ensures that the output of a window business rule cannot be used as the input of another joined object</a:HelpMessage>
<a:OutputMessage>The following objects are using the output of a window business rule as the input of another joined object:</a:OutputMessage>
<a:CheckScript>Function %Check%(obj)
&#39; Initialize the result with true.
%Check% = True

&#39; Retrieve the source objects from the mapping.
Dim colSourceObjects : Set colSourceObjects = obj.GetExtendedCollection(&quot;mdde_SourceObjects&quot;)

&#39; If the mapping has no source objects, stop here.
If colSourceObjects.Count = 0 Then
Exit Function
End If


&#39; Now loop through all source objects.
Dim objSourceObject
For Each objSourceObject In colSourceObjects
&#39; Check if the joined objects is of type windowbusinessrule
Dim joinedObject : Set joinedObject = GetRealObject(objSourceObject.GetExtendedAttribute(&quot;mdde_JoinedObject&quot;))
If Not joinedObject is Nothing Then
If joinedObject.HasStereotype(&quot;mdde_WindowBusinessRule&quot;) Then
&#39;WriteDebug(&quot;joinedObject: &quot; &amp; joinedObject.ObjectType &amp; &quot; name: &quot; &amp; joinedObject.DisplayName &amp; &quot; stereotype &quot; + joinedObject.StereoType)
&#39;WriteDebug(&quot;objSourceObject: &quot; &amp; objSourceObject.Code &amp; &quot; name: &quot; &amp; objSourceObject.DisplayName &amp; &quot; stereotype &quot; + objSourceObject.StereoType)
&#39;call the function and if it returns true return an error
Dim boolWindowFunctionUsedAsParent : boolWindowFunctionUsedAsParent = windowFunctionUsedAsParent(objSourceObject, colSourceObjects)
If boolWindowFunctionUsedAsParent = True Then
WriteError(&quot;The window function &#39;&quot; &amp; objSourceObject.DisplayName &amp; &quot;&#39; in mapping &#39;&quot; &amp; objSourceObject.ParentObject.DisplayName &amp; &quot;&#39; is used as the parent in another mapping.&quot;)
%Check% = False
End if
End If
End if
Next

End Function


&#39;Function that checks if a window function is used as the parent in another joined object on the same mapping
Function windowFunctionUsedAsParent(ByRef objWindowFunctionSourceObject, ByRef colSourceObjects)
&#39; Initialize the result with false.
windowFunctionUsedAsParent = False

Dim objSourceObject
For Each objSourceObject In colSourceObjects
&#39; Loop over the sourceobjects that are not the from and the window function object itself to determine if they have a join condition with the window function as parent
If objSourceObject &lt;&gt; objWindowFunctionSourceObject Then
If UCase(objSourceObject.GetExtendedAttributeText(&quot;mdde_JoinType&quot;)) &lt;&gt; &quot;FROM&quot; Then
&#39;WriteDebug(&quot;functionobjSourceObject: &quot; &amp; objSourceObject.ObjectType &amp; &quot; name: &quot; &amp; objSourceObject.DisplayName &amp; &quot; stereotype: &quot; &amp; objSourceObject.StereoType)
&#39; loop over the join conditions for the source object
Dim objJoinCondition
For Each objJoinCondition in objSourceObject.GetExtendedCollection(&quot;mdde_JoinConditions&quot;)
Dim objParentSourceObject : Set objParentSourceObject = objJoinCondition.GetExtendedAttribute(&quot;mdde_ParentSourceObject&quot;)
If Not objParentSourceObject is Nothing Then

&#39;WriteDebug(&quot;objParentSourceObject: &quot; &amp; objParentSourceObject.ObjectType &amp; &quot; name: &quot; &amp; objParentSourceObject.DisplayName &amp; &quot; stereotype: &quot; &amp; objParentSourceObject.StereoType)
&#39;if the parentobject is the window function object then set the variable to true
If objParentSourceObject = objWindowFunctionSourceObject Then
windowFunctionUsedAsParent = True
Exit Function
End if
End if
Next
End if
End if
Next
End Function</a:CheckScript>
<a:AutoFixScrpt>Function %Fix%(obj, outmsg)
&#39; Implement your automatic correction on &lt;obj&gt; here
&#39; filling &lt;outmsg&gt; as you wish
&#39; and return True if successful.

outmsg = &quot;Automatic correction not implemented&quot;

%Fix% = False
End Function</a:AutoFixScrpt>
</o:CustomCheckTargetItem>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="mdde_Check_OrderOfSourceObjects.xml" />
<xi:include href="Check_window_business_rule_not_a_source_of_another_joined_object_(MDDE).xml" />
<xi:include href="Check_duplicate_source_objects_(MDDE).xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<o:CustomCheckTargetItem Id="7E963ECB-133F-4252-8652-347D96A4D90E">
<a:ObjectID>7E963ECB-133F-4252-8652-347D96A4D90E</a:ObjectID>
<a:Name>Check data source acces type is read-only (MDDE)</a:Name>
<a:CreationDate>1730454757</a:CreationDate>
<a:Creator>DijkC1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<a:HelpMessage>This check ensures that the datasource has the Access Type set to Read-Only</a:HelpMessage>
<a:OutputMessage>The following objects do not pass custom check:</a:OutputMessage>
<a:CheckScript>Function %Check%(obj)
%Check% = True

If obj.AccessType &lt;&gt; &quot;RO&quot; Then
%Check% = False
WriteError &quot;Data source &quot; &amp; obj.DisplayName &amp; &quot; should have access type read-only&quot;
End if

End Function</a:CheckScript>
<a:AutoFixScrpt>Function %Fix%(obj, outmsg)
%Fix% = False
obj.AccessType = &quot;RO&quot;
If obj.AccessType = &quot;RO&quot; Then
%Fix% = True
WriteInfo &quot;Datasource &quot; &amp; obj.DisplayName &amp; &quot; set to Read-Only&quot;
End if
End Function</a:AutoFixScrpt>
<a:EnableAutoFix>1</a:EnableAutoFix>
</o:CustomCheckTargetItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<o:TypedCategoryTargetItem Id="55D68311-CF03-41A3-BB3B-6C9C8C8CBE10">
<a:TypePublicName>CustomCheckTargetItem</a:TypePublicName>
<a:ObjectID>55D68311-CF03-41A3-BB3B-6C9C8C8CBE10</a:ObjectID>
<a:Name>Custom Checks</a:Name>
<a:CreationDate>1730454757</a:CreationDate>
<a:Creator>DijkC1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="Check_data_source_acces_type_is_read-only_(MDDE).xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<a:Creator>WesselsH1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="Custom_Checks/Custom_Checks.xml" />
<xi:include href="Templates/Templates.xml" />
</c:Categories>
</o:CriterionTargetItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<o:CustomCheckTargetItem Id="278FD680-EA0D-49BF-A657-FBA47CE012C4">
<a:ObjectID>278FD680-EA0D-49BF-A657-FBA47CE012C4</a:ObjectID>
<a:Name>Check attribute mapping has valid target attribute (MDDE)</a:Name>
<a:CreationDate>1728549772</a:CreationDate>
<a:Creator>DijkC1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<a:HelpMessage>This check ensures that every attribute mapping has a valid target attribute. To correct this delete the attribute mapping and recreate it.</a:HelpMessage>
<a:OutputMessage>The following objects do not pass custom check:</a:OutputMessage>
<a:CheckScript>Function %Check%(obj)
%Check% = True
If obj.Feature Is Nothing Then
%Check% = False
WriteError(&quot;Mapping &#39;&quot; &amp; obj.Parent.DisplayName &amp; &quot; on entity &quot; &amp; obj.Parent.Classifier.DisplayName &amp; &quot; is missing a target attribute in one of the attribute mappings.&quot;)
End if
End Function</a:CheckScript>
<a:AutoFixScrpt>Function %Fix%(obj, outmsg)
&#39; Implement your automatic correction on &lt;obj&gt; here
&#39; filling &lt;outmsg&gt; as you wish
&#39; and return True if successful.

outmsg = &quot;Automatic correction not implemented&quot;

%Fix% = False
End Function</a:AutoFixScrpt>
</o:CustomCheckTargetItem>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<a:Creator>WesselsH1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="Check_attribute_mapping_has_valid_target_attribute_(MDDE).xml" />
<xi:include href="mdde_Check_AttributeMappingHasValidSourceObject.xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
.if (%Comment%)
&lt;Comment&gt;%.X:Comment%&lt;/Comment&gt;
.endif(\n)
.comment only display the sql expression if stereotype is a mdde_sourceobject of type business rule
.if (%.D:mdde_SourceObject%) &amp;&amp; (%SourceFeature%)
.if (%SourceFeature.Entity.Stereotype% == &quot;mdde_WindowBusinessRule&quot;)
.if (%.D:mdde_SourceObject.mdde_SqlExpression?%)
&lt;SourceObjectSqlExpression&gt;&quot;%.XD:mdde_SourceObject.mdde_SqlExpression%&quot;&lt;/SourceObjectSqlExpression&gt;
.endif(\n)
.endif
.endif
.comment Add the content of the export extension template
.if (%Model.mdde_Export_Extension_Attached%)
.if(%.D:mddex_BaseStructuralFeatureMapping_Export_Content%)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<o:TypedCategoryTargetItem Id="69723AD0-FBFD-40D1-BFCC-73527B302F80">
<a:TypePublicName>CriterionTargetItem</a:TypePublicName>
<a:ObjectID>69723AD0-FBFD-40D1-BFCC-73527B302F80</a:ObjectID>
<a:Name>Criteria</a:Name>
<a:CreationDate>1724142194</a:CreationDate>
<a:Creator>BuwaldaN</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="IsEntityNotWindowFunction/IsEntityNotWindowFunction.xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<o:TypedCategoryTargetItem Id="7BBEDCB3-FEE6-4532-9465-2D4764511DF3">
<o:TypedCategoryTargetItem Id="1DAAE9C4-578C-483D-BF9B-047769B1EDFF">
<a:TypePublicName>CustomCheckTargetItem</a:TypePublicName>
<a:ObjectID>7BBEDCB3-FEE6-4532-9465-2D4764511DF3</a:ObjectID>
<a:ObjectID>1DAAE9C4-578C-483D-BF9B-047769B1EDFF</a:ObjectID>
<a:Name>Custom Checks</a:Name>
<a:CreationDate>1657120038</a:CreationDate>
<a:Creator>WesselsH1</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="mdde_ExpressionBusinessRule_Example_CheckAttributeAndValues.xml" />
<xi:include href="mdde_Check_BusinessRuleHasAtLeastOneExample.xml" />
<xi:include href="mdde_Check_BusinessRuleHasAtLeastOneInputAttribute.xml" />
</c:Categories>
</o:TypedCategoryTargetItem>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<o:CustomCheckTargetItem Id="71C36100-3A41-4014-8072-2A0AF67EA716">
<a:ObjectID>71C36100-3A41-4014-8072-2A0AF67EA716</a:ObjectID>
<o:CustomCheckTargetItem Id="77F9CA88-2C29-46E5-9147-3AB8F74382D8">
<a:ObjectID>77F9CA88-2C29-46E5-9147-3AB8F74382D8</a:ObjectID>
<a:Name>mdde_Check_BusinessRuleHasAtLeastOneExample</a:Name>
<a:CreationDate>1657118746</a:CreationDate>
<a:Creator>WesselsH1</a:Creator>
Expand All @@ -9,7 +9,6 @@
<a:OutputMessage>The following business rules have no examples specified:</a:OutputMessage>
<a:CheckScript>Function %Check%(obj)
%Check% = True

Dim colExamples : Set colExamples = obj.GetExtendedCollection(&quot;mdde_BusinessRule_Examples&quot;)
If colExamples Is Nothing Then
WriteError(&quot;BusinessRule &#39;&quot; &amp; obj.DisplayName &amp; &quot;&#39; has no examples collection!&quot;)
Expand All @@ -18,7 +17,6 @@
WriteError(&quot;BusinessRule &#39;&quot; &amp; obj.DisplayName &amp; &quot;&#39; has no examples specified!&quot;)
%Check% = False
End If

End Function</a:CheckScript>
<a:AutoFixScrpt>Function %Fix%(obj, outmsg)
&#39; Implement your automatic correction on &lt;obj&gt; here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<o:CustomCheckTargetItem Id="C46720A9-A59F-4098-BCFD-1FF4DD871221">
<a:ObjectID>C46720A9-A59F-4098-BCFD-1FF4DD871221</a:ObjectID>
<o:CustomCheckTargetItem Id="B3E7954D-881A-407E-8EAC-9477BDF18F9D">
<a:ObjectID>B3E7954D-881A-407E-8EAC-9477BDF18F9D</a:ObjectID>
<a:Name>mdde_ExpressionBusinessRule_Example_CheckAttributeAndValues</a:Name>
<a:CreationDate>1657120027</a:CreationDate>
<a:Creator>WesselsH1</a:Creator>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<o:CriterionTargetItem Id="366C8C4C-536C-430D-A714-D5AA49608E63">
<a:ObjectID>366C8C4C-536C-430D-A714-D5AA49608E63</a:ObjectID>
<a:Name>IsEntityNotWindowFunction</a:Name>
<a:CriterionTargetItem.Value>%mdde_Entity_IsWindowBusinessRule% == &quot;False&quot;</a:CriterionTargetItem.Value>
<a:CreationDate>1724142194</a:CreationDate>
<a:Creator>BuwaldaN</a:Creator>
<a:TargetCategory.Type>1</a:TargetCategory.Type>
<c:Categories>
<xi:include href="Custom_Checks/Custom_Checks.xml" />
</c:Categories>
</o:CriterionTargetItem>
Loading

0 comments on commit a6b7707

Please sign in to comment.