-
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.
Add model export extension for basic classes (#13)
* Add model export extension for basic classes * review comments * Build all XEM files * review comments * review comments * review comments
- Loading branch information
1 parent
f106588
commit e641d57
Showing
92 changed files
with
699 additions
and
1,857 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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
decomposed/extensions/MDDE_LDM/Profile/Model/Extended_Attributes/Extended_Attributes.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,12 @@ | ||
<o:TypedCategoryTargetItem Id="1E094FE4-6BB9-48B7-BD1F-50F4079BF878"> | ||
<a:TypePublicName>ExtendedAttributeTargetItem</a:TypePublicName> | ||
<a:ObjectID>1E094FE4-6BB9-48B7-BD1F-50F4079BF878</a:ObjectID> | ||
<a:Name>Extended Attributes</a:Name> | ||
<a:CreationDate>1701429225</a:CreationDate> | ||
<a:Creator>WillemOtten</a:Creator> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<c:Categories> | ||
<xi:include href="mdde_Export_Extension_Attached.xml" /> | ||
<xi:include href="mdde_Export_Extension_Initialization_Successful.xml" /> | ||
</c:Categories> | ||
</o:TypedCategoryTargetItem> |
17 changes: 17 additions & 0 deletions
17
.../extensions/MDDE_LDM/Profile/Model/Extended_Attributes/mdde_export_extension_attached.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,17 @@ | ||
<o:ExtendedAttributeTargetItem Id="FD029C97-577C-44C5-A0C5-BFB158940D76"> | ||
<a:ObjectID>FD029C97-577C-44C5-A0C5-BFB158940D76</a:ObjectID> | ||
<a:Name>mdde_Export_Extension_Attached</a:Name> | ||
<a:CreationDate>1701429225</a:CreationDate> | ||
<a:Creator>WillemOtten</a:Creator> | ||
<a:Comment>Checks if the MDDE LDM Export extension is attached to the model</a:Comment> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<a:Computed>1</a:Computed> | ||
<a:ComputedAccessType>RO</a:ComputedAccessType> | ||
<a:GetMethodScript>Function %Get%(obj) | ||
%Get% = False | ||
'Find the export extension | ||
Dim extensionObject: Set extensionObject = obj.FindChildByCode ("MDDE_LDM_Export_Extension", Cls_ExtendedModelDefinition, "", Nothing, True, True) | ||
%Get% = Not extensionObject is Nothing | ||
End Function</a:GetMethodScript> | ||
<a:Label>Indicator for export extension</a:Label> | ||
</o:ExtendedAttributeTargetItem> |
10 changes: 10 additions & 0 deletions
10
...LDM/Profile/Model/Extended_Attributes/mdde_export_extension_initialization_successful.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,10 @@ | ||
<o:ExtendedAttributeTargetItem Id="3CB69645-4260-4DBC-A602-0536A9D4E6B3"> | ||
<a:ObjectID>3CB69645-4260-4DBC-A602-0536A9D4E6B3</a:ObjectID> | ||
<a:Name>mdde_Export_Extension_Initialization_Successful</a:Name> | ||
<a:CreationDate>1701438410</a:CreationDate> | ||
<a:Creator>WillemOtten</a:Creator> | ||
<a:Comment>Used to check if the export initialization was successful</a:Comment> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<a:Label>MDDE Export extension initialized successful</a:Label> | ||
<a:ValidateDataType>0</a:ValidateDataType> | ||
</o:ExtendedAttributeTargetItem> |
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
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
143 changes: 143 additions & 0 deletions
143
decomposed/extensions/MDDE_LDM/Profile/Model/Methods/mdde_InitializeExportExtension.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,143 @@ | ||
<o:MethodTargetItem Id="A2DF8843-2E87-46FC-9263-927B3E02D9E8"> | ||
<a:ObjectID>A2DF8843-2E87-46FC-9263-927B3E02D9E8</a:ObjectID> | ||
<a:Name>mdde_InitializeExportExtension</a:Name> | ||
<a:CreationDate>1701423896</a:CreationDate> | ||
<a:Creator>WillemOtten</a:Creator> | ||
<a:Comment>This method is included in the extension to load the contents of templates that are defined in the optionally attached export extension. | ||
Since it is not possible to directly access the GTL templates in another extension via GTL, the contents of these templates is loaded in local extended attributes so it can be included in the XML export</a:Comment> | ||
<a:TargetCategory.Type>1</a:TargetCategory.Type> | ||
<a:MethodScript>Sub %Method%(obj) | ||
|
||
WriteInfo "MDDE LDM Export extension initializion started" | ||
|
||
|
||
Dim errorsFound: errorsFound = False | ||
Dim templateAppliedWithoutErrors: templateAppliedWithoutErrors = False | ||
Dim childPackagesProcessedWithoutErrors: childPackagesProcessedWithoutErrors = False | ||
|
||
'Set the mddex contents attribute on model | ||
templateAppliedWithoutErrors = applyTemplateOnObject (obj, obj, "mddex_Model_Export_Template", "mddex_Model_Export_Content") | ||
If templateAppliedWithoutErrors = False Then | ||
errorsFound = True | ||
End If | ||
|
||
templateAppliedWithoutErrors = applyTemplateOnObject (obj, obj, cMDDE_NAMEDOBJECT_ATTRIBUTE_EXPORT_TEMPLATE_NAME, cMDDE_NAMEDOBJECT_ATTRIBUTE_EXPORT_ATTRIBUTE_NAME) | ||
If templateAppliedWithoutErrors = False Then | ||
errorsFound = True | ||
End If | ||
|
||
'Process all child objects recursively in all packages | ||
childPackagesProcessedWithoutErrors = processPackage (obj, obj) | ||
If childPackagesProcessedWithoutErrors = False Then | ||
errorsFound = True | ||
End If | ||
|
||
WriteInfo "MDDE LDM Export extension initializion finished" | ||
|
||
'Set initialization indicator to true | ||
If errorsFound = True Then | ||
Msgbox "There where errors processing the MDDE LDM Export extension, consult the script output window for more information." | ||
Else | ||
obj.setExtendedAttribute cMDDE_EXT_CODE & "." & cMDDE_EXPORT_EXTENSION_INITIALIZATION_INDICATOR, True | ||
End If | ||
End Sub | ||
|
||
' Check if the GTL output contains errors | ||
Function GTLOutputHasErrors(GTLResult) | ||
GTLOutputHasErrors = False | ||
If InStr(GTLResult, cMDDE_EXPORT_EXTENSION_CODE & "::Profile") Then | ||
GTLOutputHasErrors = True | ||
End If | ||
End Function | ||
|
||
Function processPackage(objModel, objPackage) | ||
|
||
Dim collectionProcessedWithoutErrors, childPackagesProcessedWithoutErrors | ||
processPackage = True | ||
collectionProcessedWithoutErrors = False | ||
childPackagesProcessedWithoutErrors = False | ||
|
||
'Loop over Entities | ||
collectionProcessedWithoutErrors = applyTemplateOnCollection(objModel, objPackage.Entities, "mddex_Entity_Export_Template", "mddex_Entity_Export_Content", True) | ||
If collectionProcessedWithoutErrors = False Then | ||
processPackage = False | ||
End If | ||
|
||
'Loop over Entity Attributes | ||
collectionProcessedWithoutErrors = applyTemplateOnCollection(objModel, objPackage.EntityAttributes, "mddex_EntityAttribute_Export_Template", "mddex_EntityAttribute_Export_Content", True) | ||
If collectionProcessedWithoutErrors = False Then | ||
processPackage = False | ||
End If | ||
|
||
'Loop over Mappings | ||
collectionProcessedWithoutErrors = applyTemplateOnCollection(objModel, objPackage.Mappings, "mddex_BaseClassifierMapping_Export_Template", "mddex_BaseClassifierMapping_Export_Content", True) | ||
If collectionProcessedWithoutErrors = False Then | ||
processPackage = False | ||
End If | ||
|
||
'Loop over AttributeMappings | ||
collectionProcessedWithoutErrors = applyTemplateOnCollection(objModel, objPackage.ModelEntityAttributeMappings, "mddex_BaseStructuralFeatureMapping_Export_Template", "mddex_BaseStructuralFeatureMapping_Export_Content", False) | ||
If collectionProcessedWithoutErrors = False Then | ||
processPackage = False | ||
End If | ||
|
||
'Loop over packages | ||
Dim childPackage | ||
For Each childPackage in objPackage.Packages | ||
childPackagesProcessedWithoutErrors = processPackage (objModel, childPackage) | ||
If childPackagesProcessedWithoutErrors = False Then | ||
processPackage = False | ||
End If | ||
Next | ||
|
||
End Function | ||
|
||
'Apply template on object and check for translation errors | ||
Function applyTemplateOnObject(objModel, objItem, templateName, extendedAttributeName) | ||
'Process the object specific template | ||
Dim evaluatedTemplate: evaluatedTemplate = objItem.EvaluateTemplateFor(templateName, cMDDE_EXPORT_EXTENSION_CODE) | ||
applyTemplateOnObject = True | ||
'Clear the extended attribute if it is set | ||
If objItem.getExtendedAttributeText(extendedAttributeName) <> "" Then | ||
objItem.setExtendedAttribute extendedAttributeName, Nothing | ||
End If | ||
|
||
' Only set the extended attribute if the template evaluation gave a non-empty result | ||
If Not evaluatedTemplate = empty And Not evaluatedTemplate = "" Then | ||
objItem.setExtendedAttribute extendedAttributeName, evaluatedTemplate | ||
If GTLOutputHasErrors(objItem.getExtendedAttribute(extendedAttributeName)) Then | ||
WriteError ("Error parsing template " & templateName & " for " & objItem.Code) | ||
'Set success indicator to false | ||
objModel.setExtendedAttribute cMDDE_EXT_CODE & "." & cMDDE_EXPORT_EXTENSION_INITIALIZATION_INDICATOR, False | ||
applyTemplateOnObject = False | ||
End If | ||
End If | ||
|
||
End Function | ||
|
||
|
||
Function applyTemplateOnCollection(objModel, objCollection, templateName, extendedAttributeName, applyNamedObjectTemplate) | ||
Dim obj, metaClassTemplateAppliedWithoutErrors, namedObjectTemplateAppliedWithoutErrors | ||
'Set default template and attribute that apply to all object types | ||
Dim attributeTemplateName: attributeTemplateName = "mddex_NamedObject_Attributes_Export_Template" | ||
Dim attributeExtendedAttributeName: attributeExtendedAttributeName = "mddex_NamedObject_Attributes_Export_Content" | ||
|
||
applyTemplateOnCollection = True | ||
metaClassTemplateAppliedWithoutErrors = True | ||
namedObjectTemplateAppliedWithoutErrors = True | ||
'Loop over collection and set the extended attribute based on the export template | ||
'If specified, also apply the namedobject template for adding custom attributes to the element | ||
For Each obj in objCollection | ||
If Not obj.IsShortCut Then | ||
metaClassTemplateAppliedWithoutErrors = applyTemplateOnObject (objModel, obj, templateName, extendedAttributeName) | ||
If applyNamedObjectTemplate Then | ||
namedObjectTemplateAppliedWithoutErrors = applyTemplateOnObject (objModel, obj, attributeTemplateName, attributeExtendedAttributeName) | ||
End If | ||
If metaClassTemplateAppliedWithoutErrors = False Or namedObjectTemplateAppliedWithoutErrors = False Then | ||
applyTemplateOnCollection = False | ||
End If | ||
End If | ||
Next | ||
End Function | ||
</a:MethodScript> | ||
</o:MethodTargetItem> |
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
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: 8 additions & 0 deletions
8
...osed/extensions/MDDE_LDM_Export_Extension/ExtendedModelDefinition/a_CheckGlobalScript.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 @@ | ||
<a:CheckGlobalScript>'****************************************************************************** | ||
'* Purpose: This script holds global definitions shared by all the custom- | ||
'* checks scripts of the model extension. | ||
'****************************************************************************** | ||
|
||
Option Explicit ' This is to ensure all used variables are defined | ||
|
||
</a:CheckGlobalScript> |
6 changes: 6 additions & 0 deletions
6
decomposed/extensions/MDDE_LDM_Export_Extension/Generation.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,6 @@ | ||
<o:TargetCategory Id="4FA71D60-5526-4E0B-BFD7-8DD3DC0F71CE"> | ||
<a:ObjectID>4FA71D60-5526-4E0B-BFD7-8DD3DC0F71CE</a:ObjectID> | ||
<a:Name>Generation</a:Name> | ||
<a:CreationDate>1700834012</a:CreationDate> | ||
<a:Creator>WillemOtten</a:Creator> | ||
</o:TargetCategory> |
Oops, something went wrong.