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

apoc.export.json.ImportJsonConfig Maven / Gradle / Ivy

There is a newer version: 4.4.0.31
Show newest version
package apoc.export.json;

import apoc.util.Util;
import org.apache.commons.lang3.StringUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;

public class ImportJsonConfig {

    private final Map> nodePropertyMappings;
    private final Map> relPropertyMappings;

    private final int unwindBatchSize;
    private final int txBatchSize;

    private final String importIdName;

    public ImportJsonConfig(Map config) {
        config = config == null ? Collections.emptyMap() : config;
        this.nodePropertyMappings = (Map>) config.getOrDefault("nodePropertyMappings", Collections.emptyMap());
        this.relPropertyMappings = (Map>) config.getOrDefault("relPropertyMappings", Collections.emptyMap());
        this.unwindBatchSize = Util.toInteger(config.getOrDefault("unwindBatchSize", 5000));
        this.txBatchSize = Util.toInteger(config.getOrDefault("txBatchSize", 5000));
        this.importIdName = (String) config.getOrDefault("importIdName", "neo4jImportId");
    }

    public String typeForNode(Collection labels, String property) {
        return labels.stream()
                .map(label -> nodePropertyMappings.getOrDefault(label, Collections.emptyMap()).get(property))
                .filter(StringUtils::isNotBlank)
                .findFirst()
                .orElse(null);
    }

    public String typeForRel(String type, String property) {
        return relPropertyMappings.getOrDefault(type, Collections.emptyMap()).get(property);
    }

    public int getUnwindBatchSize() {
        return unwindBatchSize;
    }

    public int getTxBatchSize() {
        return txBatchSize;
    }

    public String getImportIdName() {
        return importIdName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy