Examples of HDict


Examples of org.haystack.HDict

     * 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);
View Full Code Here

Examples of org.haystack.HDict

     * inserted then they must be gracefully merged.
     */
    @Override
    public final void hisWrite(HRef id, HHisItem[] items) {
        // lookup entity
        HDict rec = readById(id);

        // check that entity has "his" tag
        if (rec.missing("his"))
            throw new UnknownNameException("Entity 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 tz of items
        if (items.length == 0)
            return;
        for (int i = 0; i < items.length; ++i)
View Full Code Here

Examples of org.haystack.HDict

    /**
     * Invoke an action identified by id and action.
     */
    public final HGrid invokeAction(HRef id, String action, HDict args) {
        // lookup entity
        HDict rec = readById(id);

        // route to subclass
        return onInvokeAction(rec, action, args);
    }
View Full Code Here

Examples of org.haystack.HDict

    @Override
    protected HDict onReadById(HRef id) {
        HGrid res = readByIds(new HRef[] { id }, false);
        if (res.isEmpty())
            return null;
        HDict rec = res.row(0);
        if (rec.missing("id"))
            return null;
        return rec;
    }
View Full Code Here

Examples of org.haystack.HDict

     * point's configured "tz" tag. If duplicate or out-of-order items are
     * inserted then they must be gracefully merged.
     */
    @Override
    public void hisWrite(HRef id, HHisItem[] items) {
        HDict meta = new HDictBuilder().add("id", id).toDict();
        HGrid req = HGridBuilder.hisItemsToGrid(meta, items);
        call("hisWrite", req);
    }
View Full Code Here

Examples of org.haystack.HDict

    /**
     * Invoke a remote action using the "invokeAction" REST operation.
     */
    public HGrid invokeAction(HRef id, String action, HDict args) {
        HDict meta = new HDictBuilder().add("id", id).add("action", action).toDict();
        HGrid req = HGridBuilder.dictsToGrid(meta, new HDict[] { args });
        return call("invokeAction", req);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.