Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Include (%occInclude, %occStatus)
- /// The following bulk changes are done in T2013:
- /// - change all %this variable references to $this (new Cache standard)
- /// - remove LegacyInstanceContext class keyword from all classes (it adds legacy %this support)
- /// - remove all the properties named ‘dummy’ from the web classes (these were only needed in Object Architect)
- Class zTRAK.SSH.LabUpdate [ Abstract ]
- {
- /// This Parameter is updated by Perforce
- Parameter SrcVer = "$Id$";
- ClassMethod ParseTrak(ApplyChange As %Boolean = 0, ByRef Output As %String)
- {
- Kill Output
- // Change this to your Source Control class
- Set %ist = ##class(Studio.SourceControl.IST).%New("")
- #; Parse Classes
- Do ..ParseClasses(ApplyChange, .Output)
- Set firstCol = 40
- Set secondCol = 10
- Do ..WriteLine($Justify(+$Get(Output(".fileCount"))_" files processed", firstCol),"B")
- Do ..WriteLine($Justify(+$Get(Output(".itemCount"))_" changes "_$Select(ApplyChange:"applied",1:"found"), firstCol),"B")
- Do ..WriteLine($Justify(+$Get(Output(".errorCount"))_" errors encountered", firstCol),"B")
- Write !
- }
- ClassMethod ParseClasses(ApplyChange As %Boolean = 0, ByRef Output As %String)
- {
- Set cls="AA"
- For {
- Set cls=$Order(^oddCOM(cls))
- If cls="" q
- // Apply class name checks
- if $e(cls,1,7)'="User.LB" continue
- /*
- if $e(cls,1,3)="Ens" continue // skip Ensemble
- if $e(cls,1,4)="java" continue // skip java
- */
- Set status = ..ParseDocument(cls_".CLS", ApplyChange, .Output)
- If $$$ISERR(status) {
- If $Increment(Output(".errorCount"))
- Do $System.OBJ.DisplayError(status)
- }
- }
- If $$$ISERR(status) Do $System.OBJ.DisplayError(status)
- }
- ClassMethod ParseDocument(InternalName As %String, ApplyChange As %Boolean = 0, ByRef Output As %String) As %Status
- {
- Set status = $$$OK
- Set type = ..FileType(InternalName)
- Set extName = %ist.ExtName(InternalName)
- If type = "class" {
- If $Increment(Output(".fileCount"))
- Set className = $Piece(InternalName, ".", 1, $Length(InternalName, ".") - 1)
- If extName'="" {
- If ApplyChange {
- Set status = %ist.GetStatus(InternalName,.IsInSourceControl,.Editable,.IsCheckedOut,.UserCheckedOut)
- If $$$ISOK(status) {
- If '$g(IsCheckedOut) Set status = %ist.CheckOut(InternalName)
- If $$$ISOK(status) {
- // Apply class changes here
- do $classmethod(className,"%KillExtent")
- do ##class(%Dictionary.StorageDefinition).%DeleteId(className_"||Default")
- // Compile
- do $system.OBJ.Compile(className)
- // Export
- If $$$ISOK(status) {
- Do %ist.OnAfterSave(InternalName)
- }
- }
- }
- }
- }
- }
- Quit status
- }
- /// helper function to determine project item type
- ClassMethod FileType(InternalName As %String) As %String [ Private ]
- {
- If $ZConvert(InternalName,"U")[".CLS" Quit "class"
- If $ZConvert(InternalName,"U")[".CSP" Quit "csp"
- If $ZConvert(InternalName,"U")[".CSR" Quit "csr"
- If $ZConvert(InternalName,"U")[".PRJ" Quit "project"
- If $ZConvert(InternalName,"U")[".INC" Quit "routine"
- If $ZConvert(InternalName,"U")[".INT" Quit "routine"
- If $ZConvert(InternalName,"U")[".MAC" Quit "routine"
- If $ZConvert(InternalName,"U")[".BAS" Quit "routine"
- If $ZConvert(InternalName,"U")[".JS" Quit "javascript"
- Quit "other"
- }
- /// Weight options:
- /// [0-9] - indent
- /// B - Bold
- /// U - Underline
- /// N - Suppress new line
- ClassMethod WriteLine(Message As %String, Weight As %String = "") [ Private, ProcedureBlock = 1 ]
- {
- #define hon $c(27,91,49,109)
- #define uon $c(27,91,52,109)
- #define rst $c(27,91,109)
- If Weight'["N" Write !
- If +Weight Write $Justify("",+Weight)
- If Weight["B" Write $$$hon
- If Weight["U" Write $$$uon
- Write Message
- If $Length(Weight) Write $$$rst
- Quit
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment