Extract Dimension Hierarchy Metadata XML Through DM and Extender BR
Hi all,
I came across a very helpful post that shows how to automate extracting metadata for backup. (original code at the bottom of post)
I tried this business rule and it works perfectly, however I am looking for something a little more specific since this returns a massive dump of data. Basically, I am looking to automate a metadata xml extract of specific dimensions and their members / relationships separately into different files and combine them into a zip package. Is there any documentation that shows how to edit this xmlOptions syntax below to include specified return xml values instead of just extracting all items?
'Set the extract options Dim xmlOptions As New XmlExtractOptions xmlOptions.ExtractAllItems = True
Ideally in the package, each dimension would have two files. I would have two files as such:
- TopU4 Members
- TopU4 Relationships
'Prepare the Stage Data Extract File path
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
'Folder path to save export
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, _
True, configSettings.FileShareRootFolder, si.AppToken.AppName) & _
"\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\MetadataExtracts"
'Check if folder path for export exists
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
end if
Dim filePath As String = folderPath & "\" & si.AppToken.AppName & ".zip"
'Check if file already exists. If so then delete exsiting copy
If File.Exists(filePath) Then
File.Delete(filePath)
end if
'Set the extract options
Dim xmlOptions As New XmlExtractOptions
xmlOptions.ExtractAllItems = True
'Execute the Metadata Extract
Using dbConnFW As DBConnInfo = BRAPi.Database.CreateFrameworkDbConnInfo(si)
Using dbConnApp As DBConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)
Dim zipBytes As Byte() = ApplicationZipFileHelper.Extract( _
dbConnFW, dbConnApp, Nothing, xmlOptions)
'Push the resulting content to a new zip file we create
Using FS As New FileStream(filePath, FileMode.Append, FileAccess.Write)
'Create a binary writer, and write all bytes to the FileStream at once
Using BW As New BinaryWriter(FS)
BW.Write(zipBytes)
End Using
End Using
End Using
End Using
Thank you in advance!!