Examples of HRow


Examples of org.haystack.HRow

    protected void onHisRead(HDict entity, HDateTimeRange range, HGridWriter writer, HCol[] cols) {
        HDateTime ts = range.start;
        boolean isBool = ((HStr) entity.get("kind")).val.equals("Bool");
        int count = 0;
        HVal[] values = new HVal[2];
        HRow row = new HRow(null, values);
        while (ts.compareTo(range.end) <= 0) {
            HVal val = isBool ? (HVal) HBool.make(count % 2 == 0) : (HVal) HNum.make(count);
            if (ts != range.start) {
                values[0] = val;
                values[1] = ts;
View Full Code Here

Examples of org.haystack.HRow

        // ensure we have one row
        if (req.isEmpty())
            throw new Exception("Request has no rows");

        // perform filter or id read
        HRow row = req.row(0);
        if (row.has("filter")) {
            // filter read
            String filter = row.getStr("filter");
            int limit = row.has("limit") ? row.getInt("limit") : Integer.MAX_VALUE;
            writeGrid(writer, db.readAll(filter, limit));
        }
        else if (row.has("id")) {
            // read by ids
            HRef[] ids = gridToIds(db, req);
            writeGrid(writer, db.readByIds(ids, false));
        }
        else {
View Full Code Here

Examples of org.haystack.HRow

    @Override
    public void onService(HServer db, HGrid req, HGridWriter writer) throws Exception {
        // get required point id
        if (req.isEmpty())
            throw new Exception("Request has no rows");
        HRow row = req.row(0);
        HRef id = valToId(db, row.get("id"));

        // check for write
        if (row.has("level")) {
            int level = row.getInt("level");
            String who = row.getStr("who"); // be nice to have user fallback
            HVal val = row.get("val", false);
            HNum dur = (HNum) row.get("duration", false);
            db.pointWrite(id, level, val, who, dur);
        }

        writeGrid(writer, db.pointWriteArray(id));
    }
View Full Code Here

Examples of org.haystack.HRow

    @Override
    public void onService(HServer db, HGrid req, HGridWriter writer) throws Exception {
        if (req.isEmpty())
            throw new Exception("Request has no rows");
        HRow row = req.row(0);
        HRef id = valToId(db, row.get("id"));

        String range = row.getStr("range");
        db.hisRead(id, range, writer);
    }
View Full Code Here

Examples of org.haystack.HRow

        // rows
        verifyEq(grid.numRows(), rows.length);
        for (int ri = 0; ri < rows.length; ++ri) {
            HVal[] expected = rows[ri];
            HRow actual = grid.row(ri);
            for (int ci = 0; ci < expected.length; ++ci) {
                verifyEq(expected[ci], actual.get(grid.col(ci).name(), false));
            }
        }
    }
View Full Code Here

Examples of org.haystack.HRow

        verifyCol(g, 2, "area");

        // rows
        verifyEq(g.numRows(), 2);
        verifyEq(g.isEmpty(), false);
        HRow r;
        r = g.row(0);
        verifyEq(r.get("id"), HRef.make("a"));
        verifyEq(r.get("dis"), HStr.make("Alpha"));
        verifyEq(r.get("area"), HNum.make(1200));
        r = g.row(1);
        verifyEq(r.get("id"), HRef.make("b"));
        verifyEq(r.get("dis"), HStr.make("Beta"));
        verifyEq(r.get("area", false), null);
        try {
            r.get("area");
            fail();
        }
        catch (UnknownNameException e) {
            verifyException(e);
        }
        verifyEq(r.get("fooBar", false), null);
        try {
            r.get("fooBar");
            fail();
        }
        catch (UnknownNameException e) {
            verifyException(e);
        }
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.