Search in sources :

Example 1 with NodesAndRelsSubGraph

use of apoc.export.util.NodesAndRelsSubGraph in project neo4j-apoc-procedures by neo4j-contrib.

the class ExportCSV method graph.

@Procedure
@Description("apoc.export.csv.graph(graph,file,config) - exports given graph object as csv 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 exportCsv(fileName, source, new NodesAndRelsSubGraph(db, nodes, rels), config);
}
Also used : Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) NodesAndRelsSubGraph(apoc.export.util.NodesAndRelsSubGraph) Collection(java.util.Collection) Description(apoc.Description) Procedure(org.neo4j.procedure.Procedure)

Example 2 with NodesAndRelsSubGraph

use of apoc.export.util.NodesAndRelsSubGraph 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));
}
Also used : ExportConfig(apoc.export.util.ExportConfig) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) NodesAndRelsSubGraph(apoc.export.util.NodesAndRelsSubGraph) Collection(java.util.Collection)

Example 3 with NodesAndRelsSubGraph

use of apoc.export.util.NodesAndRelsSubGraph in project neo4j-apoc-procedures by neo4j-contrib.

the class ExportCypher method graph.

@Procedure
@Description("apoc.export.cypher.graph(graph,file,config) - exports given graph object incl. indexes as cypher statements to the provided file")
public Stream<DataProgressInfo> graph(@Name("graph") Map<String, Object> graph, @Name(value = "file", defaultValue = "") String fileName, @Name(value = "config", defaultValue = "{}") Map<String, Object> config) throws IOException {
    if (Util.isNullOrEmpty(fileName))
        fileName = null;
    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 exportCypher(fileName, source, new NodesAndRelsSubGraph(db, nodes, rels), new ExportConfig(config), false);
}
Also used : ExportConfig(apoc.export.util.ExportConfig) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) NodesAndRelsSubGraph(apoc.export.util.NodesAndRelsSubGraph)

Aggregations

NodesAndRelsSubGraph (apoc.export.util.NodesAndRelsSubGraph)3 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 ExportConfig (apoc.export.util.ExportConfig)2 Collection (java.util.Collection)2 Description (apoc.Description)1 Procedure (org.neo4j.procedure.Procedure)1