Skip to content

Commit

Permalink
add xml version of classes
Browse files Browse the repository at this point in the history
  • Loading branch information
doublefint committed Nov 23, 2016
1 parent 3384b6a commit d5f7de4
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 134 deletions.
127 changes: 127 additions & 0 deletions sc.all.sub.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="sc.all.sub">
<Description>
Export different types of modules in different subfolders</Description>
<Super>sc.all</Super>
<TimeCreated>64245,54012</TimeCreated>

<Method name="filename">
<Description><![CDATA[
test.dfi -> /dfi/test.dfi
test.cls -> /cls/test.cls
etc]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>code</FormalSpec>
<Implementation><![CDATA[
s ext = $p( code, ".", * ), ext = $zcvt( ext, "l" )
#; for each type - different directory
s wd = ..workdir() s:ext'="" wd = ##class(%File).NormalizeDirectory( ext, wd )
d:'##class(%File).DirectoryExists( wd ) ##class(%File).CreateDirectoryChain( wd )
s filename = ##class(%File).NormalizeFilename( code, wd )
#; for *.dfi filename can contain folders
if ext = "dfi" {
s path = ##class(%File).GetDirectory( filename )
d:'##class(%File).DirectoryExists( path ) ##class(%File).CreateDirectoryChain( path )
}
Q filename
]]></Implementation>
</Method>

<Method name="importUpdated">
<Description>
import from workdir all files with ts newer than code ts in db</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[qspec="cku-d",&err="",recurse=1,&loaded="",verbose=1]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
#define push(%dir) s dirs( $i( dirs ) ) = %dir
#define next(%i,%dir) s %i=$o( dirs( "" ), 1, %dir ) k:%i'="" dirs(%i)
#define isDirectory(%type) ( %type = "D" )
#define log w !, filename, " -> ", codename, " ", +sc
s sc = 1, dirs = "", dir = ..workdir() $$$push(dir)
s rs = ##class(%ResultSet).%New( "%Library.File:FileSet" )
for { $$$next(i,dir) Q:i="" Q:dir=""
s sc = rs.Execute( dir, "*.*" ) Q:'sc
while rs.Next() {
s filename = rs.Name
if $$$isDirectory( rs.Type ) {
if ( recurse ) $$$push(filename) ;push directory
continue
}
s filets = rs.DateModified
s codename = ..codename( filename, .ext )
s codets = ..codets( codename, ext )
if ( filets '] codets ) continue
/*
w !, " ************* import ************** "
w !, "file: ", filets
w !, "code: ", codets
*/
if ext = "dfi" {
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .loaded )
} else {
s sc = $system.OBJ.Load( filename, qspec, .err, .loaded)
}
if verbose $$$log
}
}
Q sc
]]></Implementation>
</Method>

<Method name="codename">
<Description>
presumable codename </Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[filename,&ext=""]]></FormalSpec>
<Implementation><![CDATA[
s ext = $p( filename, ".", * ), ext = $zcvt( ext, "l" )
s path = ##class(%File).NormalizeDirectory( ext, ..workdir() )
s codename = $p( filename, path, 2 )
if ext = "dfi" {
s fullname = $tr( codename, "\", "/" ) ; return fullname for dfi in $$$IsWINDOWS
Q $p( fullname, ".", 1, *-1 ) ;remove extension
}
Q codename
]]></Implementation>
</Method>

<Method name="codets">
<ClassMethod>1</ClassMethod>
<FormalSpec>codename,ext</FormalSpec>
<Implementation><![CDATA[
s ts = ""
if ext'="dfi" {
s ts = ##class(%RoutineMgr).TS( codename )
} else {
s sql="Select timeModified From %DeepSee_UserLibrary.FolderItem Where fullname = ?"
s rs = ##class(%SQL.Statement).%ExecDirect( , sql, codename )
if rs.%Next() {
s utcts = rs.timeModified
s utch = $zdth( utcts, 3, , 3 ) ;utc internal format
s loch = $zdth( utch, -3 ) ; utc to local timezone
s ts = $zdt( loch, 3, ,0 ) ; local timestamp*/
}
}
Q $p( ts, "." ) ;remove ms
]]></Implementation>
</Method>
</Class>
</Export>
136 changes: 2 additions & 134 deletions sc.all.prj.xml → sc.all.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.2 (Build 728U)">
<Project name="sc-all">
<Items>
<ProjectItem name="sc.all" type="CLS"></ProjectItem>
<ProjectItem name="sc.all.sub" type="CLS"></ProjectItem>
</Items>
</Project>


<Export generator="Cache" version="25">
<Class name="sc.all">
<Description>

Expand All @@ -18,6 +10,7 @@ d ##class(sc.all).export()
d ##class(sc.all).import()
</Description>
<Abstract>1</Abstract>
<TimeCreated>64245,54012</TimeCreated>

<Method name="export">
<Description>
Expand Down Expand Up @@ -173,129 +166,4 @@ gl[obal] n[ame] - storage for settings</Description>
]]></Implementation>
</Method>
</Class>


<Class name="sc.all.sub">
<Description>
Export different types of modules in different subfolders</Description>
<Super>sc.all</Super>

<Method name="filename">
<Description><![CDATA[
test.dfi -> /dfi/test.dfi
test.cls -> /cls/test.cls
etc]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>code</FormalSpec>
<Implementation><![CDATA[
s ext = $p( code, ".", * ), ext = $zcvt( ext, "l" )
#; for each type - different directory
s wd = ..workdir() s:ext'="" wd = ##class(%File).NormalizeDirectory( ext, wd )
d:'##class(%File).DirectoryExists( wd ) ##class(%File).CreateDirectoryChain( wd )
s filename = ##class(%File).NormalizeFilename( code, wd )
#; for *.dfi filename can contain folders
if ext = "dfi" {
s path = ##class(%File).GetDirectory( filename )
d:'##class(%File).DirectoryExists( path ) ##class(%File).CreateDirectoryChain( path )
}
Q filename
]]></Implementation>
</Method>

<Method name="importUpdated">
<Description>
import from workdir all files with ts newer than code ts in db</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[qspec="cku-d",&err="",recurse=1,&loaded="",verbose=1]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
#define push(%dir) s dirs( $i( dirs ) ) = %dir
#define next(%i,%dir) s %i=$o( dirs( "" ), 1, %dir ) k:%i'="" dirs(%i)
#define isDirectory(%type) ( %type = "D" )
#define log w !, filename, " -> ", codename, " ", +sc
s sc = 1, dirs = "", dir = ..workdir() $$$push(dir)
s rs = ##class(%ResultSet).%New( "%Library.File:FileSet" )
for { $$$next(i,dir) Q:i="" Q:dir=""
s sc = rs.Execute( dir, "*.*" ) Q:'sc
while rs.Next() {
s filename = rs.Name
if $$$isDirectory( rs.Type ) {
if ( recurse ) $$$push(filename) ;push directory
continue
}
s filets = rs.DateModified
s codename = ..codename( filename, .ext )
s codets = ..codets( codename, ext )
if ( filets '] codets ) continue
/*
w !, " ************* import ************** "
w !, "file: ", filets
w !, "code: ", codets
*/
if ext = "dfi" {
s sc = ##class(%DeepSee.UserLibrary.Utils).%Import( filename, 1, 0, 0, "", .loaded )
} else {
s sc = $system.OBJ.Load( filename, qspec, .err, .loaded)
}
if verbose $$$log
}
}
Q sc
]]></Implementation>
</Method>

<Method name="codename">
<Description>
presumable codename </Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[filename,&ext=""]]></FormalSpec>
<Implementation><![CDATA[
s ext = $p( filename, ".", * ), ext = $zcvt( ext, "l" )
s path = ##class(%File).NormalizeDirectory( ext, ..workdir() )
s codename = $p( filename, path, 2 )
if ext = "dfi" {
s fullname = $tr( codename, "\", "/" ) ; return fullname for dfi in $$$IsWINDOWS
Q $p( fullname, ".", 1, *-1 ) ;remove extension
}
Q codename
]]></Implementation>
</Method>

<Method name="codets">
<ClassMethod>1</ClassMethod>
<FormalSpec>codename,ext</FormalSpec>
<Implementation><![CDATA[
s ts = ""
if ext'="dfi" {
s ts = ##class(%RoutineMgr).TS( codename )
} else {
s sql="Select timeModified From %DeepSee_UserLibrary.FolderItem Where fullname = ?"
s rs = ##class(%SQL.Statement).%ExecDirect( , sql, codename )
if rs.%Next() {
s utcts = rs.timeModified
s utch = $zdth( utcts, 3, , 3 ) ;utc internal format
s loch = $zdth( utch, -3 ) ; utc to local timezone
s ts = $zdt( loch, 3, ,0 ) ; local timestamp*/
}
}
Q $p( ts, "." ) ;remove ms
]]></Implementation>
</Method>
</Class>
</Export>

0 comments on commit d5f7de4

Please sign in to comment.