Example usage for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getScopeVariables

List of usage examples for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getScopeVariables

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getScopeVariables.

Prototype

public Map<String, Object> getScopeVariables() 

Source Link

Usage

From source file:org.springframework.data.mongodb.core.MongoTemplate.java

private DBObject copyMapReduceOptions(MapReduceOptions mapReduceOptions, MapReduceCommand command) {
    if (mapReduceOptions.getJavaScriptMode() != null) {
        command.addExtraOption("jsMode", true);
    }/*www .j  av a 2  s.com*/
    if (!mapReduceOptions.getExtraOptions().isEmpty()) {
        for (Map.Entry<String, Object> entry : mapReduceOptions.getExtraOptions().entrySet()) {
            command.addExtraOption(entry.getKey(), entry.getValue());
        }
    }
    if (mapReduceOptions.getFinalizeFunction() != null) {
        command.setFinalize(this.replaceWithResourceIfNecessary(mapReduceOptions.getFinalizeFunction()));
    }
    if (mapReduceOptions.getOutputDatabase() != null) {
        command.setOutputDB(mapReduceOptions.getOutputDatabase());
    }
    if (!mapReduceOptions.getScopeVariables().isEmpty()) {
        command.setScope(mapReduceOptions.getScopeVariables());
    }

    DBObject commandObject = command.toDBObject();
    DBObject outObject = (DBObject) commandObject.get("out");

    if (mapReduceOptions.getOutputSharded() != null) {
        outObject.put("sharded", mapReduceOptions.getOutputSharded());
    }
    return commandObject;
}