4
4
Class sc .code [ Abstract ]
5
5
{
6
6
7
+ /// do ##class(sc.code).export()
7
8
/// export all available code
8
- ClassMethod export (generated = 0 , system = 0 , percent = 0 , mapped = 0 , mask = " " )
9
+ ClassMethod export (generated = 0 , system = 0 , percent = 0 , mapped = 0 , dfi = 0 )
9
10
{
11
+
10
12
11
- #define export (%code, %file ) s sc = $system .OBJ .ExportUDL (%code , %file ," /diffexport" ) ##continue
12
- w :sc " Ok" d :'sc $system .OBJ .DisplayError (sc )
13
+ #define export (%code, %file ) ##continue
14
+ s sc = $system .OBJ .ExportUDL (%code , %file ," /diffexport" ) ##continue
15
+ w +sc ##continue
16
+ if 'sc d $system .OBJ .DisplayError (sc )
13
17
14
18
#define isGenerated (%code ) ##class (%RoutineMgr ).IsGenerated ( %code )
15
19
#define isPercented (%code ) (" %" = $e (%code ))
16
20
#define isMapped (%code ) ##class (%RoutineMgr ).IsMapped ( %code )
17
- #define log w !, code , " -> " , $piece ( filename ,.. workdir (), 2 ) , " "
18
-
21
+ #define log w !, code , " -> " , filename , " "
22
+
19
23
#define mkdir (%filename ) ##continue
20
24
s path = ##class (%File ).GetDirectory ( %filename ) ##continue
21
25
if '##class (%File ).DirectoryExists ( path ) { ##continue
22
26
s sc = ##class (%File ).CreateDirectoryChain ( path ) ##continue
23
27
w !, " mkdir " , path , " " , sc ##continue
24
28
}
25
-
26
- w " #; Exporting to " , ..workdir (),!
29
+
30
+
31
+
27
32
#; classes
28
33
s rs = ##class (%ResultSet ).%New (" %Dictionary.ClassDefinition:Summary" )
29
34
if rs .Execute () {
30
35
31
36
while rs .%Next (){
32
-
33
37
s code = rs .Name _ " .cls" , isSystem = rs .System
34
38
if ( 'system && isSystem ) continue
35
39
if ( 'generated && $$$isGenerated( code ) ) continue
36
40
if ( 'percent && $$$isPercented( code ) ) continue
37
41
if ( 'mapped && $$$isMapped( code ) ) continue
38
- if ( '$find ( code , mask ) ) continue
39
-
40
42
s filename = ..filename ( code )
41
43
$$$mkdir( filename )
42
- $$$log
43
- $$$export( code , filename )
44
+ if dfi {
45
+ $$$log
46
+ $$$export( code , filename )
47
+ }
48
+ else {
49
+ do $system .OBJ .Export (code ,filename _" .xml" )
50
+ }
51
+
52
+
44
53
45
54
} s rs =" "
46
55
}
47
-
56
+
48
57
#; routines
49
58
s rs = ##class (%ResultSet ).%New (" %Routine:RoutineList" )
50
59
if rs .Execute () {
@@ -55,48 +64,51 @@ ClassMethod export(generated = 0, system = 0, percent = 0, mapped = 0, mask = ""
55
64
if ( 'generated && $$$isGenerated( code ) ) continue
56
65
if ( 'percent && $$$isPercented( code ) ) continue
57
66
if ( 'mapped && $$$isMapped( code ) ) continue
58
- if ( '$find ( code , mask ) ) continue
59
-
67
+
60
68
s filename = ..filename ( code )
61
69
$$$mkdir( filename )
62
- $$$log
63
- $$$export( code , filename )
70
+ if dfi {
71
+ $$$log
72
+ $$$export( code , filename )
73
+ }
74
+ else {
75
+ do $system .OBJ .Export (code ,filename _" .xml" )
76
+ }
64
77
65
78
} s rs =" "
66
79
}
67
80
68
81
69
82
#; dfi
70
- #define export (%code,%file ) s sc = ##class (%DeepSee.UserLibrary.Utils ).%Export ( %code , %file , 0 )
71
-
83
+ #define export (%code,%file ) w ##class (%DeepSee.UserLibrary.Utils ).%Export ( %code , %file , 0 )
72
84
s sql = " Select fullName as Name From %DeepSee_UserLibrary.FolderItem"
73
85
s rs = ##class (%SQL.Statement ).%ExecDirect ( .stm , sql )
74
86
while rs .%Next () {
75
87
s code = rs .Name , filename = ..filename ( code _" .dfi" )
76
- if ( '$find ( code , mask ) ) continue
77
- if ($L (code ," $TRASH" )>1 ) continue
78
88
$$$mkdir( filename )
79
- $$$log
80
- $$$export(code ,filename )
89
+ if dfi {
90
+ $$$log
91
+ $$$export( code , filename )
92
+ }
93
+ else {
94
+ do $system .OBJ .Export (code ,filename _" .xml" )
95
+ }
81
96
82
97
} s rs =" "
83
-
84
- w !,!, " #; Exported to " , ..workdir ()
85
-
98
+
86
99
Q 1
87
100
}
88
101
89
102
/// 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
103
+ ClassMethod import (filemask = " *.* " , qspec = " cku-d" , ByRef err = " " , recurse = 1 , ByRef loaded = " " , verbose = 1 ) As %Status
91
104
{
92
105
#define push (%dir ) s dirs ( $i ( dirs ) ) = %dir
93
106
#define next (%i,%dir ) s %i =$o ( dirs ( " " ), 1 , %dir ) k :%i '=" " dirs (%i )
94
107
#define isDirectory (%type ) ( %type = " D" )
95
- #define log w !, $piece ( filename ,.. workdir (), 2 ), " " w : sc " Ok " d :' sc $system .OBJ . DisplayError (sc )
108
+ #define log w !, filename , " " , + sc , $S ( sc = 1 : " " , 1 : " " _ $system .Status . GetOneErrorText (sc ) )
96
109
97
110
s sc = 1 , dirs = " " , dir = ..workdir () $$$push(dir )
98
- if verbose w " #; Importing from " , dir ,!
99
- d ..setIgnore (.fm )
111
+
100
112
for { $$$next(i ,dir ) Q :i =" " Q :dir =" "
101
113
102
114
s rs = ##class (%File ).FileSetFunc ( dir , filemask , , 1 )
@@ -108,78 +120,23 @@ ClassMethod import(filemask = "*.xml;*.cls;*.mac;*.int;*.inc;*.dfi", qspec = "ck
108
120
if recurse $$$push(filename )
109
121
continue
110
122
}
111
- // check file filter
112
- if ..inFilter (.fm ,filename ) continue
113
123
114
124
s ext = $p ( filename , " ." , * )
115
125
116
126
if $zcvt ( ext , " l" ) = " dfi" {
117
- s sc = ##class (%DeepSee.UserLibrary.Utils ).%Import ( filename , 1 , 0 , 0 , " " , .dsloaded )
127
+ s sc = ##class (%DeepSee.UserLibrary.Utils ).%Import ( filename , 1 , 0 , 0 , " " , .loaded )
118
128
} else {
119
- // load classes only
120
- s sc = $system .OBJ .Load ( filename , " k-d" , .err , .loaded )
129
+ s sc = $system .OBJ .Load ( filename , qspec , .err , .loaded )
121
130
}
122
131
123
132
if verbose $$$log
124
-
125
- }
126
- // compile all the loaded classes to obey dependencies
127
- s sc =$system .OBJ .CompileList ( .loaded , " cukbr-d/multicompile" ,.err )
128
-
129
- }
130
-
131
- if verbose {
132
-
133
- if $D (err ) {
134
- s i =$Order (err (" " ))
135
- while i '=" " {
136
- w !,err (i )
137
- s i =$O (err (i ))
138
- }
139
- }
140
-
141
- w !,!," #; Imported from " , ..workdir ()
142
- }
143
- Q sc
144
- }
145
133
146
- ClassMethod inFilter (ByRef filtermask ,filename ) as %Boolean
147
- {
148
- s result =0
149
- for
150
- {
151
- if '$d (filtermask ($I (i ))) quit
152
- set filter =$piece (filtermask (i )," *" )
153
- if $length (filename ,filter )>1 set result =1
154
- }
155
-
156
- quit result
157
- }
158
-
159
- /// get the filtermask for the repository.
160
- /// looks for .gitignore file and applies all the lines to filters
161
- ClassMethod setIgnore (ByRef filtermask )
162
- {
163
-
164
- // working with .gitignore file
165
- // gitignore consists of masks of filtering files
166
- s filename =..workdir ()_" /.gitignore"
167
- if '##class (%File ).Exists (filename ) quit
168
- s file =##class (%File ).%New (filename )
169
- s sc =file .Open (" R" )
170
- if 'sc
171
- {
172
- if verbose d $System .OBJ .DisplayError (sc ) return
134
+ }
173
135
}
174
136
175
- While 'file .AtEnd
176
- {
177
- s filtermask ($I (filtermask ))=file .ReadLine ()
178
- }
179
- quit
137
+ Q sc
180
138
}
181
139
182
-
183
140
/// get or set working directory for export/import source
184
141
ClassMethod workdir (workdir )
185
142
{
@@ -195,40 +152,6 @@ ClassMethod gln() [ CodeMode = expression, Private ]
195
152
" ^" _$classname ()
196
153
}
197
154
198
-
199
-
200
- ClassMethod init ()
201
- {
202
- #define confile " /cos.json"
203
- set stream =##class (%Stream.FileCharacter ).%New ()
204
- set sc =stream .LinkToFile (..workdir ()_$$$confile)
205
- s conf ={}.%FromJSON (stream .Read ($$$MaxCacheInt))
206
- s gln =..gln ()
207
- s @gln @(" compileList" )=conf .compileList
208
- s @gln @(" projectName" )=conf .projectName
209
- w " compileList=" _conf .compileList ,!
210
- w " projectName=" _conf .projectName
211
- }
212
-
213
- /// export release file for list and project settings
214
- ClassMethod release () {
215
- s gln =..gln ()
216
- s list =$G (@gln @(" compileList" ))
217
- if list =" " w " Nothing to release. Run init method first" quit
218
-
219
- s release =$G (@gln @(" projectName" )," release" )
220
- s release =release _$p ($zdt ($h ,8 )," " )_$tr ($p ($p ($zdt ($h )," " ,2 )," :" ,1 ,2 )," :" )_" .xml"
221
- D $System .OBJ .Export (list ,release )
222
- w " All objects with mask " _list _" has been exported to " _release
223
- }
224
-
225
- ClassMethod compile () {
226
- s gln =..gln ()
227
- s list =$G (@gln @(" compileList" ))
228
- if list =" " w " Nothing to compile. Run init method first" quit
229
- d $System .OBJ .compile (list )
230
- }
231
-
232
155
/// test.dfi -> /dfi/test.dfi
233
156
/// test.cls -> /cls/test.cls
234
157
/// testpkg.test.cls -> /cls/testpkg/test.cls
@@ -256,15 +179,14 @@ ClassMethod filename(code)
256
179
}
257
180
258
181
s filename = ##class (%File ).NormalizeFilename ( code , wd )
259
- #; lowercase file extension
260
- s $p (filename ," ." ,*)=ext
261
182
//B:code="DPRep.Rest.JSON.cls" "L"
262
183
#; for *.cls Package.Subpackage.ClassName.cls -> Folder/Subfolder/ClassName.cls
263
184
if ext =" cls" {
264
185
s dirs = $piece ( code , " ." ,1 , *-2 ), dirs = $translate ( dirs , " ." , " /" )
265
186
s relpath = dirs _ " /" _ $piece ( code , " ." , *-1 , * ) ;
266
187
s filename = ##class (%File ).NormalizeFilename ( relpath , wd )
267
188
}
189
+ set filename = $extract (filename ,1 ,*-4 )
268
190
Q filename
269
191
}
270
192
@@ -274,11 +196,8 @@ ClassMethod importUpdated(filemask = "*.*", qspec = "cku-d", ByRef err = "", rec
274
196
#define push (%dir ) s dirs ( $i ( dirs ) ) = %dir
275
197
#define next (%i,%dir ) s %i =$o ( dirs ( " " ), 1 , %dir ) k :%i '=" " dirs (%i )
276
198
#define isDirectory (%type ) ( %type = " D" )
277
- #define log w !, $piece (filename ,..workdir (),2 )," " w :sc " Ok" d :'sc $system .OBJ .DisplayError ( sc )
278
-
199
+ #define log w !, filename , " ->1 " , codename , " " , +sc
279
200
s sc = 1 , dirs = " " , dir = ..workdir () $$$push(dir )
280
- if verbose w " #; Importing updated from " , dir ,!
281
- d ..setIgnore (.fm )
282
201
for { $$$next(i ,dir ) Q :i =" " Q :dir =" "
283
202
284
203
s rs = ##class (%File ).FileSetFunc ( dir , filemask , , 1 )
@@ -291,34 +210,33 @@ ClassMethod importUpdated(filemask = "*.*", qspec = "cku-d", ByRef err = "", rec
291
210
continue
292
211
}
293
212
294
- // check file filter
295
- if ..inFilter (.fm ,filename ) continue
296
-
297
213
s filets = rs .DateModified
298
214
s codename = ..codename ( filename , .ext )
299
215
s codets = ..codets ( codename , ext )
300
-
301
- #; w !, filename, $c(9), "(", filets, ")"
302
- #; w !, codename, $c(9), "(", codets, ")"
303
-
304
216
if ( filets '] codets ) continue
305
-
217
+ //w codename,! B "L"
218
+
219
+ /*
220
+ w !, " ************* import ************** "
221
+ w !, "file: ", filets
222
+ w !, "code: ", codets
223
+ */
224
+
306
225
if ext = " dfi" {
307
226
308
227
s sc = ##class (%DeepSee.UserLibrary.Utils ).%Import ( filename , 1 , 0 , 0 , " " , .loaded )
309
228
310
229
} else {
311
230
312
231
#; drop existing code before import ( purge DateModified )
313
- #; s:codets'="" sc = ##class(%RoutineMgr).Delete( codename )
314
- k err s sc = $system .OBJ .Load ( filename , qspec , .err , .loaded )
232
+ s :codets '=" " sc = ##class (%RoutineMgr ).Delete ( codename )
233
+ s sc = $system .OBJ .Load ( filename , qspec , .err , .loaded )
315
234
316
235
}
317
236
318
237
if verbose $$$log
319
238
}
320
239
}
321
- w :verbose !," #; Imported updated from " , ..workdir ()
322
240
Q sc
323
241
}
324
242
@@ -332,7 +250,7 @@ ClassMethod codename(filename, ByRef ext = "")
332
250
s fullname = $tr ( codename , " \" , " /" ) ; return fullname for dfi in $$$IsWINDOWS
333
251
Q $p ( fullname , " ." , 1 , *-1 ) ;remove extension
334
252
}
335
- if (ext =" cls" )!(ext =" int" )!(ext =" inc" )!(ext =" mac" ) s codename =$tr (codename ," \ /" ," . ." )
253
+ if (ext =" cls" )!(ext =" int" )!(ext =" inc" )!(ext =" mac" ) s codename =$tr (codename ," /" ," ." )
336
254
Q codename
337
255
}
338
256
@@ -354,6 +272,4 @@ ClassMethod codets(codename, ext)
354
272
Q $p ( ts , " ." ) ;remove ms
355
273
}
356
274
357
-
358
275
}
359
-
0 commit comments