iris-pex-embedded-python 3.5.5b4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. grongier/__init__.py +0 -0
  2. grongier/cls/Grongier/PEX/BusinessOperation.cls +8 -0
  3. grongier/cls/Grongier/PEX/BusinessProcess.cls +13 -0
  4. grongier/cls/Grongier/PEX/BusinessService.cls +8 -0
  5. grongier/cls/Grongier/PEX/Common.cls +10 -0
  6. grongier/cls/Grongier/PEX/Director.cls +10 -0
  7. grongier/cls/Grongier/PEX/Duplex/Operation.cls +4 -0
  8. grongier/cls/Grongier/PEX/Duplex/Process.cls +13 -0
  9. grongier/cls/Grongier/PEX/Duplex/Service.cls +4 -0
  10. grongier/cls/Grongier/PEX/InboundAdapter.cls +8 -0
  11. grongier/cls/Grongier/PEX/Message.cls +13 -0
  12. grongier/cls/Grongier/PEX/OutboundAdapter.cls +8 -0
  13. grongier/cls/Grongier/PEX/PickleMessage.cls +13 -0
  14. grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +8 -0
  15. grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +14 -0
  16. grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +14 -0
  17. grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +14 -0
  18. grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +14 -0
  19. grongier/cls/Grongier/PEX/Test.cls +10 -0
  20. grongier/cls/Grongier/PEX/Utils.cls +10 -0
  21. grongier/cls/Grongier/Service/WSGI.cls +4 -0
  22. grongier/pex/__init__.py +24 -0
  23. grongier/pex/__main__.py +4 -0
  24. grongier/pex/_business_host.py +1 -0
  25. grongier/pex/_cli.py +4 -0
  26. grongier/pex/_common.py +1 -0
  27. grongier/pex/_director.py +1 -0
  28. grongier/pex/_utils.py +1 -0
  29. grongier/pex/wsgi/handlers.py +104 -0
  30. iop/__init__.py +25 -0
  31. iop/__main__.py +4 -0
  32. iop/_async_request.py +67 -0
  33. iop/_business_host.py +256 -0
  34. iop/_business_operation.py +75 -0
  35. iop/_business_process.py +224 -0
  36. iop/_business_service.py +63 -0
  37. iop/_cli.py +247 -0
  38. iop/_common.py +334 -0
  39. iop/_debugpy.py +187 -0
  40. iop/_decorators.py +49 -0
  41. iop/_director.py +301 -0
  42. iop/_dispatch.py +136 -0
  43. iop/_generator_request.py +30 -0
  44. iop/_inbound_adapter.py +34 -0
  45. iop/_iris.py +8 -0
  46. iop/_log_manager.py +100 -0
  47. iop/_message.py +40 -0
  48. iop/_message_validator.py +49 -0
  49. iop/_outbound_adapter.py +23 -0
  50. iop/_private_session_duplex.py +103 -0
  51. iop/_private_session_process.py +41 -0
  52. iop/_remote.py +91 -0
  53. iop/_serialization.py +199 -0
  54. iop/_utils.py +671 -0
  55. iop/cls/IOP/BusinessOperation.cls +35 -0
  56. iop/cls/IOP/BusinessProcess.cls +156 -0
  57. iop/cls/IOP/BusinessService.cls +40 -0
  58. iop/cls/IOP/Common.cls +569 -0
  59. iop/cls/IOP/Director.cls +70 -0
  60. iop/cls/IOP/Duplex/Operation.cls +29 -0
  61. iop/cls/IOP/Duplex/Process.cls +229 -0
  62. iop/cls/IOP/Duplex/Service.cls +9 -0
  63. iop/cls/IOP/Generator/Message/Ack.cls +31 -0
  64. iop/cls/IOP/Generator/Message/Poll.cls +31 -0
  65. iop/cls/IOP/Generator/Message/Start.cls +15 -0
  66. iop/cls/IOP/Generator/Message/StartPickle.cls +15 -0
  67. iop/cls/IOP/Generator/Message/Stop.cls +32 -0
  68. iop/cls/IOP/InboundAdapter.cls +22 -0
  69. iop/cls/IOP/Message/JSONSchema.cls +125 -0
  70. iop/cls/IOP/Message.cls +754 -0
  71. iop/cls/IOP/OutboundAdapter.cls +36 -0
  72. iop/cls/IOP/PickleMessage.cls +58 -0
  73. iop/cls/IOP/PrivateSession/Duplex.cls +260 -0
  74. iop/cls/IOP/PrivateSession/Message/Ack.cls +32 -0
  75. iop/cls/IOP/PrivateSession/Message/Poll.cls +32 -0
  76. iop/cls/IOP/PrivateSession/Message/Start.cls +31 -0
  77. iop/cls/IOP/PrivateSession/Message/Stop.cls +48 -0
  78. iop/cls/IOP/Projection.cls +49 -0
  79. iop/cls/IOP/Service/Remote/Handler.cls +30 -0
  80. iop/cls/IOP/Service/Remote/Rest/v1.cls +97 -0
  81. iop/cls/IOP/Service/WSGI.cls +310 -0
  82. iop/cls/IOP/Test.cls +85 -0
  83. iop/cls/IOP/Utils.cls +503 -0
  84. iop/cls/IOP/Wrapper.cls +58 -0
  85. iop/wsgi/handlers.py +104 -0
  86. iris_pex_embedded_python-3.5.5b4.dist-info/METADATA +91 -0
  87. iris_pex_embedded_python-3.5.5b4.dist-info/RECORD +91 -0
  88. iris_pex_embedded_python-3.5.5b4.dist-info/WHEEL +5 -0
  89. iris_pex_embedded_python-3.5.5b4.dist-info/entry_points.txt +2 -0
  90. iris_pex_embedded_python-3.5.5b4.dist-info/licenses/LICENSE +21 -0
  91. iris_pex_embedded_python-3.5.5b4.dist-info/top_level.txt +2 -0
