All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.ravendb.client.documents.indexes.AbstractJavaScriptIndexCreationTask Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
package net.ravendb.client.documents.indexes;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class AbstractJavaScriptIndexCreationTask extends AbstractIndexCreationTaskBase {

    private final IndexDefinition _definition = new IndexDefinition();

    protected AbstractJavaScriptIndexCreationTask() {
    }

    public Set getMaps() {
        return _definition.getMaps();
    }

    public void setMaps(Set maps) {
        _definition.setMaps(maps);
    }

    public Map getFields() {
        return _definition.getFields();
    }

    public void setFields(Map fields) {
        _definition.setFields(fields);
    }

    protected String getReduce() {
        return _definition.getReduce();
    }

    protected void setReduce(String reduce) {
        _definition.setReduce(reduce);
    }

    @Override
    public boolean isMapReduce() {
        return getReduce() != null;
    }

    /**
     * @return If not null than each reduce result will be created as a document in the specified collection name.
     */
    protected String getOutputReduceToCollection() {
        return _definition.getOutputReduceToCollection();
    }

    /**
     * @param outputReduceToCollection If not null than each reduce result will be created as a document in the specified collection name.
     */
    protected void setOutputReduceToCollection(String outputReduceToCollection) {
        _definition.setOutputReduceToCollection(outputReduceToCollection);
    }

    /**
     * @return Defines a collection name for reference documents created based on provided pattern
     */
    protected String getPatternReferencesCollectionName() {
        return _definition.getPatternReferencesCollectionName();
    }

    /**
     * @param patternReferencesCollectionName Defines a collection name for reference documents created based on provided pattern
     */
    protected void setPatternReferencesCollectionName(String patternReferencesCollectionName) {
        _definition.setPatternReferencesCollectionName(patternReferencesCollectionName);
    }

    /**
     * @return Defines a collection name for reference documents created based on provided pattern
     */
    protected String getPatternForOutputReduceToCollectionReferences() {
        return _definition.getPatternForOutputReduceToCollectionReferences();
    }

    /**
     * @param patternForOutputReduceToCollectionReferences Defines a collection name for reference documents created based on provided pattern
     */
    protected void setPatternForOutputReduceToCollectionReferences(String patternForOutputReduceToCollectionReferences) {
        _definition.setPatternForOutputReduceToCollectionReferences(patternForOutputReduceToCollectionReferences);
    }

    @Override
    public IndexDefinition createIndexDefinition() {
        _definition.setName(getIndexName());
        _definition.setType(isMapReduce() ? IndexType.JAVA_SCRIPT_MAP_REDUCE : IndexType.JAVA_SCRIPT_MAP);
        if (getAdditionalSources() != null) {
            _definition.setAdditionalSources(getAdditionalSources());
        } else {
            _definition.setAdditionalSources(new HashMap<>());
        }
        _definition.setConfiguration(configuration);
        _definition.setLockMode(lockMode);
        _definition.setPriority(priority);
        return _definition;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy