Java Code Examples for com.mongodb.DB#doEval()

The following examples show how to use com.mongodb.DB#doEval() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoDataProxy.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private CommandResult loadData() {
	logger.debug("IN");

	CommandResult result = null;

	String clientUrl = dataSource.getUrlConnection();

	logger.debug("Getting the connection URL and db name");

	if (dataSource.getUser() != null && dataSource.getPwd() != null && dataSource.getUser().length() > 0 && dataSource.getPwd().length() > 0) {
		String authPart = "mongodb://"+dataSource.getUser()+":"+dataSource.getPwd()+"@";
		clientUrl = clientUrl.replace("mongodb://", authPart);
	}
	
	logger.debug("MongoDB connection URI:"+clientUrl);
	MongoClientURI mongoClientURI= new MongoClientURI(clientUrl);
	MongoClient mongoClient = new MongoClient(new MongoClientURI(clientUrl));
	logger.debug("Connecting to mongodb");
	String databaseName = mongoClientURI.getDatabase();
	logger.debug("Database name: " + databaseName);


	try {
		logger.debug("Connecting to the db " + databaseName);
		DB database = mongoClient.getDB(databaseName);

		logger.debug("Executing the statement" + statement);
		result = database.doEval(getDecoredStatement());

	} catch (Exception e) {
		logger.error("Exception executing the MongoDataset", e);
		throw new SpagoBIRuntimeException("Exception executing the MongoDataset", e);
	} finally {
		logger.debug("Closing connection");
		mongoClient.close();
	}

	logger.debug("OUT");
	return result;

}
 
Example 2
Source File: MongoUtil.java    From gameserver with Apache License 2.0 2 votes vote down vote up
/**
 * Do a server-side eval operation. 
 * Note it is a block operation.
 * 
 * @param databaseName
 * @param namespace
 * @param collection
 * @param code
 * @param args
 * @return
 */
public static final CommandResult doEval(String databaseName,
		String namespace, String collection, String code, Object[] args) {
	DB db = getDB(databaseName, namespace, collection);
	return db.doEval(code, args);
}
 
Example 3
Source File: MongoDBUtil.java    From gameserver with Apache License 2.0 2 votes vote down vote up
/**
 * Do a server-side eval operation. 
 * Note it is a block operation.
 * 
 * @param databaseName
 * @param namespace
 * @param collection
 * @param code
 * @param args
 * @return
 */
public static final CommandResult doEval(String databaseName,
		String namespace, String collection, String code, Object[] args) {
	DB db = getDB(databaseName, namespace, collection);
	return db.doEval(code, args);
}