@@ -57,17 +57,36 @@ ClassMethod ExecuteResultSet(RS As MDX2JSON.ResultSet, QueryKey As %String = "",
5757/// <b>MDX</b> - String containing MDX query.<br>
5858ClassMethod WriteJSONfromMDX (MDX As %String , Timeout As %Integer = 0 ) As %Status
5959{
60+ Set tSC = $$$OK
6061 #dim RS As MDX2JSON.ResultSet
61- set RS = ..GetResultSet (MDX , .st )
62- return :$$$ISERR(st ) st
62+
63+ set RS = ..GetResultSet (MDX , .tSC )
64+ set cube = ##class (%DeepSee.Utils ).%IsCubeCompound (RS .%Cube ) // check if cube is compound type
65+ return :$$$ISERR(tSC ) tSC
66+
67+ if cube // if cube is compound then we prepare it using %ZEN.Auxiliary.jsonMDXProvider
68+ {
69+ Set tProvider = ##class (%ZEN.Auxiliary.jsonMDXProvider ).%New ()
70+ Set tProvider .mdxQuery = MDX
71+ Set tWait = %session .AppTimeout - $S (%session .AppTimeout >2 :2 ,1 :0 ) // Send something back jst before the appTimeout is reached
72+ Set tSC = ##class (%DeepSee.REST.v1.DataServer ).%WaitForProviderResults (tProvider ,tWait )
6373
64- set st = ..ExecuteResultSet (RS , , Timeout )
65- return :$$$ISERR(st ) st
74+ set tSC = ..ExecuteResultSet (RS , ,Timeout )
75+ return :$$$ISERR(tSC ) tSC
6676
67- set obj = RS .ToProxyObject (.st )
68- return :$$$ISERR(st ) st
69- $$$DynObjToJSON(obj )
77+ set obj = RS .ToProxyObject (.tSC )
78+ return :$$$ISERR(tSC ) tSC
79+ $$$DynObjToJSON(obj )
7080
81+ }else { // if cube is not compound execute the query in usual way
82+
83+ set tSC = ..ExecuteResultSet (RS , ,Timeout )
84+ return :$$$ISERR(tSC ) tSC
85+
86+ set obj = RS .ToProxyObject (.tSC )
87+ return :$$$ISERR(tSC ) tSC
88+ $$$DynObjToJSON(obj )
89+ }
7190 return $$$OK
7291}
7392
0 commit comments