Topics

Bug in JsonReporterHttpService ?

danielb987
 

While looking at PR #7670, I noticed that JsonReporterHttpService.doGet(Reporter reporter, ...) calls reporter.getCurrentReport() twice. Both at line 56 and line 68.

I don't know much about json or reporters, but shouldn't the line at line 68 be:

Object lr = reporter.getLastReport();

instead of

Object lr = reporter.getCurrentReport();

in jmri.server.json.reporter.JsonReporterHttpService?

Another question:
For a report, the JSON object returns both the report itself as "REPORT" and a text representation as "VALUE". But for the last report, only the last report itself is returned, as "LAST_REPORT", but the text representation of the last report is not returned. For me, it seems resonable to also return a text representation for the last report, for example as "LAST_REPORT_VALUE", in case someone wants to use it.

Daniel

Randall Wood
 

On 02-Dec-2019, at 16:13, danielb987 <db123@...> wrote:

While looking at PR #7670, I noticed that JsonReporterHttpService.doGet(Reporter reporter, ...) calls reporter.getCurrentReport() twice. Both at line 56 and line 68.

I don't know much about json or reporters, but shouldn't the line at line 68 be:

Object lr = reporter.getLastReport();

instead of

Object lr = reporter.getCurrentReport();

in jmri.server.json.reporter.JsonReporterHttpService?
Thanks for catching that.

Another question:
For a report, the JSON object returns both the report itself as "REPORT" and a text representation as "VALUE". But for the last report, only the last report itself is returned, as "LAST_REPORT", but the text representation of the last report is not returned. For me, it seems resonable to also return a text representation for the last report, for example as "LAST_REPORT_VALUE", in case someone wants to use it.
No, there are two uses of Reporters in JSON: displaying a panel where null and empty states are replaced with, respectively, “No Report” and “Blank”, and passing data around about what’s where on the layout.

The “value” property in the JSON report object exists solely for the convenience of a single JavaScript client so it can treat a number of different JSON object types identically without special code for each type; since something like you propose needs special treatment, any client that would benefit can use the “lastReport” property the same way as a “lastReportValue” property would be used.

Daniel