Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }

        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.save);
        resultMessage.setBody(ret);
        resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here


  private DBObject getObjectAsEmbeddedAssociation(AssociationKey key) {
    DBCollection collection = this.getCollection( key.getEntityKey() );
    DBObject searchObject = this.prepareIdObject( key.getEntityKey() );
    DBObject restrictionObject = this.getSearchObject( key, true );
    return collection.findOne( searchObject, restrictionObject );
  }

  private DBObject getObject(EntityKey key, TupleContext tupleContext) {
    DBCollection collection = this.getCollection( key );
    DBObject searchObject = this.prepareIdObject( key );
View Full Code Here

  private DBObject getObject(EntityKey key, TupleContext tupleContext) {
    DBCollection collection = this.getCollection( key );
    DBObject searchObject = this.prepareIdObject( key );
    BasicDBObject restrictionObject = this.getSearchObject( tupleContext );
    return collection.findOne( searchObject, restrictionObject );
  }

  private BasicDBObject getSearchObject(TupleContext tupleContext) {
    return this.getSearchObject( tupleContext.getSelectableColumns() );
  }
View Full Code Here

    @CheckForNull
    <T extends Document> T findUncached(Collection<T> collection, String key) {
        DBCollection dbCollection = getDBCollection(collection);
        long start = start();
        try {
            DBObject obj = dbCollection.findOne(getByKeyQuery(key).get());
            if (obj == null) {
                return null;
            }
            T doc = convertFromDBObject(collection, obj);
            if (doc != null) {
View Full Code Here

  @Override
  public SignerInfo getSignerInfo(byte[] signerId) {
    DBObject query = getDBObjectForSignerId(signerId);
    DBCollection signerInfoCollection = getSignerInfoCollection();
    DBObject signerInfoDBObject = signerInfoCollection.findOne(query);

    // Sub-class contract specifies return null when not found
    SignerInfo signerInfo = null;

    if (signerInfoDBObject != null) {
View Full Code Here

    }

    @Override
    public void delete(final ObjectSpecId objectSpecId, final String mongoId, final String version, final Oid oid) {
        final DBCollection instances = db.getCollection(objectSpecId.asString());
        final DBObject object = instances.findOne(mongoId);
        if (!object.get(PropertyNames.VERSION).equals(version)) {
            throw new ConcurrencyException("Could not delete object of different version", oid);
        }
        instances.remove(object);
        LOG.info("removed " + oid);
View Full Code Here

    private static final Logger LOG = LoggerFactory.getLogger(MongoStateReader.class);
    private final DBObject instance;

    public MongoStateReader(final DB db, final ObjectSpecId objectSpecId, final String mongoId) {
        final DBCollection instances = db.getCollection(objectSpecId.asString());
        instance = instances.findOne(mongoId);
        if (instance == null) {
            throw new ObjectNotFoundException(mongoId);
        }
        if(LOG.isDebugEnabled()) {
            LOG.debug("loading " + instance);
View Full Code Here

        return next + 1;
    }

    private void writeSerialNumber(final long serialNumber) {
        final DBCollection system = db.getCollection(SERIALNUMBERS_COLLECTION_NAME);
        DBObject object = system.findOne();
        if (object == null) {
            object = new BasicDBObject();
        }
        object.put("next-id", Long.toString(serialNumber));
        system.save(object);
View Full Code Here

        LOG.info("serial number written: " + serialNumber);
    }

    private long readSerialNumber() {
        final DBCollection system = db.getCollection(SERIALNUMBERS_COLLECTION_NAME);
        final DBObject data = system.findOne();
        if (data == null) {
            return 0;
        } else {
            final String number = (String) data.get("next-id");
            LOG.info("serial number read: " + number);
View Full Code Here

    }

    @Override
    public String getService(final ObjectSpecId objectSpecId) {
        final DBCollection services = db.getCollection("services");
        final DBObject object = services.findOne(new BasicDBObject().append("name", objectSpecId.asString()));
        if (object == null) {
            return null;
        } else {
            final String id = (String) object.get("key");
            LOG.info("service found " + objectSpecId + ":" + id);
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.