Example usage for com.mongodb.bulk BulkWriteResult isModifiedCountAvailable

List of usage examples for com.mongodb.bulk BulkWriteResult isModifiedCountAvailable

Introduction

In this page you can find the example usage for com.mongodb.bulk BulkWriteResult isModifiedCountAvailable.

Prototype

@Deprecated
public abstract boolean isModifiedCountAvailable();

Source Link

Document

Returns true if the server was able to provide a count of modified documents.

Usage

From source file:org.restheart.handlers.bulk.BulkResultRepresentationFactory.java

License:Open Source License

private void addBulkResult(final BulkOperationResult result, final RequestContext context,
        final Representation rep, final String requestPath) {
    Representation nrep = new Representation();

    BulkWriteResult wr = result.getBulkResult();

    if (wr.wasAcknowledged()) {
        if (wr.getUpserts() != null) {
            nrep.addProperty("inserted", new BsonInt32(wr.getUpserts().size()));

            // add links to new, upserted documents
            wr.getUpserts().stream().forEach(update -> {
                nrep.addLink(/* w w  w  .  j  a  v a 2  s.c  o  m*/
                        new Link("rh:newdoc", URLUtils.getReferenceLink(context, requestPath, update.getId())),
                        true);
            });
        }

        nrep.addProperty("deleted", new BsonInt32(wr.getDeletedCount()));

        if (wr.isModifiedCountAvailable()) {
            nrep.addProperty("modified", new BsonInt32(wr.getModifiedCount()));
        }

        nrep.addProperty("matched", new BsonInt32(wr.getMatchedCount()));

        rep.addRepresentation("rh:result", nrep);
    }
}

From source file:org.restheart.handlers.bulk.BulkResultRepresentationFactory.java

License:Open Source License

private void addWriteResult(final BulkWriteResult wr, final Representation rep, final String requestPath) {
    Representation nrep = new Representation();

    if (wr.wasAcknowledged()) {
        if (wr.getUpserts() != null) {
            nrep.addProperty("inserted", new BsonInt32(wr.getUpserts().size()));

            // add links to new, upserted documents
            wr.getUpserts().stream().forEach(update -> {
                nrep.addLink(new Link("rh:newdoc", URLUtils.getReferenceLink(requestPath, update.getId())),
                        true);/*from  w ww  .  j ava2  s. com*/
            });
        }

        nrep.addProperty("deleted", new BsonInt32(wr.getDeletedCount()));

        if (wr.isModifiedCountAvailable()) {
            nrep.addProperty("modified", new BsonInt32(wr.getModifiedCount()));
        }

        nrep.addProperty("matched", new BsonInt32(wr.getMatchedCount()));

        rep.addRepresentation("rh:result", nrep);
    }
}