-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New and updated model checks, improved XML export and bug fixes (#15)
* Renamed mdde_Classifier_IsMDDEMapping to mdde_Criterion_IsMDDEMapping. Created mdde_IsMDDEDataSource criterium with template to be used from other objects to check data source is MDDE and refactored criteria for BaseClassifierMapping, BaseStructuralFeatureMapping, . Updated Entity AddMapping method to use constant for the MDDE DataSource Stereotype. Created mdde_Entity_IsBusinessRule extended attribute to be consumed by other extensions. Fixed naming error in criterium from mdde_BusinessRule_IsBusinessRuleWithMapping to mdde_BusinessRule_IsBusinessRuleWithoutMapping. Fixed ExtendedSubObject/mdde_EntityExampleData mdde_EntityExampleData_EditExampleEntity method so you can also make example data for business rules with mappings. Added mdde_ExampleValueCount on ExtendedSubObject/mdde_ExampleRecord, so it can be viewed in datagrid. Added force saving the model file as XML (in Model mdde_ExportXmlAndDecompose method) to the current location to solve issue of switching to binary model. XML Export: - Added sorting in XML export for Packages, ExampleRecord, Inheritence, DependentModels (in Model template). - Added Comment to XML export of BaseStructuralFeatureMapping. - Created mdde_IsAttributeMapped extended attribute on EntityAttribute (with logic on inheritance) and added to XML Export. - Updated EntityAttribute XML Export template to produce same XML output (and newlines) as before added export extension. - Added mdde_NamedObject_XmlElementExport_Template to Example XML export. - Enabled export of Comment and Description properties for all named objects (mdde_NamedObject_XmlElementExport_Template). Model checks: - BaseClassifierMapping - New: Check duplicate source objects (MDDE) - Updated: mdde_Check_OrderOFSourceObjects. - Business rule - Moved mdde_Check_BusinessRuleHasAtLeastOneInputAttribute and mdde_Check_BusinessRuleHasAtLeastOneExample to ExpressionBusinessRule, otherwise it wouldn't show up. - EntityAttribute: - Renamed mdde_Check_ScalarBusinessRule_AttributeCodeOccursInSqlExpression to mdde_Check_ExpressionBusinessRule_AttributeCodeOccursInSqlExpression. - ExtendedSubObject/mdde_EntityExampleData - New: Check Entity Example Data Attributes (MDDE) - ExtendedSubObject/mdde_SourceObject - New: Expression business rule join conditions are in same order as attributes (MDDE) - Updated: mdde_Check_JoinConditionSpecified: Added checking FROM object, coping with literals and better error handling. - ShortcutBase - New: Shortcut is broken (MDDE) * Updated model xml exports after extension update. * Updated Check Entity Example Data Attributes (MDDE) to also verify first record attribute. * Fixed join condition for business where parameter was missing. Updated pdc ldm config to removed empty ExtendedCollections and ExtendedComposition elements. * Fixed typo. * Fixed type --------- Co-authored-by: Harmen Wessels <harmen.wessels@rabobank.nl>
- Loading branch information
Showing
114 changed files
with
1,220 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
123 changes: 123 additions & 0 deletions
123
...eria/mdde_Criterion_IsMDDEMapping/Custom_Checks/Check_duplicate_source_objects_(MDDE).xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<o:CustomCheckTargetItem Id="70F744D4-1B3D-4C91-948B-1095EF0DFD02"> | ||
<a:ObjectID>70F744D4-1B3D-4C91-948B-1095EF0DFD02</a:ObjectID> | ||
<a:Name>Check duplicate source objects (MDDE)</a:Name> | ||
<a:CreationDate>1704977369</a:CreationDate> | ||
<a:Creator>WesselsH1</a:Creator> | ||
<a:Comment>Check whether there are duplicate source objects in the mapping (meaning the same joined object with join conditions and offset period exists as a source object more then once).</a:Comment> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<a:HelpMessage>This check ensures that there are no are duplicate source objects in the mapping (meaning the same joined object with join conditions and offset period exists as a source object more then once).</a:HelpMessage> | ||
<a:OutputMessage>The following mapping have one or more duplicate source objects:</a:OutputMessage> | ||
<a:CheckScript>Function %Check%(obj) | ||
' Create all arrays to be used in this function. | ||
' The arrays must be created at the beginning, otherwise VBScript will complain (because of compile issues). | ||
Dim arrSourceObjectKeyParts(), arrJoinConditionKeyParts() | ||
|
||
' Initialize the result with true. | ||
%Check% = True | ||
|
||
' Create an array to store the source objects found so far. | ||
Dim colSourceObjectKeys : Set colSourceObjectKeys = CreateObject("System.Collections.ArrayList") | ||
|
||
' Retrieve the source objects from the mapping. | ||
Dim colSourceObjects : Set colSourceObjects = obj.GetExtendedCollection("mdde_SourceObjects") | ||
|
||
' If the mapping has no source objects, stop here. | ||
If colSourceObjects.Count = 0 Then | ||
Exit Function | ||
End If | ||
|
||
' Now loop though all source objects and construct a unique string to compare the source objects on. | ||
Dim objSourceObject | ||
For Each objSourceObject In colSourceObjects | ||
' Get the joined object. | ||
Dim objJoinedObject : Set objJoinedObject = objSourceObject.GetExtendedAttribute("mdde_JoinedObject") | ||
|
||
' If the joined object is nothing (unset), skip this source object. | ||
If Not(objJoinedObject Is Nothing) Then | ||
|
||
' We will use: SourceObject.JoinedObject.Code + SourceObject.JoinType + SourceObject.OffsetPeriod + SourceObject.OffsetValue + SourceObject.JoinConditions | ||
' The JoinConditions collection should be alphabetically sorted to make sure we also find equal onces if the order of the joins is different. | ||
|
||
' Get the collection with join conditions of the current source object. | ||
Dim objJoinConditions : Set objJoinConditions = objSourceObject.GetExtendedCollection("mdde_JoinConditions") | ||
|
||
' If there are no join conditions, skip creating the join conditions part. | ||
If Not(objJoinConditions Is Nothing) And objJoinConditions.Count > 0 Then | ||
|
||
' Create an array to contain the join condition key parts. | ||
ReDim arrJoinConditionKeyParts(objJoinConditions.Count) | ||
' Loop through the join conditions and make a sortable array of join conditions. | ||
Dim intCurrentJoinConditionIndex | ||
For intCurrentJoinConditionIndex = 0 To objJoinConditions.Count - 1 | ||
Dim objJoinCondition : Set objJoinCondition = objJoinConditions.Item(intCurrentJoinConditionIndex) | ||
' Use the Xml Export template to get a textual representation of the join condition. | ||
Dim TTI : Set TTI = obj.Model.FindMetaExtensionByName(objJoinCondition, PdCommon.cls_TemplateTargetItem, "mdde_JoinCondition_XmlExport_Template") | ||
Dim strJoinConditionKey : strJoinConditionKey = objJoinCondition.EvaluateTemplate("mdde_JoinCondition_XmlExport_Template", TTI) | ||
|
||
' Now we need to insert the key at the right place in the array (so the array stays alphabetically sorted). | ||
' So we loop over the array until we find a join condition key which is larger then the current one (or we reach the end). | ||
' Then we know at which position the new key needs to be and which keys to move up one position. | ||
Dim intCompareJoinConditionIndex | ||
Dim intNewJoinConditionKeyIndex : intNewJoinConditionKeyIndex = intCurrentJoinConditionIndex | ||
For intCompareJoinConditionIndex = 0 To intCurrentJoinConditionIndex | ||
' If we find the first key which is larger then the current one, we have found the position to store the new key in. | ||
If arrJoinConditionKeyParts(intCompareJoinConditionIndex) > strJoinConditionKey Then | ||
' Update the new join condition key index to the found position. | ||
intNewJoinConditionKeyIndex = intCompareJoinConditionIndex | ||
' This means we have to move all keys from this position onwards one index further. | ||
' So we loop from the index of the new key to the last index in reverse order | ||
Dim intOldJoinConditionIndex | ||
For intOldJoinConditionIndex = intCurrentJoinConditionIndex - 1 To intNewJoinConditionKeyIndex Step -1 | ||
' Move the value of the key one index further. | ||
arrJoinConditionKeyParts(intOldJoinConditionIndex + 1) = arrJoinConditionKeyParts(intOldJoinConditionIndex) | ||
' To be sure, empty the value on the old position. | ||
arrJoinConditionKeyParts(intOldJoinConditionIndex) = vbEmpty | ||
Next | ||
|
||
' Since we found the right place, we can exit the loop. | ||
Exit For | ||
End If | ||
Next | ||
|
||
' Update the array to have the new join condition key at the designated index. | ||
arrJoinConditionKeyParts(intNewJoinConditionKeyIndex) = strJoinConditionKey | ||
Next | ||
End If | ||
|
||
' Create an array to store the source object key parts. | ||
' Initialize the array for 5 items in it (so upperbound 4). | ||
ReDim arrSourceObjectKeyParts(4) | ||
|
||
' Construct the first part of the source object key. | ||
arrSourceObjectKeyParts(0) = objJoinedObject.Code | ||
arrSourceObjectKeyParts(1) = objSourceObject.GetExtendedAttributeText("mdde_JoinType") | ||
arrSourceObjectKeyParts(2) = objSourceObject.GetExtendedAttributeText("mdde_OffsetPeriod") | ||
arrSourceObjectKeyParts(3) = objSourceObject.GetExtendedAttributeText("mdde_OffsetValue") | ||
arrSourceObjectKeyParts(4) = Join(arrJoinConditionKeyParts, "&") | ||
|
||
' Construct the textual representation of the source object key by joining the key parts together. | ||
Dim strSourceObjectKey : strSourceObjectKey = Join(arrSourceObjectKeyParts, "|") | ||
' Now check whether the source object key already exists in the keys collection. | ||
' If so we have found a duplicate, so report it. | ||
If colSourceObjectKeys.Contains(strSourceObjectKey) Then | ||
WriteError("The mapping '" & obj.DisplayName & "' contains duplicate source objects, where the duplicate source object is: '" & objSourceObject.DisplayName & "'") | ||
WriteDebug(" > Duplicate key: " & strSourceObjectKey) | ||
%Check% = False | ||
' If we haven't found the key yet, add it to the key collection. | ||
Else | ||
colSourceObjectKeys.Add strSourceObjectKey | ||
End If | ||
|
||
End If | ||
Next | ||
End Function</a:CheckScript> | ||
<a:AutoFixScrpt>Function %Fix%(obj, outmsg) | ||
' Implement your automatic correction on <obj> here | ||
' filling <outmsg> as you wish | ||
' and return True if successful. | ||
|
||
outmsg = "Automatic correction not implemented" | ||
|
||
%Fix% = False | ||
End Function</a:AutoFixScrpt> | ||
</o:CustomCheckTargetItem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...Mapping/mdde_Classifier_IsMDDEMapping.xml → ...EMapping/mdde_Criterion_IsMDDEMapping.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
decomposed/extensions/MDDE_LDM/Profile/BaseDataSource/Criteria/Criteria.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<o:TypedCategoryTargetItem Id="8EC2655D-4D06-4870-8B2B-C0CC4132546B"> | ||
<a:TypePublicName>CriterionTargetItem</a:TypePublicName> | ||
<a:ObjectID>8EC2655D-4D06-4870-8B2B-C0CC4132546B</a:ObjectID> | ||
<a:Name>Criteria</a:Name> | ||
<a:CreationDate>1709820290</a:CreationDate> | ||
<a:Creator>WesselsH1</a:Creator> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<c:Categories> | ||
<xi:include href="mdde_Criterion_IsMDDEDataSource/mdde_Criterion_IsMDDEDataSource.xml" /> | ||
</c:Categories> | ||
</o:TypedCategoryTargetItem> |
11 changes: 11 additions & 0 deletions
11
...M/Profile/BaseDataSource/Criteria/mdde_Criterion_IsMDDEDataSource/Templates/Templates.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<o:TypedCategoryTargetItem Id="04574872-0E16-4BE1-9404-F8EF62AE5918"> | ||
<a:TypePublicName>TemplateTargetItem</a:TypePublicName> | ||
<a:ObjectID>04574872-0E16-4BE1-9404-F8EF62AE5918</a:ObjectID> | ||
<a:Name>Templates</a:Name> | ||
<a:CreationDate>1709820334</a:CreationDate> | ||
<a:Creator>WesselsH1</a:Creator> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<c:Categories> | ||
<xi:include href="mdde_IsMDDEDataSource.xml" /> | ||
</c:Categories> | ||
</o:TypedCategoryTargetItem> |
8 changes: 8 additions & 0 deletions
8
...seDataSource/Criteria/mdde_Criterion_IsMDDEDataSource/Templates/mdde_IsMDDEDataSource.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<o:TemplateTargetItem Id="B319137E-9329-4A06-82A5-663C4A0E5F3B"> | ||
<a:ObjectID>B319137E-9329-4A06-82A5-663C4A0E5F3B</a:ObjectID> | ||
<a:Name>mdde_IsMDDEDataSource</a:Name> | ||
<a:TemplateTargetItem.Value>True</a:TemplateTargetItem.Value> | ||
<a:CreationDate>1709820334</a:CreationDate> | ||
<a:Creator>WesselsH1</a:Creator> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
</o:TemplateTargetItem> |
11 changes: 11 additions & 0 deletions
11
...seDataSource/Criteria/mdde_Criterion_IsMDDEDataSource/mdde_Criterion_IsMDDEDataSource.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<o:CriterionTargetItem Id="078B9AFB-C42D-4955-B7C1-9488775BD364"> | ||
<a:ObjectID>078B9AFB-C42D-4955-B7C1-9488775BD364</a:ObjectID> | ||
<a:Name>mdde_Criterion_IsMDDEDataSource</a:Name> | ||
<a:CriterionTargetItem.Value>(%Stereotype% == null) Or (%Stereotype% == "") Or (%Stereotype% == "mdde_DataSource")</a:CriterionTargetItem.Value> | ||
<a:CreationDate>1709820290</a:CreationDate> | ||
<a:Creator>WesselsH1</a:Creator> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<c:Categories> | ||
<xi:include href="Templates/Templates.xml" /> | ||
</c:Categories> | ||
</o:CriterionTargetItem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...tructuralFeatureMapping/Criteria/mdde_Criterion_ParentIsMDDEMapping/Criteria/Criteria.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...eatureMapping/Criteria/mdde_Criterion_ParentIsMDDEMapping/Custom_Checks/Custom_Checks.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.