use of apoc.export.util.ExportConfig in project neo4j-apoc-procedures by neo4j-contrib.
the class ExportCSV method exportCsv.
private Stream<ProgressInfo> exportCsv(@Name("file") String fileName, String source, Object data, Map<String, Object> config) throws Exception {
checkWriteAllowed();
ExportConfig c = new ExportConfig(config);
ProgressReporter reporter = new ProgressReporter(null, null, new ProgressInfo(fileName, source, "csv"));
PrintWriter printWriter = getPrintWriter(fileName, null);
CsvFormat exporter = new CsvFormat(db);
if (data instanceof SubGraph)
exporter.dump(((SubGraph) data), printWriter, reporter, c);
if (data instanceof Result)
exporter.dump(((Result) data), printWriter, reporter, c);
return reporter.stream();
}
use of apoc.export.util.ExportConfig in project neo4j-apoc-procedures by neo4j-contrib.
the class ExportCypher method query.
@Procedure
@Description("apoc.export.cypher.query(query,file,config) - exports nodes and relationships from the cypher statement incl. indexes as cypher statements to the provided file")
public Stream<DataProgressInfo> query(@Name("query") String query, @Name(value = "file", defaultValue = "") String fileName, @Name(value = "config", defaultValue = "{}") Map<String, Object> config) throws IOException {
if (Util.isNullOrEmpty(fileName))
fileName = null;
ExportConfig c = new ExportConfig(config);
Result result = db.execute(query);
SubGraph graph = CypherResultSubGraph.from(result, db, c.getRelsInBetween());
String source = String.format("statement: nodes(%d), rels(%d)", Iterables.count(graph.getNodes()), Iterables.count(graph.getRelationships()));
return exportCypher(fileName, source, graph, c, false);
}
use of apoc.export.util.ExportConfig in project neo4j-apoc-procedures by neo4j-contrib.
the class ExportGraphML method graph.
@Procedure
@Description("apoc.export.graphml.graph(graph,file,config) - exports given graph object as graphml to the provided file")
public Stream<ProgressInfo> graph(@Name("graph") Map<String, Object> graph, @Name("file") String fileName, @Name("config") Map<String, Object> config) throws Exception {
Collection<Node> nodes = (Collection<Node>) graph.get("nodes");
Collection<Relationship> rels = (Collection<Relationship>) graph.get("relationships");
String source = String.format("graph: nodes(%d), rels(%d)", nodes.size(), rels.size());
return exportGraphML(fileName, source, new NodesAndRelsSubGraph(db, nodes, rels), new ExportConfig(config));
}
use of apoc.export.util.ExportConfig in project neo4j-apoc-procedures by neo4j-contrib.
the class ExportGraphML method query.
@Procedure
@Description("apoc.export.graphml.query(query,file,config) - exports nodes and relationships from the cypher statement as graphml to the provided file")
public Stream<ProgressInfo> query(@Name("query") String query, @Name("file") String fileName, @Name("config") Map<String, Object> config) throws Exception {
ExportConfig c = new ExportConfig(config);
Result result = db.execute(query);
SubGraph graph = CypherResultSubGraph.from(result, db, c.getRelsInBetween());
String source = String.format("statement: nodes(%d), rels(%d)", Iterables.count(graph.getNodes()), Iterables.count(graph.getRelationships()));
return exportGraphML(fileName, source, graph, c);
}
use of apoc.export.util.ExportConfig in project neo4j-apoc-procedures by neo4j-contrib.
the class ExportGraphML method file.
@Procedure(name = "apoc.import.graphml", mode = Mode.WRITE)
@Description("apoc.import.graphml(file,config) - imports graphml file")
public Stream<ProgressInfo> file(@Name("file") String fileName, @Name("config") Map<String, Object> config) throws Exception {
ProgressInfo result = Util.inThread(() -> {
ExportConfig exportConfig = new ExportConfig(config);
ProgressReporter reporter = new ProgressReporter(null, null, new ProgressInfo(fileName, "file", "graphml"));
XmlGraphMLReader graphMLReader = new XmlGraphMLReader(db).reporter(reporter).batchSize(exportConfig.getBatchSize()).relType(exportConfig.defaultRelationshipType()).nodeLabels(exportConfig.readLabels());
if (exportConfig.storeNodeIds())
graphMLReader.storeNodeIds();
graphMLReader.parseXML(FileUtils.readerFor(fileName));
return reporter.getTotal();
});
return Stream.of(result);
}
Aggregations