|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.1 (Build 792U)" ts="2017-08-18 17:12:53"> |
| 3 | +<Class name="SQLKPI.Installer"> |
| 4 | +<TimeChanged>64513,61955.639014</TimeChanged> |
| 5 | +<TimeCreated>64513,60278.826343</TimeCreated> |
| 6 | + |
| 7 | +<XData name="Install"> |
| 8 | +<XMLNamespace>INSTALLER</XMLNamespace> |
| 9 | +<Data><![CDATA[ |
| 10 | +<Manifest> |
| 11 | + <IfNotDef Var="Namespace"> |
| 12 | + <Var Name="Namespace" Value="SQLKPI"/> |
| 13 | + <Log Text="Set namespace to ${Namespace}" Level="0"/> |
| 14 | + </IfNotDef> |
| 15 | + |
| 16 | + <If Condition='(##class(Config.Namespaces).Exists("${Namespace}")=0)'> |
| 17 | + <Log Text="Creating namespace ${Namespace}" Level="0"/> |
| 18 | + <Namespace Name="${Namespace}" Create="yes" Code="${Namespace}" Ensemble="0" Data="${Namespace}"> |
| 19 | + <Configuration> |
| 20 | + <Database Name="${Namespace}" Dir="${MGRDIR}${Namespace}" Create="yes"/> |
| 21 | + </Configuration> |
| 22 | + </Namespace> |
| 23 | + <Log Text="End Creating namespace ${Namespace}" Level="0"/> |
| 24 | + </If> |
| 25 | + |
| 26 | + <Role Name="SQLKPIRole" Description="Role to access and use the SQLKPI" Resources="%DB_CACHESYS:RW,%Admin_Secure:U" /> |
| 27 | + <Namespace Name="${Namespace}" Create="no"> |
| 28 | + <RunInstall Class="SQLKPI.Installer" Method="CopyClasses"/> |
| 29 | + <RunInstall Class="SQLKPI.Installer" Method="CreateApplication"/> |
| 30 | + <CSPApplication Url="/csp/sqlkpi" Recurse="1" Directory="${CSPDIR}sqlkpi" AuthenticationMethods="64" IsNamespaceDefault="true" Grant="AppRole" /> |
| 31 | + <Log Text="Copying web application files" Level="0"/> |
| 32 | + <RunInstall Class="SQLKPI.Installer" Method="CopyFiles"/> |
| 33 | + </Namespace> |
| 34 | + |
| 35 | + <If Condition='(##class(Config.Namespaces).Exists("%All")=0)'> |
| 36 | + <Log Text="Creating namespace %All" Level="0"/> |
| 37 | + <Namespace Name="%All" Create="yes" Code="CACHETEMP" Data="CACHETEMP" Ensemble="0"> |
| 38 | + <Configuration> |
| 39 | + <Log Text="Mapping SQLKPI package to %All namespace" Level="0"/> |
| 40 | + <ClassMapping From="${Namespace}" Package="SQLKPI"/> |
| 41 | + </Configuration> |
| 42 | + </Namespace> |
| 43 | + </If> |
| 44 | + |
| 45 | + <If Condition='(##class(Config.Namespaces).Exists("%All")=1)'> |
| 46 | + <Namespace Name="%All" Create="no" Code="CACHETEMP" Data="CACHETEMP" Ensemble="0"> |
| 47 | + <Configuration> |
| 48 | + <Log Text="Mapping package SQLKPI to %All namespace" Level="0"/> |
| 49 | + <ClassMapping From="${Namespace}" Package="SQLKPI"/> |
| 50 | + </Configuration> |
| 51 | + </Namespace> |
| 52 | + </If> |
| 53 | + |
| 54 | + |
| 55 | + <Log Text="Mapping SQLKPI package to Samples namespace" Level="0"/> |
| 56 | + <If Condition='##class(Config.Namespaces).Exists("Samples")'> |
| 57 | + <Namespace Name="Samples" Create="no" Code="SAMPLES" Data="SAMPLES" Ensemble="0"> |
| 58 | + <Configuration> |
| 59 | + <ClassMapping From="${Namespace}" Package="SQLKPI"/> |
| 60 | + </Configuration> |
| 61 | + </Namespace> |
| 62 | + </If> |
| 63 | + </Manifest> |
| 64 | +]]></Data> |
| 65 | +</XData> |
| 66 | + |
| 67 | +<Method name="setup"> |
| 68 | +<Internal>1</Internal> |
| 69 | +<ClassMethod>1</ClassMethod> |
| 70 | +<CodeMode>objectgenerator</CodeMode> |
| 71 | +<FormalSpec><![CDATA[&pVars,pLogLevel:%Integer=0,pInstaller:%Installer.Installer]]></FormalSpec> |
| 72 | +<ReturnType>%Status</ReturnType> |
| 73 | +<Implementation><![CDATA[ Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "Install") |
| 74 | +]]></Implementation> |
| 75 | +</Method> |
| 76 | + |
| 77 | +<Method name="CreateApplication"> |
| 78 | +<ClassMethod>1</ClassMethod> |
| 79 | +<FormalSpec>pVars,pLogLevel,tInstaller</FormalSpec> |
| 80 | +<Implementation><![CDATA[ |
| 81 | + set Namespace = tInstaller.Evaluate("${Namespace}") |
| 82 | + do tInstaller.PushNS("%SYS") |
| 83 | + if ('##class(Security.Applications).Exists("/sqlkpi")) { |
| 84 | + set cspProperties("NameSpace") = Namespace |
| 85 | + set cspProperties("AutheEnabled") = $$$AutheCache |
| 86 | + set cspProperties("IsNameSpaceDefault") = $$$NO |
| 87 | + set cspProperties("DispatchClass") = "SQLKPI.REST" |
| 88 | + set cspProperties("GroupById") = "sqlkpi" |
| 89 | + set cspProperties("MatchRoles") = ":SQLKPIRole" |
| 90 | + set cspProperties("CookiePath") = "/" |
| 91 | + |
| 92 | + set tSC = ##class(Security.Applications).Create("/sqlkpi", .cspProperties) |
| 93 | + if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC) |
| 94 | + kill cspProperties |
| 95 | + } |
| 96 | + |
| 97 | + do tInstaller.PopNS() |
| 98 | + |
| 99 | + quit $$$OK |
| 100 | +]]></Implementation> |
| 101 | +</Method> |
| 102 | + |
| 103 | +<Method name="CopyClasses"> |
| 104 | +<ClassMethod>1</ClassMethod> |
| 105 | +<FormalSpec>pVars,pLogLevel,tInstaller</FormalSpec> |
| 106 | +<Implementation><![CDATA[ |
| 107 | + set sc = $$$OK |
| 108 | + |
| 109 | + set i = 0 |
| 110 | + while 1 { |
| 111 | + set id = "SQLKPI.CLSData||File" _ i |
| 112 | + if (##class(%Dictionary.CompiledXData).%ExistsId(id) = 0) Q |
| 113 | + set class = ##class(%Dictionary.CompiledXData).%OpenId(id) |
| 114 | + set data = $zconvert(class.Data.Read(class.Data.Size), "O", "UTF8") |
| 115 | + set className = "SQLKPI."_$piece(class.Description,".",1) |
| 116 | + |
| 117 | + set Namespace = tInstaller.Evaluate("${Namespace}") |
| 118 | + do tInstaller.PushNS(Namespace) |
| 119 | + |
| 120 | + if ('##class(%Dictionary.ClassDefinition).%ExistsId(className)) { |
| 121 | + set clsDef = ##class(%Dictionary.ClassDefinition).%New() |
| 122 | + set clsDef.Name = className |
| 123 | + set sc = clsDef.%Save() |
| 124 | + quit:$$$ISERR(sc) |
| 125 | + } |
| 126 | + set sc = ##class(%Compiler.UDL.TextServices).SetTextFromString(,className,$System.Encryption.Base64Decode(data)) |
| 127 | + do $system.OBJ.Compile(className, "cuk") |
| 128 | + |
| 129 | + do tInstaller.PopNS() |
| 130 | + |
| 131 | + set i = i + 1 |
| 132 | + } |
| 133 | + |
| 134 | + quit $$$OK |
| 135 | +]]></Implementation> |
| 136 | +</Method> |
| 137 | + |
| 138 | +<Method name="CopyFiles"> |
| 139 | +<ClassMethod>1</ClassMethod> |
| 140 | +<FormalSpec>pVars,pLogLevel,tInstaller</FormalSpec> |
| 141 | +<Implementation><![CDATA[ |
| 142 | + set csp = tInstaller.Evaluate("${CSPDIR}") |
| 143 | + set path = ##class(%File).NormalizeDirectory(csp _ "sqlkpi") |
| 144 | + |
| 145 | + // Get path separator |
| 146 | + set r = ##class(%File).NormalizeDirectory("\") |
| 147 | + if ($find(r, "/") = 0) { |
| 148 | + set r = "\" |
| 149 | + } else { |
| 150 | + set r = "/" |
| 151 | + } |
| 152 | + |
| 153 | + set i = 0 |
| 154 | + while 1 { |
| 155 | + set id = "SQLKPI.CSPData||File" _ i |
| 156 | + if (##class(%Dictionary.CompiledXData).%ExistsId(id) = 0) Q |
| 157 | + set file = ##class(%Dictionary.CompiledXData).%OpenId(id) |
| 158 | + |
| 159 | + set data = $zconvert(file.Data.Read(file.Data.Size), "O", "UTF8") |
| 160 | + set fileName = ##class(%File).NormalizeFilename(path _ file.Description) |
| 161 | + |
| 162 | + |
| 163 | + set fileName = $replace(fileName, "\", r) |
| 164 | + set fileName = $replace(fileName, "/", r) |
| 165 | + set dir = ##class(%File).ParentDirectoryName(fileName) |
| 166 | + if ('##class(%File).DirectoryExists(dir)) { |
| 167 | + do ##class(%File).CreateDirectory(dir) |
| 168 | + } |
| 169 | + |
| 170 | + do tInstaller.Log(pLogLevel, "Creating file", fileName) |
| 171 | + |
| 172 | + |
| 173 | + set f = ##class(%Stream.FileBinary).%New() |
| 174 | + do f.LinkToFile(fileName) |
| 175 | + do f.Write($System.Encryption.Base64Decode(data)) |
| 176 | + do f.%Save() |
| 177 | + |
| 178 | + set i = i + 1 |
| 179 | + } |
| 180 | + |
| 181 | + quit $$$OK |
| 182 | +]]></Implementation> |
| 183 | +</Method> |
| 184 | +</Class> |
| 185 | +</Export> |
0 commit comments