Skip to content

Commit

Permalink
Merge pull request #126 from Frisle/master
Browse files Browse the repository at this point in the history
FEAT: added globals check in corresponding methods
  • Loading branch information
eduard93 authored Jul 12, 2024
2 parents 3564bd0 + 87840c0 commit c377292
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions MDX2JSON/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ ClassMethod ExecuteResultSet(RS As MDX2JSON.ResultSet, QueryKey As %String = "",
quit Status
}

ClassMethod QuerySet(MDX) As %Status
{
set ^Query($I(^Query), "%dsQuery") = MDX
}

/// Automatic processing of MDX query and outputting resulting JSON.<br>
/// <b>MDX</b> - String containing MDX query.<br>
ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
Expand All @@ -76,6 +81,17 @@ ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status

set obj = RS.ToProxyObject(.tSC)
return:$$$ISERR(tSC) tSC

set %dsQuery = MDX

// initiate an RS object to a global variable %dsResultSet
set %dsResultSet = RS

set %dsCubeName = RS.%Cube

// check if audit global hold something and execute it
try {xecute ^DeepSee.AuditQueryCode} catch {}

$$$DynObjToJSON(obj)

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

set obj = RS.ToProxyObject(.tSC)
return:$$$ISERR(tSC) tSC

set %dsQuery = MDX
set %dsResultSet = RS

// check if audit global hold something and execute it
try {xecute ^DeepSee.AuditQueryCode} catch {}

$$$DynObjToJSON(obj)
}


return $$$OK
}

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


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


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

set st = $$$OK
try {

if ($FIND(pDataSource, ".pivot") = ($LENGTH(pDataSource) + 1) && pDataSource '="") {
set st = ..OpenPivotByName(pDataSource, .dataSource)
return:($$$ISERR(st)) st
Expand All @@ -322,6 +345,7 @@ ClassMethod GetDataSource(pDataSource As %String)
set st = ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(dataSource, .out)

}


} catch ex {
set st = ex.AsStatus()
Expand Down Expand Up @@ -409,12 +433,19 @@ ClassMethod GetWidgetsList(pDashName As %String) As %Status
ClassMethod GetDashboard(pDashName As %String) As %Status
{
try {

set st = ##class(MDX2JSON.DashboardFilters).OpenDashboardByName(pDashName, .dash)
return:($$$ISERR(st)) st

set st = ##class(MDX2JSON.DashboardFilters).WidgetsToProxyObject(dash, .widgetlist)
return:($$$ISERR(st)) st
w "" // weird hack required for 15.3

set %dsDashboard = pDashName

// check if audit global hold something and execute it
try {xecute ^DeepSee.AuditCode} catch {}

$$$DynObjToJSON(widgetlist)
} catch ex {
set st = ex.AsStatus()
Expand All @@ -423,6 +454,42 @@ ClassMethod GetDashboard(pDashName As %String) As %Status
return st
}

/// the method initiate the audit for %dsDashboard
ClassMethod SetAuditCode() As %Status
{
set ^DeepSee.AuditCode = "Do ##class(MDX2JSON.Utils).SetAuditDash()"

quit $$$OK
}

/// the method initiate the audit for %dsQueryText, %dsCubeName, %dsResultSet
ClassMethod SetAuditQueryCode() As %Status
{
set ^DeepSee.AuditQueryCode = "Do ##class(MDX2JSON.Utils).SetAuditQuery()"

quit $$$OK
}

/// zw ^AuditLogDash to get the dashboard audit dashboard readings
ClassMethod SetAuditDash() As %Status
{
set ^AuditLogDash($INCREMENT(^AuditLogDash),"%dsDashoard") = %dsDashboard

quit $$$OK
}

/// zw ^AuditLogQuery to get the query audit readings
/// zw ^AuditLogCube to get the cube audit readings
/// zw ^AuditLogRS to get the RS audit readings
ClassMethod SetAuditQuery() As %Status
{
set ^AuditLogQuery($INCREMENT(^AuditLogQuery),"%dsQueryText") = %dsQueryText
set ^AuditLogCube($INCREMENT(^AuditLogQuery),"%dsCubeName") = %dsCubeName
set ^AuditLogRS($INCREMENT(^AuditLogRS),"%dsResultSet") = %dsResultSet

quit $$$OK
}

/// Get format defaults.
ClassMethod GetFormat() As %Status
{
Expand Down Expand Up @@ -672,7 +739,6 @@ ClassMethod DeleteWidget(wName As %String, sDashboard As %String) As %Status
return st
}


/// the collection of necessary parameters for building widget
ClassMethod UpdateWidget(widgetToUpdate As %DeepSee.Dashboard.Widget, data As %ZEN.proxyObject) As %Status
{
Expand Down

0 comments on commit c377292

Please sign in to comment.