Skip to content

Commit

Permalink
Merge pull request #117 from Frisle/patch-12
Browse files Browse the repository at this point in the history
FIX: Add support for compound calculation
  • Loading branch information
eduard93 authored Sep 25, 2023
2 parents a3d0e4c + 16c2efa commit c447d36
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions MDX2JSON/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,36 @@ ClassMethod ExecuteResultSet(RS As MDX2JSON.ResultSet, QueryKey As %String = "",
/// <b>MDX</b> - String containing MDX query.<br>
ClassMethod WriteJSONfromMDX(MDX As %String, Timeout As %Integer = 0) As %Status
{
Set tSC = $$$OK
#dim RS As MDX2JSON.ResultSet
set RS = ..GetResultSet(MDX, .st)
return:$$$ISERR(st) st

set RS = ..GetResultSet(MDX, .tSC)
set cube = ##class(%DeepSee.Utils).%IsCubeCompound(RS.%Cube) // check if cube is compound type
return:$$$ISERR(tSC) tSC

if cube // if cube is compound then we prepare it using %ZEN.Auxiliary.jsonMDXProvider
{
Set tProvider = ##class(%ZEN.Auxiliary.jsonMDXProvider).%New()
Set tProvider.mdxQuery = MDX
Set tWait = %session.AppTimeout - $S(%session.AppTimeout>2:2,1:0) // Send something back jst before the appTimeout is reached
Set tSC = ##class(%DeepSee.REST.v1.DataServer).%WaitForProviderResults(tProvider,tWait)

set st = ..ExecuteResultSet(RS, , Timeout)
return:$$$ISERR(st) st
set tSC = ..ExecuteResultSet(RS, ,Timeout)
return:$$$ISERR(tSC) tSC

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

}else{ // if cube is not compound execute the query in usual way

set tSC = ..ExecuteResultSet(RS, ,Timeout)
return:$$$ISERR(tSC) tSC

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

Expand Down

0 comments on commit c447d36

Please sign in to comment.