Skip to content

Commit f95fcb3

Browse files
committed
Answer to the Ultimate Question of Life, the Universe, and Everything
Fixes #42 Adds format info, /Format webapp path, related docs
1 parent 159b57f commit f95fcb3

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

MDX2JSON/REST.cls.xml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ To get information about possible Cube's filters and filters' values:<br><ul>
2424
<li>webapplication/FilterValues/:cube - to get all filters for DeepSee Cube in JSON format.</li>
2525
<li>webapplication/FilterValues/:cube - Same but with POST { "Cube":"CubeName","Values":0} body. If values = 1, then filters' values would also be provided.</li>
2626
<li>webapplication/FilterValues/:cube/:filter - to get all values for Filter for DeepSee Cube in JSON format.</li></ul>
27-
Example: send HTTP GET request to web application with Dispatch class <b>MDX2JSON.REST</b> and URL:<br>
28-
/FilterValues/HoleFoods/[DateOfSale].[Actual].[MonthSold] - to get information about possible values of [DateOfSale].[Actual].[MonthSold] in HoleFoods Cube.<br>
29-
27+
3028
To get information about pivot:<br><ul>
3129
<li>webapplication/DataSource- to get info about pivot (POST {DataSource:"Name of DS"})</li> </ul>
30+
31+
To get information about system-wide defaults (format):<br><ul>
32+
<li>webapplication/Format - to get info about system-wide defaults (format). GET request </li> </ul>
33+
3234
You can add a param Namespace to request to execute MDX in desired namespace (MDX2JSON package must be mapped to that namespace):<br>
33-
webapplication/MDX?Namespace=Samples<br>]]></Description>
35+
webapplication/MDX?Namespace=Samples<br>
36+
37+
Example: send HTTP GET request to web application with Dispatch class <b>MDX2JSON.REST</b> and URL:<br>
38+
/FilterValues/HoleFoods/[DateOfSale].[Actual].[MonthSold] - to get information about possible values of [DateOfSale].[Actual].[MonthSold] in HoleFoods Cube.<br>
39+
]]></Description>
3440
<IncludeCode>MDX2JSON.MDX2JSON</IncludeCode>
3541
<Super>MDX2JSON.AbstractREST</Super>
3642
<TimeCreated>63165,65257.8179</TimeCreated>
@@ -52,6 +58,9 @@ webapplication/MDX?Namespace=Samples<br>]]></Description>
5258
<!-- Get info about widgets-->
5359
<Route Url="/Dashboards" Method="GET" Call="GetDashboardList"/>
5460
<Route Url="/Widgets" Method="POST" Call="GetWidgetsList" Body="Dashboard"/>
61+
62+
<!-- Get info about system format and locale-->
63+
<Route Url="/Format" Method="GET" Call="GetFormat"/>
5564
5665
<!-- Get info about pivot-->
5766
<Route Url="/DataSource" Method="POST" Call="GetDataSource" Body="DataSource"/>
@@ -255,5 +264,14 @@ Converts incoming request object and calls abovementioned method.]]></Descriptio
255264
<Implementation><![CDATA[ return ##class(MDX2JSON.Utils).WriteXMLAfromMDX(%request.Content.MDX)
256265
]]></Implementation>
257266
</Method>
267+
268+
<Method name="GetFormat">
269+
<Description>
270+
Wrapper for ##class(MDX2JSON.Utils).GetFormat()</Description>
271+
<ClassMethod>1</ClassMethod>
272+
<ReturnType>%Status</ReturnType>
273+
<Implementation><![CDATA[ return ##class(MDX2JSON.Utils).GetFormat()
274+
]]></Implementation>
275+
</Method>
258276
</Class>
259277
</Export>

MDX2JSON/Utils.cls.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,35 @@ Using dashboard name get JSON representation (array of ("type","title","mdx")) o
219219
return st
220220
]]></Implementation>
221221
</Method>
222+
223+
<Method name="GetFormat">
224+
<Description>
225+
Get format defaults.</Description>
226+
<ClassMethod>1</ClassMethod>
227+
<ReturnType>%Status</ReturnType>
228+
<Implementation><![CDATA[
229+
set st = $$$OK
230+
set datelist="DD Mmm [YY]YY^MM/DD/[YY]^DD Mmm [YY]YY^YYYY-MM-DD^DD/MM/[YY]YY^Mmm D, YYYY^Mmm D YYYY^Mmm DD [YY]YY^YYYYMMDD^Mmmmmm D, YYYY^W^Www^Wwwwww^[D]D/[M]M/YYYY^nnn"
231+
set timelist="hh:mm:ss,hh:mm,hh:mm:ss[AM/PM],hh:mm[AM/PM]" // lists taken from %CSP.UI.Portal.NLSEdit - DrawProperties
232+
set proplist = "AM,DateSeparator,DecimalSeparator,MinusSign,MonthAbbr,MonthName,NumericGroupSeparator,NumericGroupSize,PM,PlusSign,TimePrecision,TimeSeparator,WeekdayAbbr,WeekdayName"
233+
set obj = ##class(%ZEN.proxyObject).%New()
234+
235+
try {
236+
for i = 1:1:$L(proplist, ",") {
237+
set property = $P(proplist, ",", i)
238+
do obj.%DispatchSetProperty(property,##class(%SYS.NLS.Format).GetFormatItem(property))
239+
}
240+
241+
// that's why we cant just do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON()
242+
set obj.DateFormat = $P(datelist, "^",##class(%SYS.NLS.Format).GetFormatItem("DateFormat"))
243+
set obj.TimeFormat = $P(timelist, ",",##class(%SYS.NLS.Format).GetFormatItem("TimeFormat"))
244+
245+
do obj.%ToJSON()
246+
} catch ex {
247+
set st = ex.AsStatus()
248+
}
249+
return st
250+
]]></Implementation>
251+
</Method>
222252
</Class>
223253
</Export>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ These are the possible requests to web application (add param ?Namespace={Desire
3939
| FilterValues/:cube | GET | | JSON | All filters for DeepSee Cube |
4040
| FilterValues | POST |{ "Cube":"Cube Name","Values":1}| JSON | All filters for DeepSee Cube with values (if Values = 1, set to 0 or omit otherwise)|
4141
| FilterValues/:cube/:filter | GET | | JSON | All possible values for filter |
42+
| Format | GET | | JSON | Default formatting |
4243
| Test | GET | | JSON | Test info |
4344

4445
Example

0 commit comments

Comments
 (0)