Package org.ektorp

Examples of org.ektorp.ViewResult


    public Channel getChannel(final String channelId) throws ChannelNotFoundException {
        return channelFromJson(getChannelJson(channelId));
    }

    private JsonNode getChannelJson(final String channelId) throws ChannelNotFoundException {
        final ViewResult viewResult = db.queryView(query(Views.CHANNEL.viewName(), channelId));
        final List<Row> rows = viewResult.getRows();
        if (rows.isEmpty()) {
            throw new ChannelNotFoundException("Cound not find channel", channelId);
        }
        if (rows.size() > 1) {
            throw new IllegalStateException("There should not be multiple channelId with the same id");
View Full Code Here


                doc.get(TOKEN_FIELD).asText());
    }

    @Override
    public void removeChannels(final String uaid) {
        final ViewResult viewResult = db.queryView(query(Views.UAID.viewName(), uaid));
        final List<Row> rows = viewResult.getRows();
        final Set<String> channelIds = new HashSet<String>(rows.size());
        for (Row row : rows) {
            final JsonNode json = row.getValueAsNode().get(DOC_FIELD);
            channelIds.add(json.get(CHID_FIELD).asText());
        }
View Full Code Here

                    .key(key);
    }

    @Override
    public void removeChannels(final Set<String> channelIds) {
        final ViewResult viewResult = db.queryView(channelsQuery(channelIds));
        final List<Row> rows = viewResult.getRows();
        final Collection<BulkDeleteDocument> removals = new LinkedHashSet<BulkDeleteDocument>();
        for (Row row : rows) {
            final JsonNode json = row.getValueAsNode();
            removals.add(BulkDeleteDocument.of(json.get(DOC_FIELD)));
        }
View Full Code Here

                    .keys(keys);
    }

    @Override
    public Set<String> getChannelIds(final String uaid) {
        final ViewResult viewResult = db.queryView(query(Views.UAID.viewName(), uaid));
        final List<Row> rows = viewResult.getRows();
        if (rows.isEmpty()) {
            return Collections.emptySet();
        }
        final Set<String> channelIds = new HashSet<String> (rows.size());
        for (Row row : rows) {
View Full Code Here

        return channelIds;
    }

    @Override
    public String updateVersion(final String endpointToken, final long version) throws VersionException, ChannelNotFoundException {
        final ViewResult viewResult = db.queryView(query(Views.TOKEN.viewName(), endpointToken));
        final List<Row> rows = viewResult.getRows();
        if (rows.isEmpty()) {
            throw new ChannelNotFoundException("Cound not find channel for endpointToken", endpointToken);
        }
        final ObjectNode node = (ObjectNode) rows.get(0).getValueAsNode().get(DOC_FIELD);
        final long currentVersion = node.get(VERSION_FIELD).asLong();
View Full Code Here

        return map;
    }

    @Override
    public Set<Ack> getUnacknowledged(final String uaid) {
        final ViewResult viewResult = db.queryView(query(Views.UNACKS.viewName(), uaid));
        return rowsToAcks(viewResult.getRows());
    }
View Full Code Here

        return rowsToAcks(viewResult.getRows());
    }

    @Override
    public Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acked) {
        final ViewResult viewResult = db.queryView(query(Views.UNACKS.viewName(), uaid));
        final List<Row> rows = viewResult.getRows();
        final Collection<BulkDeleteDocument> removals = new LinkedHashSet<BulkDeleteDocument>();
        for (Iterator<Row> iter = rows.iterator(); iter.hasNext(); ) {
            final Row row = iter.next();
            final JsonNode json = row.getValueAsNode();
            final JsonNode doc = json.get(DOC_FIELD);
View Full Code Here

TOP

Related Classes of org.ektorp.ViewResult

Copyright © 2018 www.massapicom. 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.