List of usage examples for com.mongodb DBCollection remove
public WriteResult remove(final DBObject query)
From source file:no.pritest.restapi.MongoMeasureDAO.java
License:Open Source License
@Override public void delete(String name) throws MongoException, UnknownHostException { DB db = MongoDBProvider.getInstance().getDB(); DBCollection coll = db.getCollection("measure"); BasicDBObject removalQuery = new BasicDBObject(); removalQuery.put("name", name); coll.remove(removalQuery); }
From source file:no.pritest.restapi.MongoTestDataDAO.java
License:Open Source License
@Override public void delete(String className) throws MongoException, UnknownHostException { DB db = MongoDBProvider.getInstance().getDB(); DBCollection coll = db.getCollection("testdata"); BasicDBObject removalQuery = new BasicDBObject(); removalQuery.put("source", className); coll.remove(removalQuery); }
From source file:org.alfresco.extension.wcmdeployment.mongodb.MongoDbDeploymentTarget.java
License:Open Source License
/** * @see org.alfresco.deployment.DeploymentTarget#delete(java.lang.String, java.lang.String) *//* w w w.j a v a 2 s .c om*/ public void delete(final String ticket, final String path) throws DeploymentException { log.trace("MongoDbDeploymentTarget.delete(" + ticket + ", " + path + ")"); DBCollection collection = getCollection(ticket); DBObject document = findByPath(collection, path); if (document != null) { collection.remove(document); } }
From source file:org.apache.camel.component.mongodb.MongoDbProducer.java
License:Apache License
protected void doRemove(Exchange exchange) throws Exception { DBCollection dbCol = calculateCollection(exchange); DBObject removeObj = exchange.getIn().getMandatoryBody(DBObject.class); WriteConcern wc = extractWriteConcern(exchange); WriteResult result = wc == null ? dbCol.remove(removeObj) : dbCol.remove(removeObj, wc); Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.remove); // we always return the WriteResult, because whether the getLastError was called or not, // the user will have the means to call it or obtain the cached CommandResult processAndTransferWriteResult(result, exchange); resultMessage.setHeader(MongoDbConstants.RECORDS_AFFECTED, result.getN()); }
From source file:org.apache.felix.useradmin.mongodb.MongoDBStore.java
License:Apache License
@Override public Role removeRole(String roleName) throws MongoException { DBCollection coll = getCollection(); Role role = getRole(roleName); if (role == null) { return null; }/*from w w w. j ava 2 s . co m*/ WriteResult result = coll.remove(getTemplateObject(role)); if (result.getLastError() != null) { result.getLastError().throwOnError(); } return role; }
From source file:org.apache.isis.objectstore.nosql.db.mongo.MongoClientCommandContext.java
License:Apache License
@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); }/*from w ww. j av a 2 s . c o m*/ instances.remove(object); LOG.info("removed " + oid); }
From source file:org.apache.isis.runtimes.dflt.objectstores.nosql.db.mongo.MongoDb.java
License:Apache License
public void delete(final ObjectSpecId objectSpecId, final String key) { final DBCollection instances = db.getCollection(objectSpecId.asString()); final ObjectId id = new ObjectId(key); final DBObject object = instances.findOne(id); instances.remove(object); LOG.info("removed " + key); }
From source file:org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore.java
License:Apache License
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { DBCollection collection = getBlobCollection(); QueryBuilder queryBuilder = new QueryBuilder(); if (chunkIds != null) { queryBuilder = queryBuilder.and(MongoBlob.KEY_ID).in(chunkIds.toArray(new String[0])); if (maxLastModifiedTime > 0) { queryBuilder = queryBuilder.and(MongoBlob.KEY_LAST_MOD).lessThan(maxLastModifiedTime); }/*from w w w .j a va2s. c o m*/ } WriteResult result = collection.remove(queryBuilder.get()); return result.getN(); }
From source file:org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore.java
License:Apache License
@Override public <T extends Document> void remove(Collection<T> collection, String key) { log("remove", key); DBCollection dbCollection = getDBCollection(collection); long start = PERFLOG.start(); try {/*from w w w . j av a 2 s . c o m*/ dbCollection.remove(getByKeyQuery(key).get()); } catch (Exception e) { throw DocumentStoreException.convert(e, "Remove failed for " + key); } finally { invalidateCache(collection, key); PERFLOG.end(start, 1, "remove key={}", key); } }
From source file:org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore.java
License:Apache License
@Override public <T extends Document> void remove(Collection<T> collection, List<String> keys) { log("remove", keys); DBCollection dbCollection = getDBCollection(collection); long start = PERFLOG.start(); try {//from ww w .j a v a2 s. c om for (List<String> keyBatch : Lists.partition(keys, IN_CLAUSE_BATCH_SIZE)) { DBObject query = QueryBuilder.start(Document.ID).in(keyBatch).get(); try { dbCollection.remove(query); } catch (Exception e) { throw DocumentStoreException.convert(e, "Remove failed for " + keyBatch); } finally { if (collection == Collection.NODES) { for (String key : keyBatch) { invalidateCache(collection, key); } } } } } finally { PERFLOG.end(start, 1, "remove keys={}", keys); } }