apoc.export.json.ImportJsonConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apoc Show documentation
Show all versions of apoc Show documentation
A collection of useful Neo4j Procedures
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;
}
}