|
| 1 | +Class CDV.CDV Extends %Persistent |
| 2 | +{ |
| 3 | + |
| 4 | +ClassMethod ScanFromAllClasses(Replace As %String = "%", Capitalize As %Boolean = {$$$YES}) As %Status |
| 5 | +{ |
| 6 | + #Dim sc As %Status = $$$OK |
| 7 | + set sc = $System.OBJ.GetClassList(.Classes, "/application=0 /system=0 /percent=0 /mapped=0") |
| 8 | + Quit:$$$ISERR(sc) |
| 9 | + Set sc = ..ScanFromClassLocal(.Classes, Replace, Capitalize) |
| 10 | + Quit sc |
| 11 | +} |
| 12 | + |
| 13 | +ClassMethod ScanFromSubclassesOf(Class As %String, Replace As %String = "%", Capitalize As %Boolean = {$$$YES}) As %Status |
| 14 | +{ |
| 15 | + #Dim sc As %Status = $$$OK |
| 16 | + Set RS = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:SubclassOf") |
| 17 | + Set sc = RS.%Execute(Class) |
| 18 | + Quit:$$$ISERR(sc) |
| 19 | + |
| 20 | + Set Classes(Class) = "" |
| 21 | + |
| 22 | + While (RS.%Next(.sc)) { |
| 23 | + Quit:$$$ISERR(sc) |
| 24 | + Set Classes(RS.Data("Name")) = "" |
| 25 | + } |
| 26 | + |
| 27 | + Set sc = ..ScanFromClassLocal(.Classes, Replace, Capitalize) |
| 28 | + Quit sc |
| 29 | +} |
| 30 | + |
| 31 | +ClassMethod ScanFromMatchingClasses(Mask As %String, Replace As %String = "%", Capitalize As %Boolean = {$$$YES}) As %Status |
| 32 | +{ |
| 33 | + #Dim sc As %Status = $$$OK |
| 34 | + |
| 35 | + Set SQL = "SELECT ID FROM %Dictionary.ClassDefinition Where ID LIKE ?" |
| 36 | + Set ST = ##class(%SQL.Statement).%New() |
| 37 | + Set sc = ST.%Prepare(SQL) |
| 38 | + Quit:$$$ISERR(sc) sc |
| 39 | + |
| 40 | + #Dim RS As %SQL.StatementResult |
| 41 | + Set RS = ST.%Execute(Mask) |
| 42 | + |
| 43 | + While RS.%Next() { |
| 44 | + Set Classes(RS.%GetData(1)) = "" |
| 45 | + } |
| 46 | + |
| 47 | + Set sc = ..ScanFromClassLocal(.Classes, Replace, Capitalize) |
| 48 | + Quit sc |
| 49 | +} |
| 50 | + |
| 51 | +ClassMethod ScanFromClassLocal(ByRef Classes As %String, Replace As %String = "%", Capitalize As %Boolean = {$$$YES}) As %Status |
| 52 | +{ |
| 53 | + #Dim sc,sc1 As %Status = $$$OK |
| 54 | + Set Class = "" |
| 55 | + For { |
| 56 | + Set Class = $Order(Classes(Class)) |
| 57 | + Quit:Class="" |
| 58 | + If ($classmethod(Class, "%Extends", "%Persistent")) |
| 59 | + { |
| 60 | + Set sc1 = ..ValidateClassObjects(Class, Replace, Capitalize) |
| 61 | + } |
| 62 | + Set sc = $$$ADDSC(sc, sc1) |
| 63 | + } |
| 64 | + |
| 65 | + Quit sc |
| 66 | +} |
| 67 | + |
| 68 | +ClassMethod ValidateClassObjects(Class As %String, Replace As %String = "%", Capitalize As %Boolean = {$$$YES}) As %Status |
| 69 | +{ |
| 70 | + #Dim sc As %Status = $$$OK |
| 71 | + |
| 72 | + set Oid = Class |
| 73 | + set query = ##class(%SQL.Statement).%New() |
| 74 | + set status= query.%PrepareClassQuery(Class,"Extent") |
| 75 | + if 'status |
| 76 | + { |
| 77 | + do $system.OBJ.DisplayError(status) |
| 78 | + } |
| 79 | + set rset=query.%Execute() |
| 80 | + |
| 81 | + While (rset.%Next()) |
| 82 | + { |
| 83 | + set obj = $classmethod(Class, "%OpenId", rset.%Get("ID")) |
| 84 | + set Oid(Class,rset.%Get("ID")) = obj.%ValidateObject() |
| 85 | + Kill obj |
| 86 | + } |
| 87 | + |
| 88 | + zw Oid |
| 89 | + Quit sc |
| 90 | +} |
| 91 | + |
| 92 | +Storage Default |
| 93 | +{ |
| 94 | +<Data name="CDVDefaultData"> |
| 95 | +<Value name="1"> |
| 96 | +<Value>%%CLASSNAME</Value> |
| 97 | +</Value> |
| 98 | +<Value name="2"> |
| 99 | +<Value>Name</Value> |
| 100 | +</Value> |
| 101 | +</Data> |
| 102 | +<DataLocation>^CDV.CDVD</DataLocation> |
| 103 | +<DefaultData>CDVDefaultData</DefaultData> |
| 104 | +<IdLocation>^CDV.CDVD</IdLocation> |
| 105 | +<IndexLocation>^CDV.CDVI</IndexLocation> |
| 106 | +<StreamLocation>^CDV.CDVS</StreamLocation> |
| 107 | +<Type>%Library.CacheStorage</Type> |
| 108 | +} |
| 109 | + |
| 110 | +} |
| 111 | + |
0 commit comments