CoS Routine to export Global

64 views
Skip to first unread message

Bala

unread,
May 31, 2011, 2:22:27 AM5/31/11
to InterSystems: Ensemble in Healthcare
Hi,

How do I write a routine/method(in Cache Object Script) to export
globals?

Using the documentation I was able to write routines to export
Lookups, and other project files.

Thank you,

Bala

htg

unread,
May 31, 2011, 3:58:12 AM5/31/11
to InterSystems: Ensemble in Healthcare
set g="^yourGlobal" for set g=$q(@g,1,val) quit:g="" write g,!,val,!

Bill McCormick

unread,
May 31, 2011, 5:02:44 AM5/31/11
to ensemble-in...@googlegroups.com, InterSystems: Ensemble in Healthcare
$System.OBJ.Export() can export globals as well as routines and classes

Bill

> --
> You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
> To post to this group, send email to Ensemble-in...@googlegroups.com
> To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en
>

David Loveluck

unread,
May 31, 2011, 8:22:39 AM5/31/11
to ensemble-in...@googlegroups.com
You can use $System.OBJ.Export() t export a single item such as a global, or you can build an array with the subscripts being the items you want to export. This allows you to export many things in one go.

The subscripts have to be suffixed .gbl, .cls, .hl7 to indicate what they are.

e.g. This method builds an array of many things from my ABC package.

