* the history record. Otherwise if a String is passed, it is resolved
* relative to the history record's timezone.
*/
public final void hisRead(HRef id, Object range, HGridWriter writer) {
// lookup entity
HDict rec = readById(id);
// check that entity has "his" tag
if (rec.missing("his"))
throw new UnknownNameException("Rec missing 'his' tag: " + rec.dis());
// lookup "tz" on entity
HTimeZone tz = null;
if (rec.has("tz"))
tz = HTimeZone.make(rec.getStr("tz"), false);
if (tz == null)
throw new UnknownNameException("Rec missing or invalid 'tz' tag: " + rec.dis());
// check or parse date range
HDateTimeRange r = null;
if (range instanceof HDateTimeRange) {
r = (HDateTimeRange) range;
}
else {
try {
r = HDateTimeRange.make(range.toString(), tz);
}
catch (ParseException e) {
throw new ParseException("Invalid date time range: " + range);
}
}
// checking
if (!r.start.tz.equals(tz))
throw new RuntimeException("range.tz != rec: " + r.start.tz + " != " + tz);
// build and return result grid
HDict meta = new HDictBuilder().add("id", id).add("hisStart", r.start).add("hisEnd", r.end).toDict();
writer.writeMeta(meta);
HDictBuilder dictBuilder = new HDictBuilder();
HCol[] cols = { new HCol(0, "ts", dictBuilder.toDict()), new HCol(1, "val", dictBuilder.toDict()), };
writer.writeCols(cols);