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

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

Introduction

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

Prototype

@Nullable
    public Boolean getJavaScriptMode() 

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);
    }/* w w w . j a  va  2s  .c om*/
    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;
}