Skip to content

Commit c377292

Browse files
authored
Merge pull request #126 from Frisle/master
FEAT: added globals check in corresponding methods
2 parents 3564bd0 + 87840c0 commit c377292

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed

MDX2JSON/Utils.cls

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ ClassMethod ExecuteResultSet(RS As MDX2JSON.ResultSet, QueryKey As %String = "",
5353
quit Status
5454
}
5555

56+
ClassMethod QuerySet(MDX) As %Status
57+
{
58+
set ^Query($I(^Query), "%dsQuery") = MDX
59+
}
60+
5661
/// Automatic processing of MDX query and outputting resulting JSON.<br>
5762
/// <b>MDX</b> - String containing MDX query.<br>
5863
ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
@@ -76,6 +81,17 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
7681

7782
set obj = RS.ToProxyObject(.tSC)
7883
return:$$$ISERR(tSC) tSC
84+
85+
set %dsQuery = MDX
86+
87+
// initiate an RS object to a global variable %dsResultSet
88+
set %dsResultSet = RS
89+
90+
set %dsCubeName = RS.%Cube
91+
92+
// check if audit global hold something and execute it
93+
try {xecute ^DeepSee.AuditQueryCode} catch {}
94+
7995
$$$DynObjToJSON(obj)
8096

8197
}else{ // if cube is not compound execute the query in usual way
@@ -85,8 +101,17 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
85101

86102
set obj = RS.ToProxyObject(.tSC)
87103
return:$$$ISERR(tSC) tSC
104+
105+
set %dsQuery = MDX
106+
set %dsResultSet = RS
107+
108+
// check if audit global hold something and execute it
109+
try {xecute ^DeepSee.AuditQueryCode} catch {}
110+
88111
$$$DynObjToJSON(obj)
89112
}
113+
114+
90115
return $$$OK
91116
}
92117

@@ -108,7 +133,6 @@ ClassMethod WriteJSONfromQuery(CubeKey As %String, QueryKey As %String, Timeout
108133
return $$$OK
109134
}
110135

111-
112136
/// Execute SQL query taken from KPI and extract column values by name of column
113137
/// Output array with list of values like so pValue(n) = $LB(sNameList(i)...)
114138
ClassMethod GetSQLValues(pSQL, Output pValues As %String, Output tResultSet As %SQL.Statement) As %Status
@@ -133,7 +157,6 @@ ClassMethod GetSQLValues(pSQL, Output pValues As %String, Output tResultSet As %
133157
return st
134158
}
135159

136-
137160
/// This method provides listing execution for KPI.
138161
/// <b>tKPI<b> as a name of KPI class. <b>pFilters<b> not yet implemented
139162
/// as a <b>pSelection<b>. Thats for future use.
@@ -309,7 +332,7 @@ ClassMethod GetDataSource(pDataSource As %String)
309332

310333
set st = $$$OK
311334
try {
312-
335+
313336
if ($FIND(pDataSource, ".pivot") = ($LENGTH(pDataSource) + 1) && pDataSource '="") {
314337
set st = ..OpenPivotByName(pDataSource, .dataSource)
315338
return:($$$ISERR(st)) st
@@ -322,6 +345,7 @@ ClassMethod GetDataSource(pDataSource As %String)
322345
set st = ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(dataSource, .out)
323346

324347
}
348+
325349

326350
} catch ex {
327351
set st = ex.AsStatus()
@@ -409,12 +433,19 @@ ClassMethod GetWidgetsList(pDashName As %String) As %Status
409433
ClassMethod GetDashboard(pDashName As %String) As %Status
410434
{
411435
try {
436+
412437
set st = ##class(MDX2JSON.DashboardFilters).OpenDashboardByName(pDashName, .dash)
413438
return:($$$ISERR(st)) st
414439

415440
set st = ##class(MDX2JSON.DashboardFilters).WidgetsToProxyObject(dash, .widgetlist)
416441
return:($$$ISERR(st)) st
417442
w "" // weird hack required for 15.3
443+
444+
set %dsDashboard = pDashName
445+
446+
// check if audit global hold something and execute it
447+
try {xecute ^DeepSee.AuditCode} catch {}
448+
418449
$$$DynObjToJSON(widgetlist)
419450
} catch ex {
420451
set st = ex.AsStatus()
@@ -423,6 +454,42 @@ ClassMethod GetDashboard(pDashName As %String) As %Status
423454
return st
424455
}
425456

457+
/// the method initiate the audit for %dsDashboard
458+
ClassMethod SetAuditCode() As %Status
459+
{
460+
set ^DeepSee.AuditCode = "Do ##class(MDX2JSON.Utils).SetAuditDash()"
461+
462+
quit $$$OK
463+
}
464+
465+
/// the method initiate the audit for %dsQueryText, %dsCubeName, %dsResultSet
466+
ClassMethod SetAuditQueryCode() As %Status
467+
{
468+
set ^DeepSee.AuditQueryCode = "Do ##class(MDX2JSON.Utils).SetAuditQuery()"
469+
470+
quit $$$OK
471+
}
472+
473+
/// zw ^AuditLogDash to get the dashboard audit dashboard readings
474+
ClassMethod SetAuditDash() As %Status
475+
{
476+
set ^AuditLogDash($INCREMENT(^AuditLogDash),"%dsDashoard") = %dsDashboard
477+
478+
quit $$$OK
479+
}
480+
481+
/// zw ^AuditLogQuery to get the query audit readings
482+
/// zw ^AuditLogCube to get the cube audit readings
483+
/// zw ^AuditLogRS to get the RS audit readings
484+
ClassMethod SetAuditQuery() As %Status
485+
{
486+
set ^AuditLogQuery($INCREMENT(^AuditLogQuery),"%dsQueryText") = %dsQueryText
487+
set ^AuditLogCube($INCREMENT(^AuditLogQuery),"%dsCubeName") = %dsCubeName
488+
set ^AuditLogRS($INCREMENT(^AuditLogRS),"%dsResultSet") = %dsResultSet
489+
490+
quit $$$OK
491+
}
492+
426493
/// Get format defaults.
427494
ClassMethod GetFormat() As %Status
428495
{
@@ -672,7 +739,6 @@ ClassMethod DeleteWidget(wName As %String, sDashboard As %String) As %Status
672739
return st
673740
}
674741

675-
676742
/// the collection of necessary parameters for building widget
677743
ClassMethod UpdateWidget(widgetToUpdate As %DeepSee.Dashboard.Widget, data As %ZEN.proxyObject) As %Status
678744
{

0 commit comments

Comments
 (0)