Forum Discussion

ChrisFeller's avatar
ChrisFeller
New Contributor
2 years ago
Solved

Scheduling an extract of metadata

I'm being asked to schedule an extract of the OneStream metadata.  I'm under the impression that this cannot be done using the Task Scheduler since an extract of metadata is not an option in Data Management.  Is this an accurate statement?  If this can be schedule, how so?

Thanks!

7 Replies

    • ChrisFeller's avatar
      ChrisFeller
      New Contributor

      I've built this rule successfully.  When I extract this file to my computer, how do I open the zip file?  When I open it I get the following.  I need the xml file of all the dimensions.  Thanks for the feedback!

       

      • MarcusH's avatar
        MarcusH
        Valued Contributor

        You have selected to download the file in OneStream format (the down arrow). Double click should open the file in your zip application. Or you can download the file as a zip by clicking on the last icon on the toolbar (piece of paper with a down arrow).

         

         

    • amritp02's avatar
      amritp02
      New Contributor

      Any idea how I can export specific dimension hierarchy and get it to show specific properties in the column in a .csv file?

       

      • MarcusH's avatar
        MarcusH
        Valued Contributor

        The xmlExtractOptions object has properties that control what is extracted (eg XmlLoadExtractType.ApplicationDashboards). Unfortunately I haven't found any documentation and intellisense doesn't work. In short the way I do it is extract everything and then read the output zip file and pick off the Metadata.XML file like this:

        ' You will need these imports:
        ' Imports System.IO.Compression
        ' Imports System.Xml
        
        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)
        		' Decompress the zipped bytes into memory
        		Using zipStream As New MemoryStream(zipBytes)
        			Using archive As New ZipArchive(zipStream, ZipArchiveMode.Read)
        				' Iterate through each entry in the zip archive
        				For Each entry As ZipArchiveEntry In archive.Entries
        					If entry.fullname.toupper = "METADATA.XML" Then
        						' Read the contents of the entry into a string
        						Using entryStream As Stream = entry.Open()
        							Using reader As New StreamReader(entryStream)
        								Dim contents As String = reader.ReadToEnd()
        								' Save file ...
        							End Using
        						End Using
        						Exit For
        					End If
        				Next
        			End Using
        		End Using
        	End Using
        End Using

        If you then want a particular dimension, I would load the file into an XML document and parse out the dimension you want. Then convert it to a csv file.