Guest User

Untitled

a guest
Apr 30th, 2014
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. Include (%occInclude, %occStatus)
  2.  
  3. /// The following bulk changes are done in T2013:
  4. /// - change all %this variable references to $this (new Cache standard)
  5. /// - remove LegacyInstanceContext class keyword from all classes (it adds legacy %this support)
  6. /// - remove all the properties named ‘dummy’ from the web classes (these were only needed in Object Architect)
  7. Class zTRAK.SSH.LabUpdate [ Abstract ]
  8. {
  9.  
  10. /// This Parameter is updated by Perforce
  11. Parameter SrcVer = "$Id$";
  12.  
  13. ClassMethod ParseTrak(ApplyChange As %Boolean = 0, ByRef Output As %String)
  14. {
  15. Kill Output
  16.  
  17. // Change this to your Source Control class
  18. Set %ist = ##class(Studio.SourceControl.IST).%New("")
  19.  
  20. #; Parse Classes
  21. Do ..ParseClasses(ApplyChange, .Output)
  22.  
  23. Set firstCol = 40
  24. Set secondCol = 10
  25.  
  26. Do ..WriteLine($Justify(+$Get(Output(".fileCount"))_" files processed", firstCol),"B")
  27. Do ..WriteLine($Justify(+$Get(Output(".itemCount"))_" changes "_$Select(ApplyChange:"applied",1:"found"), firstCol),"B")
  28. Do ..WriteLine($Justify(+$Get(Output(".errorCount"))_" errors encountered", firstCol),"B")
  29. Write !
  30. }
  31.  
  32. ClassMethod ParseClasses(ApplyChange As %Boolean = 0, ByRef Output As %String)
  33. {
  34. Set cls="AA"
  35. For {
  36. Set cls=$Order(^oddCOM(cls))
  37. If cls="" q
  38. // Apply class name checks
  39. if $e(cls,1,7)'="User.LB" continue
  40. /*
  41. if $e(cls,1,3)="Ens" continue // skip Ensemble
  42. if $e(cls,1,4)="java" continue // skip java
  43. */
  44.  
  45. Set status = ..ParseDocument(cls_".CLS", ApplyChange, .Output)
  46.  
  47. If $$$ISERR(status) {
  48. If $Increment(Output(".errorCount"))
  49. Do $System.OBJ.DisplayError(status)
  50. }
  51. }
  52. If $$$ISERR(status) Do $System.OBJ.DisplayError(status)
  53. }
  54.  
  55. ClassMethod ParseDocument(InternalName As %String, ApplyChange As %Boolean = 0, ByRef Output As %String) As %Status
  56. {
  57. Set status = $$$OK
  58. Set type = ..FileType(InternalName)
  59.  
  60. Set extName = %ist.ExtName(InternalName)
  61.  
  62. If type = "class" {
  63. If $Increment(Output(".fileCount"))
  64. Set className = $Piece(InternalName, ".", 1, $Length(InternalName, ".") - 1)
  65.  
  66. If extName'="" {
  67. If ApplyChange {
  68. Set status = %ist.GetStatus(InternalName,.IsInSourceControl,.Editable,.IsCheckedOut,.UserCheckedOut)
  69. If $$$ISOK(status) {
  70. If '$g(IsCheckedOut) Set status = %ist.CheckOut(InternalName)
  71. If $$$ISOK(status) {
  72. // Apply class changes here
  73. do $classmethod(className,"%KillExtent")
  74. do ##class(%Dictionary.StorageDefinition).%DeleteId(className_"||Default")
  75. // Compile
  76. do $system.OBJ.Compile(className)
  77. // Export
  78. If $$$ISOK(status) {
  79. Do %ist.OnAfterSave(InternalName)
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. Quit status
  87. }
  88.  
  89. /// helper function to determine project item type
  90. ClassMethod FileType(InternalName As %String) As %String [ Private ]
  91. {
  92. If $ZConvert(InternalName,"U")[".CLS" Quit "class"
  93. If $ZConvert(InternalName,"U")[".CSP" Quit "csp"
  94. If $ZConvert(InternalName,"U")[".CSR" Quit "csr"
  95. If $ZConvert(InternalName,"U")[".PRJ" Quit "project"
  96. If $ZConvert(InternalName,"U")[".INC" Quit "routine"
  97. If $ZConvert(InternalName,"U")[".INT" Quit "routine"
  98. If $ZConvert(InternalName,"U")[".MAC" Quit "routine"
  99. If $ZConvert(InternalName,"U")[".BAS" Quit "routine"
  100. If $ZConvert(InternalName,"U")[".JS" Quit "javascript"
  101. Quit "other"
  102. }
  103.  
  104. /// Weight options:
  105. /// [0-9] - indent
  106. /// B - Bold
  107. /// U - Underline
  108. /// N - Suppress new line
  109. ClassMethod WriteLine(Message As %String, Weight As %String = "") [ Private, ProcedureBlock = 1 ]
  110. {
  111. #define hon $c(27,91,49,109)
  112. #define uon $c(27,91,52,109)
  113. #define rst $c(27,91,109)
  114.  
  115. If Weight'["N" Write !
  116. If +Weight Write $Justify("",+Weight)
  117. If Weight["B" Write $$$hon
  118. If Weight["U" Write $$$uon
  119. Write Message
  120. If $Length(Weight) Write $$$rst
  121.  
  122. Quit
  123. }
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment