Skip to content

Commit a2edf6f

Browse files
committed
Support for dynamic objects with dashboards
1 parent 5b36cb2 commit a2edf6f

5 files changed

Lines changed: 59 additions & 43 deletions

File tree

MDX2JSON/AbstractREST.cls.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,24 +446,23 @@ This is the Schema which defines the form of the dispatch map</Description>
446446

447447
<Method name="POtoStr">
448448
<ClassMethod>1</ClassMethod>
449-
<FormalSpec>config</FormalSpec>
449+
<FormalSpec>obj:%ZEN.proxyObject</FormalSpec>
450450
<ProcedureBlock>0</ProcedureBlock>
451451
<ReturnType>%String</ReturnType>
452452
<Implementation><![CDATA[
453-
454453
set str=""
455-
454+
456455
//Redirect IO to the current routine - makes use of the labels defined below
457456
use $io::("^"_$ZNAME)
458457
459458
//Enable redirection
460459
do ##class(%Device).ReDirectIO(1)
461460
462-
do config.%ToJSON()
461+
set st = obj.%ToJSON()
463462
464463
//Disable redirection
465464
do ##class(%Device).ReDirectIO(0)
466-
465+
467466
quit str
468467
469468
//Labels that allow for IO redirection

MDX2JSON/Dashboard.cls.xml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ Converts %DeepSee.Dashboard.Definition widgets into %ZEN.proxyObject.</Descripti
108108
<ReturnType>%Status</ReturnType>
109109
<Implementation><![CDATA[
110110
#Dim widget As %DeepSee.Dashboard.Widget
111-
set Widgetlist = ##class(%ZEN.proxyObject).%New()
112-
set Widgetlist.children = ##class(%ListOfObjects).%New()
111+
set Widgetlist = $$$NewDynObj
112+
set Widgetlist.children = $$$NewDynObjList
113113
set Widgetlist.displayInfo = ..GetDashboardDisplayInfo(Dashboard)
114114
set Widgetlist.info = ..GetDashboardInfo(Dashboard)
115115
116116
set st = $$$OK
117117
try {
118118
for i=1:1:Dashboard.widgets.Count() {
119-
do Widgetlist.children.Insert(..WidgetToProxyObject(Dashboard.widgets.GetAt(i)))
119+
$$$Insert(Widgetlist.children,..WidgetToProxyObject(Dashboard.widgets.GetAt(i)))
120120
}
121121
} catch ex {
122122
set st = ex.AsStatus()
@@ -134,7 +134,7 @@ Converts relevant parts of %DeepSee.Dashboard.Widget object into %ZEN.proxyObjec
134134
<FormalSpec>Widget:%DeepSee.Dashboard.Widget</FormalSpec>
135135
<ReturnType>%ZEN.proxyObject</ReturnType>
136136
<Implementation><![CDATA[
137-
set obj = ##class(%ZEN.proxyObject).%New()
137+
set obj = $$$NewDynObj
138138
139139
&sql(SELECT cubeName into :cube FROM %DeepSee_Dashboard.Pivot WHERE fullName=:Widget.dataSource)
140140
set:(SQLCODE'=0) cube=""
@@ -158,23 +158,26 @@ Converts relevant parts of %DeepSee.Dashboard.Widget object into %ZEN.proxyObjec
158158
set obj.drillDownDataSource = Widget.drillDownDataSource
159159
set obj.cube = cube
160160
set obj.displayInfo = ..GetWidgetDisplayInfo(Widget)
161-
set obj.controls = ##class(%ListOfObjects).%New()
161+
set obj.controls = $$$NewDynObjList
162162
163163
for i=1:1:Widget.controls.Count()
164164
{
165165
set control = ..WidgetControlToProxyObject(Widget,i,cube)
166-
do:$IsObject(control) obj.controls.Insert(control)
166+
if $IsObject(control) {
167+
$$$Insert(obj.controls,control)
168+
}
167169
}
168170
169171
if ##class(%Dictionary.CompiledMethod).%ExistsId("MDX2JSON.Dashboard||Process"_Widget.subtype) {
170172
do $ClassMethod("MDX2JSON.Dashboard", "Process"_Widget.subtype, Widget, obj)
171173
}
172174
173175
if (Widget.properties.Count()>0) {
174-
set obj.properties = ##class(%ArrayOfDataTypes).%New()
176+
set obj.properties = $$$NewDynObj //##class(%ArrayOfDataTypes).%New()
175177
do {
176178
set property = Widget.properties.GetNext(.key)
177-
do:(key'="") obj.properties.SetAt(property,key)
179+
//do:(key'="") obj.properties.SetAt(property,key)
180+
do:(key'="") obj.properties.%DispatchSetProperty(key,property)
178181
} while key'=""
179182
}
180183
@@ -184,19 +187,32 @@ Converts relevant parts of %DeepSee.Dashboard.Widget object into %ZEN.proxyObjec
184187

185188
<Method name="ProcesscomboChart">
186189
<ClassMethod>1</ClassMethod>
187-
<FormalSpec>Widget,Obj:%ZEN.proxyObject</FormalSpec>
190+
<FormalSpec>Widget:%DeepSee.Dashboard.Widget,Obj:%ZEN.proxyObject</FormalSpec>
188191
<Implementation><![CDATA[
189-
set Obj.seriesTypes = ##class(%ListOfDataTypes).%New()
192+
193+
set Obj.seriesTypes = $$$NewDynDTList
190194
for i=1:1:Widget.dataSeries.Count()
191195
{
192-
do Obj.seriesTypes.Insert(Widget.dataSeries.GetAt(i).type)
196+
$$$Insert(Obj.seriesTypes,Widget.dataSeries.GetAt(i).type)
193197
}
194198
195-
set Obj.overrides = ##class(%ListOfObjects).%New()
199+
set Obj.overrides = $$$NewDynObjList
196200
do {
197-
set overridestr = Widget.overrides.GetNext(.key)
198-
do ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(overridestr,,.override,1)
199-
do:$IsObject(override) Obj.overrides.Insert(override)
201+
set overridestr = Widget.overrides.GetNext(.key) // we take DeepSee widget override string (in "json" format)
202+
return:key=""
203+
204+
205+
do ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(overridestr,,.override,1) // convert it into %ZEN.proxyObject
206+
207+
#if $$$IsNewJSON // if we are on new versions
208+
set overridestr = ##class(MDX2JSON.AbstractREST).POtoStr(override) // convert it into valid json
209+
set override = ##class(%Object).$fromJSON(overridestr) // and into %Object
210+
#endif
211+
212+
if $IsObject(override) {
213+
$$$Insert(Obj.overrides,override)
214+
}
215+
200216
} while key'=""
201217
]]></Implementation>
202218
</Method>
@@ -205,12 +221,12 @@ Converts relevant parts of %DeepSee.Dashboard.Widget object into %ZEN.proxyObjec
205221
<ClassMethod>1</ClassMethod>
206222
<FormalSpec>Widget:%DeepSee.Dashboard.Widget,Obj:%ZEN.proxyObject</FormalSpec>
207223
<Implementation><![CDATA[
208-
set Obj.dataProperties = ##class(%ListOfDataTypes).%New()
224+
set Obj.dataProperties = $$$NewDynDTList
209225
for i=1:1:Widget.dataProperties.Count()
210226
{
211-
set dataProperty = ##class(%ZEN.proxyObject).%New()
227+
set dataProperty = $$$NewDynObj
212228
do Widget.dataProperties.GetAt(i).%CopyTo(dataProperty)
213-
do Obj.dataProperties.Insert(dataProperty)
229+
$$$Insert(Obj.dataProperties,dataProperty)
214230
}
215231
]]></Implementation>
216232
</Method>
@@ -223,7 +239,7 @@ Converts %DeepSee.Dashboard.Control object into %ZEN.proxyObject, handles run-ti
223239
<FormalSpec>Widget:%DeepSee.Dashboard.Widget,Number:%Integer,Cube:%String</FormalSpec>
224240
<ReturnType>%ZEN.proxyObject</ReturnType>
225241
<Implementation><![CDATA[
226-
set obj = ##class(%ZEN.proxyObject).%New()
242+
set obj = $$$NewDynObj
227243
set st = Widget.controls.GetAt(Number).%CopyTo(obj) // copy widget control properties to proxyObj
228244
229245
set obj.label = ##class(%DeepSee.UserPortal.Utils).%ResolveText(obj.label)
@@ -294,16 +310,16 @@ Returns list of %ZEN.proxyObject:<br/>]]></Description>
294310
<ReturnType>%ListOfObjects</ReturnType>
295311
<Implementation><![CDATA[
296312
set st = ##class(%DeepSee.Dashboard.Utils).%GetMembersForFilter(DataSource,Filter,.tMembers,.tDefaultFilterValue,,.tRelatedFilters,0,,.tValueList)
297-
set members = ##class(%ListOfObjects).%New()
313+
set members = $$$NewDynObjList
298314
299315
set key = $order(tMembers(""))
300316
while (key '= "") {
301-
set member = ##class(%ZEN.proxyObject).%New()
317+
set member = $$$NewDynObj
302318
set member.name = $lg(tMembers(key),1)
303319
set member.path = $lg(tMembers(key),2)
304320
set member.info = $lg(tMembers(key),3)
305321
set key = $order(tMembers(key))
306-
do members.Insert(member)
322+
$$$Insert(members,member)
307323
}
308324
return members
309325
]]></Implementation>
@@ -316,7 +332,7 @@ Converts %DeepSee.Dashboard.Definition display information into %ZEN.proxyObject
316332
<FormalSpec>Dashboard:%DeepSee.Dashboard.Definition</FormalSpec>
317333
<ReturnType>%ZEN.proxyObject</ReturnType>
318334
<Implementation><![CDATA[
319-
set DisplayInfo = ##class(%ZEN.proxyObject).%New()
335+
set DisplayInfo = $$$NewDynObj
320336
set DisplayInfo.snapToGrid = Dashboard.snapTo // Dashboard is in "snap to grid" mode.
321337
set DisplayInfo.gridMode = Dashboard.snapGrid // Dashboard uses the new snapGrid layout mode.
322338
set DisplayInfo.gridRows = Dashboard.gridRows
@@ -332,7 +348,7 @@ Converts %DeepSee.Dashboard.Widget display information into %ZEN.proxyObject.</D
332348
<FormalSpec>Widget:%DeepSee.Dashboard.Widget</FormalSpec>
333349
<ReturnType>%ZEN.proxyObject</ReturnType>
334350
<Implementation><![CDATA[
335-
set DisplayInfo = ##class(%ZEN.proxyObject).%New()
351+
set DisplayInfo = $$$NewDynObj
336352
337353
set DisplayInfo.top = Widget.top
338354
set DisplayInfo.left = Widget.left
@@ -354,7 +370,7 @@ Converts %DeepSee.Dashboard.Definition display information into %ZEN.proxyObject
354370
<FormalSpec>Dashboard:%DeepSee.Dashboard.Definition</FormalSpec>
355371
<ReturnType>%ZEN.proxyObject</ReturnType>
356372
<Implementation><![CDATA[
357-
set Info = ##class(%ZEN.proxyObject).%New()
373+
set Info = $$$NewDynObj
358374
set Info.title = Dashboard.title
359375
360376
return Info

MDX2JSON/DashboardFilters.cls.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ Converts %DeepSee.Dashboard.Definition widgets into %ZEN.proxyObject.</Descripti
1414
<FormalSpec>Dashboard:%DeepSee.Dashboard.Definition,*Widgetlist:%ZEN.proxyObject</FormalSpec>
1515
<ReturnType>%Status</ReturnType>
1616
<Implementation><![CDATA[
17+
w "" // weird hack required for 15.3
1718
#Dim widget As %DeepSee.Dashboard.Widget
18-
set Widgetlist = ##class(%ZEN.proxyObject).%New()
19-
set Widgetlist.widgets = ##class(%ListOfObjects).%New()
20-
set Widgetlist.filters = ##class(%ListOfObjects).%New()
19+
set Widgetlist = $$$NewDynObj
20+
set Widgetlist.widgets = $$$NewDynObjList
21+
set Widgetlist.filters = $$$NewDynObjList
2122
set Widgetlist.displayInfo = ..GetDashboardDisplayInfo(Dashboard)
2223
set Widgetlist.info = ..GetDashboardInfo(Dashboard)
2324
2425
set st = $$$OK
2526
try {
2627
for i=1:1:Dashboard.widgets.Count() {
27-
do Widgetlist.widgets.Insert(..WidgetToProxyObject(Dashboard.widgets.GetAt(i)))
28-
28+
$$$Insert(Widgetlist.widgets,..WidgetToProxyObject(Dashboard.widgets.GetAt(i)))
2929
#dim filters As %ListOfObjects
3030
set filters = ..WidgetFiltersToProxyObject(Dashboard.widgets.GetAt(i))
31-
for j=1:1:filters.Count() {
32-
do Widgetlist.filters.Insert(filters.GetAt(j))
31+
for j=1:1:$$$ListSize(filters) {
32+
$$$Insert(Widgetlist.filters,$$$ListGet(filters,j))
3333
}
3434
}
3535
} catch ex {
@@ -51,11 +51,13 @@ Converts relevant parts of %DeepSee.Dashboard.Widget object into %ZEN.proxyObjec
5151
&sql(SELECT cubeName into :cube FROM %DeepSee_Dashboard.Pivot WHERE fullName=:Widget.dataSource)
5252
set:(SQLCODE'=0) cube=""
5353
54-
set obj = ##class(%ListOfObjects).%New()
54+
set obj = $$$NewDynObjList
5555
for i=1:1:Widget.controls.Count()
5656
{
5757
set filter = ..WidgetFilterToProxyObject(Widget,i,cube)
58-
do:$IsObject(filter) obj.Insert(filter)
58+
if $IsObject(filter){
59+
$$$Insert(obj,filter)
60+
}
5961
}
6062
return obj
6163
]]></Implementation>

MDX2JSON/MDX2JSON.inc.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
#define ListSize(%obj) %obj.Count()
3434
#define ListGet(%obj,%i) %obj.Get(%i)
3535
#endif
36-
36+
#define IsNewJSON ##Expression($$$comClassDefined("%Library.Array"))
3737
]]></Routine>
3838
</Export>

MDX2JSON/Utils.cls.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Using dashboard name get JSON representation (array of ("type","title","mdx")) o
221221
set st = ##class(MDX2JSON.Dashboard).WidgetsToProxyObject(dash, .widgetlist)
222222
return:($$$ISERR(st)) st
223223
224-
do widgetlist.%ToJSON()
224+
$$$DynObjToJSON(widgetlist)
225225
} catch ex {
226226
set st = ex.AsStatus()
227227
do ex.Log()
@@ -244,8 +244,7 @@ Using dashboard name get JSON representation of all its' widgets and filters.<br
244244
245245
set st = ##class(MDX2JSON.DashboardFilters).WidgetsToProxyObject(dash, .widgetlist)
246246
return:($$$ISERR(st)) st
247-
248-
do widgetlist.%ToJSON()
247+
$$$DynObjToJSON(widgetlist)
249248
} catch ex {
250249
set st = ex.AsStatus()
251250
do ex.Log()

0 commit comments

Comments
 (0)