当前位置: 首页>>代码示例>>Java>>正文


Java MongoNamespace类代码示例

本文整理汇总了Java中com.mongodb.MongoNamespace的典型用法代码示例。如果您正苦于以下问题:Java MongoNamespace类的具体用法?Java MongoNamespace怎么用?Java MongoNamespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MongoNamespace类属于com.mongodb包,在下文中一共展示了MongoNamespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Throwable {
    super.setUp();
    gridFSBucket = GridFSBuckets.create(database);
    filesCollection = initializeCollection(new MongoNamespace(getDefaultDatabaseName(), "fs.files"))
            .withDocumentClass(BsonDocument.class);
    chunksCollection = initializeCollection(new MongoNamespace(getDefaultDatabaseName(), "fs.chunks"))
            .withDocumentClass(BsonDocument.class);

    List<BsonDocument> filesDocuments = processFiles(data.getArray("files", new BsonArray()), new ArrayList<BsonDocument>());
    if (!filesDocuments.isEmpty()) {
        filesCollection.insertMany(filesDocuments).timeout(30, SECONDS).first().toBlocking().first();
    }

    List<BsonDocument> chunksDocuments = processChunks(data.getArray("chunks", new BsonArray()), new ArrayList<BsonDocument>());
    if (!chunksDocuments.isEmpty()) {
        chunksCollection.insertMany(chunksDocuments).timeout(30, SECONDS).first().toBlocking().first();
    }
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:21,代码来源:GridFSTest.java

示例2: onReanameCollection

import com.mongodb.MongoNamespace; //导入依赖的package包/类
private void onReanameCollection(ActionEvent actionEvent) {
  TreeItem<DbTreeValue> selectedItem = treeView.getSelectionModel().getSelectedItem();
  if (selectedItem == null) {
    return;
  }

  DbTreeValue value = selectedItem.getValue();
  TextInputDialog dialog = new TextInputDialog(value.getDisplayValue());
  dialog.setContentText("New collection name:");
  dialog.setHeaderText("Rename collection");
  dialog.showAndWait().ifPresent(targetCollection -> {
    MongoCollection<Document> collection = value.getMongoDatabase().getMongoDb().getCollection(value.getDisplayValue());
    collection.renameCollection(new MongoNamespace(value.getMongoDatabase().getName(), targetCollection));
    ((DynamicTreeItem)selectedItem.getParent()).reload();
  });
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:17,代码来源:DBTreeController.java

示例3: iterator

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@JsIgnore
@Override
public MongoCursor<Document> iterator(int skip, int limit) {
  MongoCollection<Document> collection = getCollection();

  findOptions.skip(skip);
  findOptions.limit(limit);
  if (projection != null) {
    findOptions.projection(projection);
  }
  if (sort != null) {
    findOptions.sort(dbObjectFromMap(sort));
  }
  return new FindIterable(new MongoNamespace(mongoDatabase.getName(), collectionName), collection.getCodecRegistry(), //
      collection.getReadPreference(), getExecutor(), findQuery, findOptions).iterator();
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:17,代码来源:FindResultIterable.java

示例4: setUp

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Throwable {
    super.setUp();
    gridFSBucket = GridFSBuckets.create(database);
    filesCollection = initializeCollection(new MongoNamespace(getDefaultDatabaseName(), "fs.files"))
            .withDocumentClass(BsonDocument.class);
    chunksCollection = initializeCollection(new MongoNamespace(getDefaultDatabaseName(), "fs.chunks"))
            .withDocumentClass(BsonDocument.class);

    List<BsonDocument> filesDocuments = processFiles(data.getArray("files", new BsonArray()), new ArrayList<BsonDocument>());
    if (!filesDocuments.isEmpty()) {
        ObservableSubscriber<Success> filesInsertSubscriber = new ObservableSubscriber<Success>();
        filesCollection.insertMany(filesDocuments).subscribe(filesInsertSubscriber);
        filesInsertSubscriber.await(30, SECONDS);
    }

    List<BsonDocument> chunksDocuments = processChunks(data.getArray("chunks", new BsonArray()), new ArrayList<BsonDocument>());
    if (!chunksDocuments.isEmpty()) {
        ObservableSubscriber<Success> chunksInsertSubscriber = new ObservableSubscriber<Success>();
        chunksCollection.insertMany(chunksDocuments).subscribe(chunksInsertSubscriber);
        chunksInsertSubscriber.await(30, SECONDS);
    }
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:25,代码来源:GridFSTest.java

示例5: setUp

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Before
public void setUp() throws Exception {

    interceptor = new MongoDBMethodInterceptor();

    Config.Plugin.MongoDB.TRACE_PARAM = true;

    when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn("127.0.0.1:27017");

    BsonDocument document = new BsonDocument();
    document.append("name", new BsonString("by"));
    MongoNamespace mongoNamespace = new MongoNamespace("test.user");
    Decoder decoder = PowerMockito.mock(Decoder.class);
    FindOperation findOperation = new FindOperation(mongoNamespace, decoder);
    findOperation.filter(document);

    arguments = new Object[] {findOperation};
    argumentTypes = new Class[] {findOperation.getClass()};
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:21,代码来源:MongoDBMethodInterceptorTest.java

示例6: execute

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
	MongoDatabase	db	= getMongoDatabase( _session, argStruct );
	
	String collection	= getNamedStringParam(argStruct, "collection", null);
	if ( collection == null )
		throwException(_session, "please specify a collection");
	
	String name	= getNamedStringParam(argStruct, "name", null);
	if ( name == null )
		throwException(_session, "please specify a name");
	
	try{
		
		db
			.getCollection( collection )
			.renameCollection( new MongoNamespace( db.getName(), name ), new RenameCollectionOptions().dropTarget( getNamedBooleanParam(argStruct, "droptarget", false ) ) );

		return cfBooleanData.TRUE;
		
	} catch (MongoException me){
		throwException(_session, me.getMessage());
		return null;
	}
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:25,代码来源:MongoCollectionRename.java

示例7: renameCollection

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@Override
public Boolean renameCollection(String newCollection,String oldCollection) {
	// old collection name
	String collectionNameForT = null;
	
	if (oldCollection == null) {
		collectionNameForT = getCollectionName(this.collectionNames.get());
	}
	else {
		collectionNameForT = getCollectionName(oldCollection);
	}
	
	// collection
	MongoCollection<Document> collection = database.getCollection(collectionNameForT);
	
	// database name
	String databaseName = database.getName();
	// MongoDB namespace
	MongoNamespace mongoNamespace = new MongoNamespace(databaseName+"."+newCollection);
	
	if (collection == null) {
		collection.renameCollection(mongoNamespace);
	}
	else {
		gc(); // clear
		return false;
	}
	
	gc(); // clear
	
	return true;
}
 
开发者ID:lolog,项目名称:mogodb-dao,代码行数:33,代码来源:MongoDaoImpl.java

示例8: setup

import com.mongodb.MongoNamespace; //导入依赖的package包/类
private void setup(MongoNamespace namespace, Document bson) {
    this.namespace = namespace;
    if (bson == null) {
        this.bson = new DBDataDocument(new Document("_id", id.toString()));
        SimpleAPIImpl.getDatabaseManager().withCollectionConsumer(namespace.getDatabaseName(), namespace.getCollectionName(), c -> c.insertOne(new Document(this.bson)));
    } else
        this.bson = new DBDataDocument(bson);
    id = this.bson.getString("_id");
    loaded = true;
}
 
开发者ID:toonsevrin,项目名称:SimpleAPI,代码行数:11,代码来源:DBDataImpl.java

示例9: renameCollection

import com.mongodb.MongoNamespace; //导入依赖的package包/类
@Override
public Observable<Success> renameCollection(final MongoNamespace newCollectionNamespace, final RenameCollectionOptions options) {
    return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() {
        @Override
        public void apply(final SingleResultCallback<Success> callback) {
            wrapped.renameCollection(newCollectionNamespace, options, voidToSuccessCallback(callback));
        }
    }), observableAdapter);
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java

示例10: initializeCollection

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public static MongoCollection<Document> initializeCollection(final MongoNamespace namespace) throws Throwable {
    MongoDatabase database = getMongoClient().getDatabase(namespace.getDatabaseName());
    try {
        database.runCommand(new Document("drop", namespace.getCollectionName())).timeout(10, SECONDS).toBlocking().first();
    } catch (MongoCommandException e) {
        if (!e.getErrorMessage().startsWith("ns not found")) {
            throw e;
        }
    }
    return database.getCollection(namespace.getCollectionName());
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:12,代码来源:Fixture.java

示例11: drop

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public static void drop(final MongoNamespace namespace) throws Throwable {
    try {
        getMongoClient().getDatabase(namespace.getDatabaseName())
                .runCommand(new Document("drop", namespace.getCollectionName())).timeout(10, SECONDS).toBlocking().first();
    } catch (MongoCommandException e) {
        if (!e.getErrorMessage().contains("ns not found")) {
            throw e;
        }
    }
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:11,代码来源:Fixture.java

示例12: FindIterable

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public FindIterable(final MongoNamespace namespace,
    final CodecRegistry codecRegistry,
    final ReadPreference readPreference, final OperationExecutor executor,
    final Bson filter, final FindOptions findOptions) {
  this.namespace = notNull("namespace", namespace);
  this.codecRegistry = notNull("codecRegistry", codecRegistry);
  this.readPreference = notNull("readPreference", readPreference);
  this.executor = notNull("executor", executor);
  this.filter = notNull("filter", filter);
  this.findOptions = notNull("findOptions", findOptions);
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:12,代码来源:FindIterable.java

示例13: explain

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public ObjectListPresentation explain() {
  MongoCollection<Document> collection = getCollection();

  FindIterable findIterable = new FindIterable(new MongoNamespace(mongoDatabase.getName(), collectionName), collection.getCodecRegistry(), //
      collection.getReadPreference(), getExecutor(), findQuery, findOptions);

  BsonDocument res = findIterable.explainIterator(ExplainVerbosity.QUERY_PLANNER);
  return JsApiUtils.singletonIter(JsApiUtils.convertBsonToDocument(res));
}
 
开发者ID:daa84,项目名称:mongofx,代码行数:10,代码来源:FindResultIterable.java

示例14: initializeCollection

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public static MongoCollection<Document> initializeCollection(final MongoNamespace namespace) throws Throwable {
    MongoDatabase database = getMongoClient().getDatabase(namespace.getDatabaseName());
    try {
        RxReactiveStreams.toObservable(database.runCommand(new Document("drop", namespace.getCollectionName())))
                .timeout(10, SECONDS).toBlocking().toIterable();
    } catch (MongoCommandException e) {
        if (!e.getErrorMessage().startsWith("ns not found")) {
            throw e;
        }
    }
    return database.getCollection(namespace.getCollectionName());
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:13,代码来源:Fixture.java

示例15: drop

import com.mongodb.MongoNamespace; //导入依赖的package包/类
public static void drop(final MongoNamespace namespace) throws Throwable {
    try {
        RxReactiveStreams.toObservable(getMongoClient().getDatabase(namespace.getDatabaseName())
                .runCommand(new Document("drop", namespace.getCollectionName()))).timeout(10, SECONDS).toBlocking().toIterable();
    } catch (MongoCommandException e) {
        if (!e.getErrorMessage().contains("ns not found")) {
            throw e;
        }
    }
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:11,代码来源:Fixture.java


注:本文中的com.mongodb.MongoNamespace类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。