Skip to content

Commit

Permalink
process review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Otten committed Jan 15, 2025
1 parent 639bd61 commit a1fb61e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ Function GetRealObject(objItemOrShortcut)
If not objItemOrShortcut.TargetObject Is Nothing Then
Set GetRealObject = objItemOrShortcut.TargetObject
Else
WriteError objectItemOrShortcut.code & " Appears to be a broken shortcut, target object could not be found in target model"
WriteError objectItemOrShortcut.DisplayName & " appears to be a broken shortcut, target object could not be found in target model"
End if
Else
WriteError objectItemOrShortcut.code & " Appears to be a broken shortcut, target model could not be resolved"
WriteError objectItemOrShortcut.DisplayName & " appears to be a broken shortcut, target model could not be resolved"
End if
Else
' If the object is not a shortcut, return the passed object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<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 windows business rule as the input of another joined object:</a:OutputMessage>
<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
Expand All @@ -19,28 +19,29 @@
End If


&#39; Now loop though all source objects.
&#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 joinedObject.HasStereotype(&quot;mdde_WindowBusinessRule&quot;) Then
&#39;WriteInfo(&quot;joinedObject: &quot; &amp; joinedObject.ObjectType &amp; &quot; name: &quot; &amp; joinedObject.DisplayName &amp; &quot; stereotype &quot; + joinedObject.StereoType)
&#39;WriteInfo(&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 return true return an error
Dim boolwindowsFunctionUsedAsParent : boolwindowsFunctionUsedAsParent = windowFunctionUsedAsParent(objSourceObject, colSourceObjects)
If boolwindowsFunctionUsedAsParent = 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
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 functie is used as the parent in another joined object on the same mapping
&#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
Expand All @@ -50,17 +51,18 @@ Function windowFunctionUsedAsParent(ByRef objWindowFunctionSourceObject, ByRef c
&#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;WriteInfo(&quot;functionobjSourceObject: &quot; &amp; objSourceObject.ObjectType &amp; &quot; name: &quot; &amp; objSourceObject.DisplayName &amp; &quot; stereotype: &quot; &amp; objSourceObject.StereoType)
&#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;WriteInfo(&quot;objParentSourceObject: &quot; &amp; objParentSourceObject.ObjectType &amp; &quot; name: &quot; &amp; objParentSourceObject.DisplayName &amp; &quot; stereotype: &quot; &amp; objParentSourceObject.StereoType)
&#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
windowFunctionUsedAsParent = True\
Exit Function
End if
End if
Next
Expand Down

0 comments on commit a1fb61e

Please sign in to comment.