Written by

Senior Startups and Community Programs Manager at InterSystems Corporation
Question Evgeny Shvarov · Apr 1, 2017

Is there an option to export globals in archive?

Hi, Community!

Is there an option to get an archived file of globals in one command. Say for:

Do $System.OBJ.Export("Class1*D.GBL,Class2*D.GBL","data_gbl.xml")

get something like:

Do $System.OBJ.Export("Data*D.GBL","data_gbl.gz","gzip")

And also to have the convenient one click way to  import it to the namespace via terminal or Control Panel?

If anyone already has this module, share please?

It would be very convenient for import/export/continuous integration purposes cause globals can be really heavy.

Comments

Sean Connelly · Apr 1, 2017

Hi Evgeny,

Not exactly one command, but it can be done on one line...

set file="foo.zip" do $System.OBJ.ExportToStream("foo*.GBL",.s) open file:("WNS":/GZIP=1) use file Do s.OutputToDevice() close file do s.Clear()

This should work in reverse opening the file with the GZIP flag, read the contents to a temporary binary stream and then using the $System.OBJ.LoadStream on the temp binary stream.

Sean.

0
Eduard Lebedyuk  Apr 1, 2017 to Sean Connelly

It can be done with Gzip stream directly:

set ^dbg=123
set s=##class(%Stream.FileBinaryGzip).%New()
do s.LinkToFile("1.xml")
do $System.OBJ.ExportToStream("dbg*.GBL", s)
do s.%Save()
kill
kill ^dbg
set s=##class(%Stream.FileBinaryGzip).%New()
do s.LinkToFile("1.xml")
do $System.OBJ.LoadStream(s)
write ^dbg
>123
0
Evgeny Shvarov  Apr 1, 2017 to Sean Connelly

Finally, have the following for globals export/import in gzip:

// export gbl
set gbl="foo*D.GBL,boo*D.GBL"
set s=##class(%Stream.FileBinaryGzip).%New() do s.LinkToFile("1.xml.gz") do $System.OBJ.ExportToStream(gbl,s) do s.%Save() kill s
// gbl import
set s=##class(%Stream.FileBinaryGzip).%New() do s.LinkToFile("1.xml.gz") do $System.OBJ.LoadStream(s) kill s

0
Alexey Maslov  Apr 1, 2017 to Eduard Lebedyuk

Don't you think that naming the file "1.xml.gz" would be more clear?

0
Eduard Lebedyuk  Apr 1, 2017 to Evgeny Shvarov

Dot would be unrequired and even misleading here.

0
Evgeny Shvarov  Apr 1, 2017 to Eduard Lebedyuk

You are right, no dot is needed here.

0
Evgeny Shvarov  Apr 1, 2017 to Eduard Lebedyuk

Thanks, Sean, Ed, Alexey!

That works perfectly! Ed, please add a dot to s in ExportToStream?

I'm using it in one line, and think would add in some "Dev.Utils" class to make it shorter.

0
Evgeny Shvarov  Apr 1, 2017 to Eduard Lebedyuk
kill ^dbg

BTW, kill ^dbg is not mandatory here, cause import from XML format everytime kills the global first.

0