ClassMethod CreateExportXML(FileName As %String, excludedata As %Boolean = 1)
{

if $g(FileName)="" set FileName="C:\temp\ABCExport.xml"

//loop through various groups of items in the ABC application

// Get list of all classes in the ABC package
set x=$system.OBJ.GetPackageList(.classList,"ABC")
set class=""
for {
set class=$order(classList(class))
continue:class["Contextsys"
continue:class["Processsys"

quit:class=""
//skip generated classes (ending in .Context or .Threadn)
set last=$p(class,".",$l(class,"."))
if '((last="Context")||($e(last,1,6)="Thread")) {
set list(class_".cls")=""
}
}
set x=$system.OBJ.GetPackageList(.classList,"ABC")
set class=""
for {
set class=$order(classList(class))
continue:class["Contextsys"
continue:class["Processsys"
quit:class=""
//skip generated classes (ending in .Context or .Threadn)
set last=$p(class,".",$l(class,"."))
if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e(last,1,6)["Processsys")) {
set list(class_".cls")=""
}
}
// Get list of all classes in the Transplant package
set x=$system.OBJ.GetPackageList(.classList,"Transplant")
set class=""
for {
set class=$order(classList(class))
continue:class["Contextsys"
continue:class["Processsys"
quit:class=""
//skip generated classes (ending in .Context or .Threadn)
set last=$p(class,".",$l(class,"."))
if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e(last,1,6)["Processsys")) {
set list(class_".cls")=""
}
}
// Get list of all classes in the EnsMonitor2 package
set x=$system.OBJ.GetPackageList(.classList,"EnsMonitor2")
set class=""
for {
set class=$order(classList(class))
continue:class["Contextsys"
continue:class["Processsys"
quit:class=""
//skip generated classes (ending in .Context or .Threadn)
set last=$p(class,".",$l(class,"."))
if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e(last,1,6)["Processsys")) {
set list(class_".cls")=""
}
}
//get all the business rules in package ABC
set tRS=##class(%ResultSet).%New("Ens.Rule.RuleDefinition:EnumerateRules")

set tSC=tRS.Execute()
while tRS.Next() {
set tPackage=tRS.Data("Package")
set tName=tRS.Data("Name")
if (tPackage["ABC")||(tName["ABC")||(tName["ABC")||(tPackage["ABC") {
set list(tPackage_"."_tName_".rul")=""
}

}
//export the credentials global
set global="^Ens.Conf.CredentialsD"
set list(global_".gbl")=""

//^SYS("BI") global stored the subject areas
//set global="^SYS"
//set list(global_".gbl")=""

/* these are no longer needed - they are DeepSee 1
// Get list of all globals matching ^BI.*
set global="^BI"
for {
set global=$order(^$GLOBAL(global))
quit:($e(global,1,4)'="^BI.")
set list(global_".gbl")=""
}
*/

// Get list of all globals matching ^ABC.*
//but don't export the large patient and admission globals unless explicitly told to.
set global="^ABC"
for {
set global=$order(^$GLOBAL(global))

quit:($e(global,1,5)'="^ABC.")
continue:(excludedata&(global="^ABC.DemoData"))
continue:(excludedata&(global="^ABC.PatientD"))
continue:(excludedata&(global="^ABC.PatientI"))
continue:(excludedata&(global="^ABC.AdmissionD"))
continue:(excludedata&(global="^ABC.AdmissionI"))
continue:(excludedata&(global="^ABC.AdmissionRequestD"))
set list(global_".gbl")=""
}

// Get list of all globals matching ^Tran.*
set global="^Tran"
for {
set global=$order(^$GLOBAL(global))
quit:($e(global,1,5)'="^Tran")
set list(global_".gbl")=""
}


//individually specify any other items here, such as CSP pages

// Get list of DeepSee Folders
set global="^ABC.Demo"
set list("^DeepSee.FolderD.gbl")=""
set list("^DeepSee.FolderI.gbl")=""
set list("^DeepSee.FolderItemD.gbl")=""
set list("^DeepSee.FolderItemI.gbl")=""
set list("^DeepSee.UserPreferences.gbl")=""
set list("^DeepSee.UserPortalSettigs.gbl")=""

//set list("/csp/"_$zu(5)_"/EHRpatientView.csp")=""

; Get all the CSP classes and csp files
set dir=$system.CSP.GetFileName("/csp/"_$zu(5)_"/")
set rs=##class(%ResultSet).%New("%File:FileSet")
set tSC=rs.Execute(dir,"*.*",,0)
for {

quit:rs.Next()=0
set file=rs.GetData(1),file=$p(file,"\",$l(file,"\"))
;break
continue:(file'["ABC")&(file'["ABC")
set list("/csp/"_$zu(5)_"/"_file)=""
}
; Get all the files from ./pimages
set dir=$system.CSP.GetFileName("/csp/"_$zu(5)_"/pimages/")
set rs=##class(%ResultSet).%New("%File:FileSet")
set tSC=rs.Execute(dir,"*.*",,0)
for {

quit:rs.Next()=0
set file=rs.GetData(1),file=$p(file,"\",$l(file,"\"))
set list("/csp/"_$zu(5)_"/pimages/"_file)=""
}
;
set list("Pharm_2.3.HL7")=""
//having built up the array, we can now export it
zw list
do $system.OBJ.Export(.list,FileName)
}

}

Hi,

Thank you,

Bala

--

Bala

unread,
Jun 2, 2011, 1:44:45 AM6/2/11
to InterSystems: Ensemble in Healthcare
Thank you Bill and Dave.

That helped me with the export.

On May 31, 5:22 pm, David Loveluck <David.Lovel...@intersystems.com>
wrote:
> You can use $System.OBJ.Export() t export a single item such as aglobal, or you can build an array with the subscripts being the items you want to export. This allows you to export many things in one go.
>                 if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e( last,1,6)["Processsys")) {
>                         set list(class_".cls")=""
>                 }
>         }
>         // Get list of all classes in the Transplant package
>         set x=$system.OBJ.GetPackageList(.classList,"Transplant")
>         set class=""
>         for {
>                 set class=$order(classList(class))
>                 continue:class["Contextsys"
>                 continue:class["Processsys"
>                 quit:class=""
>                 //skip generated classes (ending in .Context or .Threadn)
>                 set last=$p(class,".",$l(class,"."))
>                 if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e( last,1,6)["Processsys")) {
>                         set list(class_".cls")=""
>                 }
>         }
>         // Get list of all classes in the EnsMonitor2 package
>         set x=$system.OBJ.GetPackageList(.classList,"EnsMonitor2")
>         set class=""
>         for {
>                 set class=$order(classList(class))
>                 continue:class["Contextsys"
>                 continue:class["Processsys"
>                 quit:class=""
>                 //skip generated classes (ending in .Context or .Threadn)
>                 set last=$p(class,".",$l(class,"."))
>                 if '((last="Context")||($e(last,1,6)="Thread")||($e(last,1,7)="Context")||($e( last,1,6)["Processsys")) {
>                         set list(class_".cls")=""
>                 }
>         }
>         //get all the business rules in package ABC
>         set tRS=##class(%ResultSet).%New("Ens.Rule.RuleDefinition:EnumerateRules")
>
>         set tSC=tRS.Execute()
>         while tRS.Next() {
>                 set tPackage=tRS.Data("Package")
>                 set tName=tRS.Data("Name")
>                 if (tPackage["ABC")||(tName["ABC")||(tName["ABC")||(tPackage["ABC") {
>                         set list(tPackage_"."_tName_".rul")=""
>                 }
>
>         }
>         //export the credentialsglobal
>         setglobal="^Ens.Conf.CredentialsD"
>         set list(global_".gbl")=""
>
>         //^SYS("BI")globalstored the subject areas
>         //setglobal="^SYS"
>         setglobal="^ABC.Demo"
Reply all
Reply to author
Forward
0 new messages