@@ -0,0 +1,229 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.DuplexProcess Extends IOP.BusinessProcess [ ClassType = persistent, ProcedureBlock, System = 4 ]
6
+ {
7
+
8
+ /// Domain for Text localization
9
+ Parameter DOMAIN = "PrivateSession";
10
+
11
+ /// The Duplex Service name. This property is set at runtime after receiving the primary request
12
+ Property ServiceDuplexName As %String;
13
+
14
+ /// Indicates if a given ConfigItem is in private session or not
15
+ Property %IsInPrivateSession As array Of %Boolean(STORAGEDEFAULT = "list");
16
+
17
+ /// This method is always called asynchronously ONCE at the beginning of the process
18
+ Method OnRequest(
19
+ pRequest As %Library.Persistent,
20
+ Output pResponse As Ens.Response) As %Status
21
+ {
22
+ #dim tSC As %Status = $$$OK
23
+ try {
24
+ If $IsObject(pRequest)&&($classname(pRequest)="IOP.PrivateSession.Message.Start") {
25
+ Set tSC=..Reply(##class(IOP.PrivateSession.Message.Ack).%New()) Quit:$$$ISERR(tSC)
26
+ Set ..ServiceDuplexName = ..%PrimaryRequestHeader.SourceConfigName
27
+ Do ..IsInPrivateSessionSet(..ServiceDuplexName,1)
28
+ Set tSC=..SendRequestAsync(..ServiceDuplexName,##class(IOP.PrivateSession.Message.Poll).%New(),1) Quit:$$$ISERR(tSC)
29
+ Set tSC=..OnPrivateSessionStarted(..ServiceDuplexName,0) Quit:$$$ISERR(tSC)
30
+ } Else {
31
+ Set tSC=..OnDocument(..%PrimaryRequestHeader.SourceConfigName,pRequest)
32
+ }
33
+ } catch {
34
+ Set tSC=$$$EnsSystemError
35
+ }
36
+ Quit tSC
37
+ }
38
+
39
+ /// Handle a 'Response'
40
+ Method OnResponse(
41
+ request As %Library.Persistent,
42
+ ByRef response As %Library.Persistent,
43
+ callrequest As %Library.Persistent,
44
+ callresponse As %Library.Persistent,
45
+ pCompletionKey As %String) As %Status
46
+ {
47
+ #dim tSC As %Status = $$$OK
48
+ #dim tSourceConfigName, tOneConfigName As %String
49
+ try {
50
+ ; get the SourceConfigName of this message
51
+ Set tSourceConfigName=..%CurrentResponseHeader.SourceConfigName
52
+ ; handle SessionStop message
53
+ If $IsObject(callresponse)&&($classname(callresponse)="IOP.PrivateSession.Message.Ack") {
54
+ Do ..IsInPrivateSessionSet(tSourceConfigName,1)
55
+ Set tSC=..SendRequestAsync(tSourceConfigName,##class(IOP.PrivateSession.Message.Poll).%New(),1) Quit:$$$ISERR(tSC)
56
+ Set tSC=..OnPrivateSessionStarted(tSourceConfigName,1) Quit:$$$ISERR(tSC)
57
+ Quit
58
+ }
59
+ ; handle SessionStop message
60
+ If $IsObject(callresponse)&&($classname(callresponse)="IOP.PrivateSession.Message.Stop") {
61
+ Set tSC=..UnRegisterPrivateSession(tSourceConfigName) Quit:$$$ISERR(tSC)
62
+ Set tSC=..OnPrivateSessionStopped(tSourceConfigName,0,callresponse.AttachedMessage) Quit:$$$ISERR(tSC)
63
+ Quit
64
+ }
65
+ ; send poll request again back to the same ConfigItem if this this is in response to a poll request
66
+ If $IsObject(callrequest)&&($classname(callrequest)="IOP.PrivateSession.Message.Poll") {
67
+ If ..IsInPrivateSession(tSourceConfigName) {
68
+ Set tSC=..SendRequestAsync(tSourceConfigName,##class(IOP.PrivateSession.Message.Poll).%New(),1) If $$$ISERR(tSC)
69
+ }
70
+ }
71
+ ; call OnDocument
72
+ Set tSC=..OnDocument(tSourceConfigName,callresponse) Quit:$$$ISERR(tSC)
73
+ } catch {
74
+ Set tSC=$$$EnsSystemError
75
+ }
76
+ Quit tSC
77
+ }
78
+
79
+ Method StartPrivateSession(pDuplexConfigName As %String = "") As %Status
80
+ {
81
+ #dim tSC As %Status = $$$OK
82
+ try {
83
+ If pDuplexConfigName="" Set tSC=$$$EnsError($$$EnsErrGeneral,"Duplex configuration name is missing") Quit
84
+ If ..IsInPrivateSession(pDuplexConfigName) Quit
85
+ Set tSC=..SendRequestAsync(pDuplexConfigName,##class(IOP.PrivateSession.Message.Start).%New()) Quit:$$$ISERR(tSC)
86
+ } catch {
87
+ Set tSC=$$$EnsSystemError
88
+ }
89
+ Quit tSC
90
+ }
91
+
92
+ Method StopPrivateSession(
93
+ pDuplexConfigName As %String = "",
94
+ pAttachedMessage As %Persistent = "") As %Status
95
+ {
96
+ #dim tSC As %Status = $$$OK
97
+ try {
98
+ If pDuplexConfigName="" Set tSC=$$$EnsError($$$EnsErrGeneral,"Duplex configuration name is missing") Quit
99
+ If '..IsInPrivateSession(pDuplexConfigName) Quit
100
+ Set tSC=..SendRequestAsync(pDuplexConfigName,##class(IOP.PrivateSession.Message.Stop).%New(pAttachedMessage),0) Quit:$$$ISERR(tSC)
101
+ Set tSC=..UnRegisterPrivateSession(pDuplexConfigName)
102
+ Set tSC=..OnPrivateSessionStopped(pDuplexConfigName,1) Quit:$$$ISERR(tSC)
103
+ } catch {
104
+ Set tSC=$$$EnsSystemError
105
+ }
106
+ Quit tSC
107
+ }
108
+
109
+ Method StopAllPrivateSessions(pAttachedMessage As %Persistent = "") As %Status
110
+ {
111
+ #dim tSC As %Status = $$$OK
112
+ #dim tItem As %String
113
+ try {
114
+ Set tItem="" For {
115
+ Set tItem=..%IsInPrivateSession.Next(tItem) Quit:tItem=""
116
+ Set tSC=..StopPrivateSession(tItem,pAttachedMessage) Quit:$$$ISERR(tSC)
117
+ }
118
+ } catch {
119
+ Set tSC=$$$EnsSystemError
120
+ }
121
+ Quit tSC
122
+ }
123
+
124
+ Method UnRegisterPrivateSession(pDuplexConfigName As %String) As %String
125
+ {
126
+ #dim tSC As %Status = $$$OK
127
+ try {
128
+ For i=..%MasterPendingResponses.Count():-1:1 {
129
+ Set tRequestHeader=##class(Ens.MessageHeader).%OpenId($li(..%MasterPendingResponses.GetAt(i),1))
130
+ If $IsObject(tRequestHeader),tRequestHeader.TargetConfigName=pDuplexConfigName,tRequestHeader.MessageBodyClassName="IOP.PrivateSession.Message.Poll" {
131
+ Do ..%MasterPendingResponses.RemoveAt(i)
132
+ }
133
+ }
134
+ Do ..IsInPrivateSessionSet(pDuplexConfigName,0)
135
+ } catch {
136
+ Set tSC=$$$EnsSystemError
137
+ }
138
+ Quit tSC
139
+ }
140
+
141
+ Method IsInPrivateSessionSet(
142
+ pDuplexConfigName As %String,
143
+ pInPrivateSession As %Boolean)
144
+ {
145
+ If pInPrivateSession {
146
+ Do ..%IsInPrivateSession.SetAt(1,pDuplexConfigName)
147
+ } Else {
148
+ Do ..%IsInPrivateSession.RemoveAt(pDuplexConfigName)
149
+ }
150
+ Quit
151
+ }
152
+
153
+ Method IsInPrivateSession(pDuplexConfigName As %String) As %Boolean
154
+ {
155
+ If pDuplexConfigName="" Quit 0
156
+ Quit ..%IsInPrivateSession.IsDefined(pDuplexConfigName)
157
+ }
158
+
159
+ Method OnDocument(
160
+ pSourceConfigName As %String,
161
+ pInput As %Library.Persistent) As %Status
162
+ {
163
+ set tSC = $$$OK
164
+ try {
165
+ set response = ..%class."_dispatch_on_document"($this,pSourceConfigName,pInput)
166
+ } catch ex {
167
+ set tSC = ex.AsStatus()
168
+ }
169
+ quit tSC
170
+ }
171
+
172
+ Method OnPrivateSessionStarted(
173
+ pSourceConfigName As %String,
174
+ pSelfGenerated As %Boolean) As %Status
175
+ {
176
+ set tSC = $$$OK
177
+ try {
178
+ set response = ..%class."_dispatch_on_private_session_started"($this,pSourceConfigName,pSelfGenerated)
179
+ } catch ex {
180
+ set tSC = ex.AsStatus()
181
+ }
182
+ quit tSC
183
+ }
184
+
185
+ Method OnPrivateSessionStopped(
186
+ pSourceConfigName As %String,
187
+ pSelfGenerated As %Boolean,
188
+ pAttachedMessage As %Persistent = "") As %Status
189
+ {
190
+ set tSC = $$$OK
191
+ try {
192
+ set response = ..%class."_dispatch_on_private_session_stopped"($this,pSourceConfigName,pSelfGenerated,pAttachedMessage)
193
+ } catch ex {
194
+ set tSC = ex.AsStatus()
195
+ }
196
+ quit tSC
197
+ }
198
+
199
+ Storage Default
200
+ {
201
+ <Data name="ProcessDefaultData">
202
+ <Subscript>"Process"</Subscript>
203
+ <Value name="1">
204
+ <Value>ServiceDuplexName</Value>
205
+ </Value>
206
+ <Value name="2">
207
+ <Value>%IsInPrivateSession</Value>
208
+ </Value>
209
+ <Value name="3">
210
+ <Value>%classpaths</Value>
211
+ </Value>
212
+ <Value name="4">
213
+ <Value>%classname</Value>
214
+ </Value>
215
+ <Value name="5">
216
+ <Value>%module</Value>
217
+ </Value>
218
+ <Value name="6">
219
+ <Value>%settings</Value>
220
+ </Value>
221
+ <Value name="7">
222
+ <Value>%class</Value>
223
+ </Value>
224
+ </Data>
225
+ <DefaultData>ProcessDefaultData</DefaultData>
226
+ <Type>%Storage.Persistent</Type>
227
+ }
228
+
229
+ }
@@ -0,0 +1,9 @@
1
+ Class IOP.DuplexService Extends IOP.PrivateSessionDuplex
2
+ {
3
+
4
+ ClassMethod OnBusinessType(pItem As Ens.Config.Item) As %Integer
5
+ {
6
+ Quit $$$eHostTypeService
7
+ }
8
+
9
+ }
@@ -0,0 +1,31 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.Generator.Message.Ack Extends (%Persistent, Ens.Util.MessageBodyMethods) [ ClassType = persistent, Inheritance = right, ProcedureBlock, System = 4 ]
6
+ {
7
+
8
+ Parameter DOMAIN = "Generator";
9
+
10
+ /// From 'Ens.Util.MessageBodyMethods'
11
+ Method %ShowContents(pZenOutput As %Boolean = 0)
12
+ {
13
+ Write $$$Text("(session-ack)")
14
+ }
15
+
16
+ Storage Default
17
+ {
18
+ <Data name="AckDefaultData">
19
+ <Value name="1">
20
+ <Value>%%CLASSNAME</Value>
21
+ </Value>
22
+ </Data>
23
+ <DataLocation>^IOP.Generator.Message.AckD</DataLocation>
24
+ <DefaultData>AckDefaultData</DefaultData>
25
+ <IdLocation>^IOP.Generator.Message.AckD</IdLocation>
26
+ <IndexLocation>^IOP.Generator.Message.AckI</IndexLocation>
27
+ <StreamLocation>^IOP.Generator.Message.AckS</StreamLocation>
28
+ <Type>%Storage.Persistent</Type>
29
+ }
30
+
31
+ }
@@ -0,0 +1,31 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.Generator.Message.Poll Extends (%Persistent, Ens.Util.MessageBodyMethods) [ ClassType = persistent, Inheritance = right, ProcedureBlock, System = 4 ]
6
+ {
7
+
8
+ Parameter DOMAIN = "Generator";
9
+
10
+ /// From 'Ens.Util.MessageBodyMethods'
11
+ Method %ShowContents(pZenOutput As %Boolean = 0)
12
+ {
13
+ Write $$$Text("(poll-data)")
14
+ }
15
+
16
+ Storage Default
17
+ {
18
+ <Data name="PollDefaultData">
19
+ <Value name="1">
20
+ <Value>%%CLASSNAME</Value>
21
+ </Value>
22
+ </Data>
23
+ <DataLocation>^IOP.PrivateS9756.PollD</DataLocation>
24
+ <DefaultData>PollDefaultData</DefaultData>
25
+ <IdLocation>^IOP.PrivateS9756.PollD</IdLocation>
26
+ <IndexLocation>^IOP.PrivateS9756.PollI</IndexLocation>
27
+ <StreamLocation>^IOP.PrivateS9756.PollS</StreamLocation>
28
+ <Type>%Storage.Persistent</Type>
29
+ }
30
+
31
+ }
@@ -0,0 +1,15 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.Generator.Message.Start Extends IOP.Message [ ClassType = persistent, Inheritance = right, ProcedureBlock ]
6
+ {
7
+
8
+ Parameter DOMAIN = "Generator";
9
+
10
+ Storage Default
11
+ {
12
+ <Type>%Storage.Persistent</Type>
13
+ }
14
+
15
+ }
@@ -0,0 +1,15 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.Generator.Message.StartPickle Extends IOP.PickleMessage [ ClassType = persistent, Inheritance = right, ProcedureBlock ]
6
+ {
7
+
8
+ Parameter DOMAIN = "Generator";
9
+
10
+ Storage Default
11
+ {
12
+ <Type>%Storage.Persistent</Type>
13
+ }
14
+
15
+ }
@@ -0,0 +1,32 @@
1
+ /* Copyright (c) 2022 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.Generator.Message.Stop Extends (%Persistent, Ens.Util.MessageBodyMethods) [ ClassType = persistent, Inheritance = right, ProcedureBlock, System = 4 ]
6
+ {
7
+
8
+ Parameter DOMAIN = "PrivateSession";
9
+
10
+ /// From 'Ens.Util.MessageBodyMethods'
11
+ Method %ShowContents(pZenOutput As %Boolean = 0)
12
+ {
13
+
14
+ Write $$$Text("(session-stop)")
15
+ }
16
+
17
+ Storage Default
18
+ {
19
+ <Data name="StopDefaultData">
20
+ <Value name="1">
21
+ <Value>%%CLASSNAME</Value>
22
+ </Value>
23
+ </Data>
24
+ <DataLocation>^IOP.Generator.Message.StopD</DataLocation>
25
+ <DefaultData>StopDefaultData</DefaultData>
26
+ <IdLocation>^IOP.Generator.Message.StopD</IdLocation>
27
+ <IndexLocation>^IOP.Generator.Message.StopI</IndexLocation>
28
+ <StreamLocation>^IOP.Generator.Message.StopS</StreamLocation>
29
+ <Type>%Storage.Persistent</Type>
30
+ }
31
+
32
+ }
@@ -0,0 +1,22 @@
1
+ /* Copyright (c) 2021 by InterSystems Corporation.
2
+ Cambridge, Massachusetts, U.S.A. All rights reserved.
3
+ Confidential property of InterSystems Corporation. */
4
+
5
+ Class IOP.InboundAdapter Extends (Ens.InboundAdapter, IOP.Common) [ Inheritance = right, ProcedureBlock, System = 4 ]
6
+ {
7
+
8
+ Parameter SETTINGS = "%classname:Python InboundAdapter,%module:Python InboundAdapter,%settings:Python InboundAdapter,%classpaths:Python InboundAdapter";
9
+
10
+ Method OnTask() As %Status
11
+ {
12
+ set tSC = $$$OK
13
+ try {
14
+ $$$ThrowOnError(..Connect())
15
+ do ..%class."on_task"()
16
+ } catch ex {
17
+ set tSC = ..DisplayTraceback(ex)
18
+ }
19
+ quit tSC
20
+ }
21
+
22
+ }
@@ -0,0 +1,125 @@
1
+ Class IOP.Message.JSONSchema Extends %Persistent
2
+ {
3
+
4
+ Property Name As %String;
5
+
6
+ Property Category As %String;
7
+
8
+ Property JSONSchema As %String(MAXLEN = "");
9
+
10
+ Index NameIndex On Name [ IdKey, Unique ];
11
+
12
+ /// Import a JSON Schema from file
13
+ ClassMethod ImportFromFile(
14
+ pFileName As %String,
15
+ pCategory As %String = "",
16
+ pName As %String) As %Status
17
+ {
18
+ Set pStatus = $$$OK
19
+ Try {
20
+ If '##class(%File).Exists(pFileName) {
21
+ Set pStatus = $$$ERROR($$$GeneralError, "File not found")
22
+ Return pStatus
23
+ }
24
+ Set tFile = ##class(%File).%New(pFileName)
25
+ $$$ThrowOnError(tFile.Open("R"))
26
+ Set tSchema = ""
27
+ While 'tFile.AtEnd {
28
+ Set tSchema = tSchema _ tFile.ReadLine()
29
+ }
30
+ Set pStatus = ..Import(tSchema, pCategory, pName)
31
+ } Catch ex {
32
+ Set pStatus = ex.AsStatus()
33
+ }
34
+ Return pStatus
35
+ }
36
+
37
+ /// Store the JSON Schema in this object
38
+ ClassMethod Import(
39
+ pSchema As %String,
40
+ pCategory As %String = "",
41
+ pName As %String) As %Status
42
+ {
43
+ Set pStatus = $$$OK
44
+ Try {
45
+ if ##class(IOP.Message.JSONSchema).%ExistsId(pName) {
46
+ Set tThis = ##class(IOP.Message.JSONSchema).%OpenId(pName)
47
+ Set tThis.Category = pCategory
48
+ Set tThis.JSONSchema = pSchema
49
+ $$$ThrowOnError(tThis.%Save())
50
+ } Else {
51
+ Set tThis = ##class(IOP.Message.JSONSchema).%New()
52
+ Set tThis.Name = pName
53
+ Set tThis.Category = pCategory
54
+ Set tThis.JSONSchema = pSchema
55
+ $$$ThrowOnError(tThis.%Save())
56
+ }
57
+ } Catch ex {
58
+ Set pStatus = ex.AsStatus()
59
+ }
60
+ Quit pStatus
61
+ }
62
+
63
+ /// Get a stored schema by category and name
64
+ ClassMethod GetSchema(
65
+ pName As %String = "",
66
+ Output pSchema As %String) As %Status
67
+ {
68
+ Set pStatus = $$$OK
69
+ Try {
70
+ Set tSql = "SELECT JSONSchema FROM IOP_Message.JSONSchema WHERE Name = ?"
71
+ Set tStatement = ##class(%SQL.Statement).%New()
72
+ Do tStatement.%Prepare(tSql)
73
+ set rs = tStatement.%Execute(pName)
74
+ If rs.%Next() {
75
+ Set pSchema = rs.%Get("JSONSchema")
76
+ } Else {
77
+ Set pStatus = $$$ERROR($$$GeneralError, "Schema not found")
78
+ }
79
+ } Catch ex {
80
+ Set pStatus = ex.AsStatus()
81
+ }
82
+ Return pStatus
83
+ }
84
+
85
+ /// Validate JSON data against a stored schema
86
+ ClassMethod ValidateJSONSchema(
87
+ pJSON As %String,
88
+ pName As %String) As %Status
89
+ {
90
+ Set tSC = $$$OK
91
+ Try {
92
+ Set tSchema = ""
93
+ Set tSC = ..GetSchema(pName, .tSchema)
94
+ If $$$ISERR(tSC) Return tSC
95
+ // Validate JSON data against schema
96
+ // To be implemented
97
+ Set tSC = $$$OK
98
+ } Catch ex {
99
+ Set tSC = ex.AsStatus()
100
+ }
101
+ Return tSC
102
+ }
103
+
104
+ Storage Default
105
+ {
106
+ <Data name="JSONSchemaDefaultData">
107
+ <Value name="1">
108
+ <Value>%%CLASSNAME</Value>
109
+ </Value>
110
+ <Value name="2">
111
+ <Value>JSONSchema</Value>
112
+ </Value>
113
+ <Value name="3">
114
+ <Value>Category</Value>
115
+ </Value>
116
+ </Data>
117
+ <DataLocation>^IOP.Message.JSONSchemaD</DataLocation>
118
+ <DefaultData>JSONSchemaDefaultData</DefaultData>
119
+ <IdLocation>^IOP.Message.JSONSchemaD</IdLocation>
120
+ <IndexLocation>^IOP.Message.JSONSchemaI</IndexLocation>
121
+ <StreamLocation>^IOP.Message.JSONSchemaS</StreamLocation>
122
+ <Type>%Storage.Persistent</Type>
123
+ }
124
+
125
+ }