Skip to content

Commit 1c502a1

Browse files
committed
import/export in xml for dashboards and pivots added
1 parent 4c0fc8b commit 1c502a1

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

sc.code.cls

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Class sc.code [ Abstract ]
55
{
66

77
/// export all available code
8-
ClassMethod export(generated = 0, system = 0, percent = 0, mapped = 0, mask = "")
8+
ClassMethod export(generated = 0, system = 0, percent = 0, mapped = 0, mask = "", dfi = 0)
99
{
1010

1111
#define export(%code, %file) s sc = $system.OBJ.ExportUDL(%code, %file,"/diffexport") ##continue
@@ -73,11 +73,17 @@ ClassMethod export(generated = 0, system = 0, percent = 0, mapped = 0, mask = ""
7373
s rs = ##class(%SQL.Statement).%ExecDirect( .stm, sql )
7474
while rs.%Next() {
7575
s code = rs.Name, filename = ..filename( code_".dfi" )
76-
if ( '$find( code, mask ) ) continue
76+
if ( '$find( filename, mask ) ) continue
7777
if ($L(code,"$TRASH")>1) continue
7878
$$$mkdir( filename )
79-
$$$log
80-
$$$export(code,filename)
79+
if dfi{
80+
$$$log
81+
$$$export( code, filename)
82+
}
83+
else{
84+
set filename = $extract(filename,1,*-4)
85+
do ##class(%DeepSee.UserLibrary.Utils).%Export(code,filename_".xml",1)
86+
}
8187

8288
} s rs=""
8389

@@ -87,7 +93,7 @@ ClassMethod export(generated = 0, system = 0, percent = 0, mapped = 0, mask = ""
8793
}
8894

8995
/// import all from workdir
90-
ClassMethod import(filemask = "*.xml;*.cls;*.mac;*.int;*.inc;*.dfi", qspec = "cku-d", ByRef err = "", recurse = 1, ByRef loaded = "", verbose = 1) As %Status
96+
ClassMethod import(filemask = "*.xml;*.cls;*.mac;*.int;*.inc;*.dfi", qspec = "cku-d", ByRef err = "", recurse = 1, ByRef loaded = "", verbose = 1, dfi = 0) As %Status
9197
{
9298
#define push(%dir) s dirs( $i( dirs ) ) = %dir
9399
#define next(%i,%dir) s %i=$o( dirs( "" ), 1, %dir ) k:%i'="" dirs(%i)
@@ -111,10 +117,19 @@ ClassMethod import(filemask = "*.xml;*.cls;*.mac;*.int;*.inc;*.dfi", qspec = "ck
111117
// check file filter
112118
if ..inFilter(.fm,filename) continue
113119

114-
s ext = $p( filename, ".", * )
120+
s ext = $zcvt($p( filename, ".", * ),"l")
121+
122+
if (ext = "dfi") || (ext = "xml") {
123+
if (ext = "dfi") {
124+
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .dsloaded )
125+
}elseif ((ext = "xml") && dfi = 0){
126+
set location = $piece(filename,"\dfi\",1)
127+
set name = $piece(filename,"\dfi\",2)
128+
set name = $replace(name,"\","-")
129+
set filename = location_"\dfi\"_name
130+
do ##class(%DeepSee.UserLibrary.Utils).%Import(filename,1,0)
131+
}
115132

116-
if $zcvt( ext, "l" ) = "dfi" {
117-
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .dsloaded )
118133
} else {
119134
// load classes only
120135
s sc = $system.OBJ.Load( filename, "k-d", .err, .loaded)
@@ -143,7 +158,7 @@ ClassMethod import(filemask = "*.xml;*.cls;*.mac;*.int;*.inc;*.dfi", qspec = "ck
143158
Q sc
144159
}
145160

146-
ClassMethod inFilter(ByRef filtermask,filename) as %Boolean
161+
ClassMethod inFilter(ByRef filtermask, filename) As %Boolean
147162
{
148163
s result=0
149164
for
@@ -158,7 +173,7 @@ ClassMethod inFilter(ByRef filtermask,filename) as %Boolean
158173

159174
/// get the filtermask for the repository.
160175
/// looks for .gitignore file and applies all the lines to filters
161-
ClassMethod setIgnore(ByRef filtermask)
176+
ClassMethod setIgnore(ByRef filtermask)
162177
{
163178

164179
// working with .gitignore file
@@ -179,7 +194,6 @@ ClassMethod setIgnore(ByRef filtermask)
179194
quit
180195
}
181196

182-
183197
/// get or set working directory for export/import source
184198
ClassMethod workdir(workdir)
185199
{
@@ -195,8 +209,6 @@ ClassMethod gln() [ CodeMode = expression, Private ]
195209
"^"_$classname()
196210
}
197211

198-
199-
200212
ClassMethod init()
201213
{
202214
#define confile "/cos.json"
@@ -211,7 +223,8 @@ ClassMethod init()
211223
}
212224

213225
/// export release file for list and project settings
214-
ClassMethod release() {
226+
ClassMethod release()
227+
{
215228
s gln=..gln()
216229
s list=$G(@gln@("compileList"))
217230
if list="" w "Nothing to release. Run init method first" quit
@@ -222,7 +235,8 @@ ClassMethod release() {
222235
w "All objects with mask "_list_" has been exported to "_release
223236
}
224237

225-
ClassMethod compile() {
238+
ClassMethod compile()
239+
{
226240
s gln=..gln()
227241
s list=$G(@gln@("compileList"))
228242
if list="" w "Nothing to compile. Run init method first" quit
@@ -269,7 +283,7 @@ ClassMethod filename(code)
269283
}
270284

271285
/// import from workdir all files with ts newer than code ts in db
272-
ClassMethod importUpdated(filemask = "*.*", qspec = "cku-d", ByRef err = "", recurse = 1, ByRef loaded = "", verbose = 1) As %Status
286+
ClassMethod importUpdated(filemask = "*.*", qspec = "cku-d", ByRef err = "", recurse = 1, ByRef loaded = "", verbose = 1, dfi = 0) As %Status
273287
{
274288
#define push(%dir) s dirs( $i( dirs ) ) = %dir
275289
#define next(%i,%dir) s %i=$o( dirs( "" ), 1, %dir ) k:%i'="" dirs(%i)
@@ -303,10 +317,16 @@ ClassMethod importUpdated(filemask = "*.*", qspec = "cku-d", ByRef err = "", rec
303317

304318
if ( filets '] codets ) continue
305319

306-
if ext = "dfi" {
307-
308-
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .loaded )
309-
320+
if (ext = "dfi") || (ext = "xml") {
321+
if (ext = "dfi") {
322+
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .dsloaded )
323+
}elseif ((ext = "xml") && dfi = 0){
324+
set location = $piece(filename,"\dfi\",1)
325+
set name = $piece(filename,"\dfi\",2)
326+
set name = $replace(name,"\","-")
327+
set filename = location_"\dfi\"_name
328+
do ##class(%DeepSee.UserLibrary.Utils).%Import(filename,1,0)
329+
}
310330
} else {
311331

312332
#; drop existing code before import ( purge DateModified )
@@ -354,6 +374,4 @@ ClassMethod codets(codename, ext)
354374
Q $p( ts, "." ) ;remove ms
355375
}
356376

357-
358377
}
359-

0 commit comments

Comments
 (0)