@Override public void addOutputs(ObjectId streamId, Collection<ObjectId> outputIds) { final BasicDBList outputs = new BasicDBList(); outputs.addAll(outputIds); collection(StreamImpl.class).update( new BasicDBObject("_id", streamId), new BasicDBObject("$addToSet", new BasicDBObject(StreamImpl.FIELD_OUTPUTS, new BasicDBObject("$each", outputs))) ); clusterEventBus.post(StreamsChangedEvent.create(streamId.toHexString())); }
public void setData(final List<?> data) { this.data = new BasicDBList(); this.data.addAll(data); }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { Document command = new Document("$eval", script.getCode()); BasicDBList commandArgs = new BasicDBList(); commandArgs.addAll(Arrays.asList(convertScriptArgs(false, args))); command.append("args", commandArgs); return db.runCommand(command).get("retval"); } });
private static BasicDBList toDBList(final BatchCursor<DBObject> source) { BasicDBList dbList = new BasicDBList(); while (source.hasNext()) { dbList.addAll(source.next()); } return dbList; }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { Document command = new Document("$eval", script.getCode()); BasicDBList commandArgs = new BasicDBList(); commandArgs.addAll(Arrays.asList(convertScriptArgs(false, args))); command.append("args", commandArgs); return db.runCommand(command).get("retval"); } });
public static BasicDBList wrap(List otherList) { BasicDBList list = new BasicDBList(); list.addAll(otherList); return list; }
BasicDBList dblist = new BasicDBList(); // create arraylist to use ArrayList<String> alist = new ArrayList<String>(); alist.add("blip"); alist.add("bloop"); alist.add("blap"); dblist.addAll(alist); System.out.println(dblist); }
Optional<BasicDBObject> collectionQuery() { List<String> exactMatches = databasesWithCollections().collect(Collectors.toList()); if( exactMatches.isEmpty() ) { return Optional.empty(); } else { BasicDBList exactMatchList = new BasicDBList(); exactMatchList.addAll(exactMatches); return Optional.of( new BasicDBObject("$in", exactMatchList)); } }
public static void getDocuments(List<Integer> documentIds) { BasicDBList docIds = new BasicDBList(); docIds.addAll(documentIds) DBObject inClause = new BasicDBObject("$in", docIds); DBObject query = new BasicDBObject("Id", inClause); DBCursor dbCursor = mongoRule.getDatabase().getCollection("mycollection").find(query); System.out.println(dbCursor == null); if (dbCursor != null) { while (dbCursor.hasNext()) { System.out.println("object - " + dbCursor.next()); } } }
/** * Chain add to build object. * * @param value * target value * @return */ public PropertyDocumentBuilder addFixedValues(Set<String> values) { BasicDBList fixedValues = new BasicDBList(); if (values != null) { fixedValues.addAll(values); builder.append(PROPERTY_FIXEDVALUES, fixedValues); } return this; }
/** * Chain add to build object. * * @param value * target value * @return */ public FeatureDBObjectBuilder addRoles(Set<String> auths) { BasicDBList authorizations = new BasicDBList(); authorizations.addAll(auths); builder.add(ROLES, authorizations); return this; }
/** * Chain add to build object. * * @param value * target value * @return */ public PropertyDBObjectBuilder addFixedValues(Set<String> values) { BasicDBList fixedValues = new BasicDBList(); if (values != null) { fixedValues.addAll(values); builder.add(PROPERTY_FIXEDVALUES, fixedValues); } return this; }
Optional<Object> query() { BasicDBList queries = new BasicDBList(); collectionQuery().ifPresent(queries::add); queries.addAll(databaseQueries()); if( queries.size() == 0 ) { return Optional.empty(); } else if( queries.size() == 1 ) { return Optional.of(queries.get(0)); } else { return Optional.of(new BasicDBObject("$or", queries)); } } }
private static BasicDBList toDBList(final BatchCursor<DBObject> source) { BasicDBList dbList = new BasicDBList(); while (source.hasNext()) { dbList.addAll(source.next()); } return dbList; }
@Override public DBObject createResult(DBCollection coll) { BasicDBList list = new BasicDBList(); list.addAll(coll.find().toArray()); return list; } };
/** * Deserialize the input bytes into object */ @Override @SuppressWarnings("unchecked") public <T> T fromDBObject(Document input, Class<T> expected) throws Exception { //NOSONAR try { if (input == null) { return null; } final BasicDBList list = new BasicDBList(); list.addAll((List) input.get(OBJECT_FIELD)); return (T) objectMapper.readValue(list.toString(), expected); } catch (Exception e) { throw new MongoException("Unknown error occurred converting BSON to object", e); } } }
private void readMetaClass(InputStream is, BasicDBList metas) { DBObject bson = loadBasonFromFile(is); if (bson instanceof BasicDBList) { metas.addAll((BasicDBList)bson); } else { metas.add(bson); } }
private void readMetaClasses(InputStream is, BasicDBList metas) { DBObject bson = loadBasonFromFile(is); if (bson instanceof BasicDBList) { metas.addAll((BasicDBList)bson); } else { metas.add(bson); } }
@Override void mergeAction(String subKey, DBObject subObject, Object object) { List newList = expressionParser.typecast(command + " value", object, List.class); if (!subObject.containsField(subKey)){ subObject.put(subKey, newList); } else { BasicDBList currentValue = expressionParser.typecast(subKey, subObject.get(subKey), BasicDBList.class); currentValue.addAll(newList); subObject.put(subKey, currentValue); } } },
public synchronized void pushToBatch(DBObject sample, boolean isList){ if(sample == null){ // A null sample indicates a flush is required if(currentBatch.size() > 0){ flushBatch(); } } else { // Add the list or document to the current batch if(isList){ currentBatch.addAll((BasicDBList) sample); } else { currentBatch.add(sample); } // If the batch size exceeds limit, flush it if(currentBatch.size() >= maxBatchSize){ flushBatch(); } } }