本文整理汇总了Java中org.neo4j.tooling.GlobalGraphOperations.at方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalGraphOperations.at方法的具体用法?Java GlobalGraphOperations.at怎么用?Java GlobalGraphOperations.at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.tooling.GlobalGraphOperations
的用法示例。
在下文中一共展示了GlobalGraphOperations.at方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allNodes
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
@Override
public IGraphIterable<IGraphNode> allNodes(String label) {
if (graph != null) {
GlobalGraphOperations g = GlobalGraphOperations.at(graph);
return (label == null) ? (new Neo4JIterable<IGraphNode>(
g.getAllNodes(), this)) : (new Neo4JIterable<IGraphNode>(
g.getAllNodesWithLabel(Neo4JBatchUtil.createLabel(label)),
this));
} else {
LOGGER.warn("allNodes called in a batch isert mode, please exit batch insert first, returning null");
return null;
}
}
示例2: writeOutContent
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
public void writeOutContent(String filename) {
GlobalGraphOperations ops = GlobalGraphOperations.at(graphDb);
ExecutionEngine engine = new ExecutionEngine(graphDb);
try (FileWriter writer = new FileWriter(filename);
Transaction tx = graphDb.beginTx()) {
for (Node n : ops.getAllNodes()) {
writer.write("[" + n.getId() + "," + n.getProperty(PROP_NAME)
+ ",[");
Iterator<Node> connected = engine.execute(
"START s=node(" + n.getId()
+ ") MATCH s-[r]->n RETURN n").columnAs("n");
for (Node e : IteratorUtil.asIterable(connected)) {
Iterator<String> rel = engine.execute(
"START s=node(" + n.getId() + "), e=node("
+ e.getId()
+ ") MATCH s-[r]->e RETURN r.value")
.columnAs("r.value");
String relVal = rel.hasNext()? rel.next() : "";
writer.write("[" + e.getId() + ","
+ relVal + "],");
}
writer.write("]]\n");
}
tx.success();
} catch (IOException e1) {
e1.printStackTrace();
}
}
示例3: Database
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
public Database(GraphDatabaseService database, Transaction transaction) {
this.database = database;
this.engine = new ExecutionEngine(database);
this.global = GlobalGraphOperations.at(database);
this.transaction = transaction;
this.labelCache = new HashMap<>();
this.typeCache = new HashMap<>();
}
示例4: loadTopology
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
public static <V, E> Neo4jTopology loadTopology(Neo4jWorkspaceSettings settings) throws Exception {
String db = DatabaseConfiguration.readDatabase(settings);
Logger.getLogger(Neo4jWorkspace.class).info("using db " + db);
// Get neo4j stuffs
GraphDatabaseFactory factory = new GraphDatabaseFactory();
GraphDatabaseService database = factory.newEmbeddedDatabase(db);
GlobalGraphOperations operation = GlobalGraphOperations.at(database);
ViewsManager views = new ViewsManager();
views.load(settings);
// Setup graph model
Neo4jGraphModelIO gio = new Neo4jGraphModelIO();
gio.read(SimpleFile.read(settings.getModelPath()));
Neo4jGraphModel typeModel = gio.getGraphModel();
// Build graph
INeo4jGraphReader r = views.getFirst().getFilter();
Graph<IPropertyNode, IPropertyEdge> graph = r.read(operation, typeModel);
Logger.getLogger(Neo4jWorkspace.class).info("filtered graph has " + graph.getVertexCount() + " nodes using db " + db);
// Build topology using graph typing model
String topologyName = views.getFirst().getTopologyName();
Neo4jTopologyFactory tfact = new Neo4jTopologyFactory();
Neo4jTopology topology = tfact.newTopology(topologyName, graph, typeModel);
return topology;
}
示例5: main
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String db = null;
if(args.length>0){
db = args[0];
}
else{
System.err.println("requires the relative db path as parameter: data/databases/???");
return;
}
// Get graph data to build model
GraphDatabaseFactory f = new GraphDatabaseFactory();
GraphDatabaseService s = f.newEmbeddedDatabase(db);
GlobalGraphOperations o = GlobalGraphOperations.at(s);
// Build all netscope models
//Multimap<NodeType, Node> getNodeTypes(Collection<Node> nodes)
String st = nodeTypes(getGraph(o));
System.out.println(st);
File dbf = new File(db);
String pt = dbf.getParent() + "/" + dbf.getName() + "-types.ns";
SimpleFile.write(st, pt);
System.out.println("--------------");
System.out.println("this was saved to " + pt);
}
示例6: before
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
@Before
public void before(){
Logger.getLogger(this.getClass()).info("using db " + TEST_DB);
factory = new GraphDatabaseFactory();
database = factory.newEmbeddedDatabase(TEST_DB);
operation = GlobalGraphOperations.at(database);
}
示例7: Neo4jWorkspace
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
/**
* Build full Neo4jWorkspace involving reading files given by settings:
* <ul>
* <li>neo4j database
* <li>view
* <li>graph model
* <li>projection
* </ul>
* and build topology & geometrical model according to Neo4j factories
*
* @param settings
* @throws Exception
*/
public Neo4jWorkspace(Neo4jWorkspaceSettings settings) throws Exception {
String db = DatabaseConfiguration.readDatabase(settings);
Logger.getLogger(Neo4jWorkspace.class).info("using db " + db);
// Get neo4j stuffs
GraphDatabaseFactory factory = new GraphDatabaseFactory();
database = factory.newEmbeddedDatabase(db);
operation = GlobalGraphOperations.at(database);
views = new ViewsManager();
views.load(settings);
layoutML = views.getFirst().getLayout();
// Setup graph model
Neo4jGraphModelIO gio = new Neo4jGraphModelIO();
gio.read(SimpleFile.read(settings.getModelPath()));
Neo4jGraphModel typeModel = gio.getGraphModel();
// Build graph
INeo4jGraphReader r = views.getFirst().getFilter();
Graph<IPropertyNode, IPropertyEdge> graph = r.read(operation, typeModel);
Logger.getLogger(Neo4jWorkspace.class).info("filtered graph has " + graph.getVertexCount() + " nodes using db " + db);
// Build topology using graph typing model
String topologyName = views.getFirst().getTopologyName();
Neo4jTopologyFactory tfact = new Neo4jTopologyFactory();
topology = tfact.newTopology(topologyName, graph, typeModel);
// Edit topology according to dataprism
Dataprism dp = loadDataprism(settings);
if (dp != null)
((Neo4jTopology)topology).edit().apply(dp);
// Build layout model
modelFactory = new Neo4jModelFactory(gio.getGraphModel());
model = (IHierarchicalNodeModel)modelFactory.getLayoutModel(topology);
edgeModel = model.getEdgeModel();
applyLayoutMLConfiguration(model, layoutML);
// Build layout
layoutFactory = new Neo4jLayoutFactory(typeModel);
if (layoutML != null) {
Map<String, String> mapping = extractModelLayoutMapping(layoutML);
layoutFactory.setModelLayoutMapping(mapping);
}
layout = layoutFactory.getLayout(model);
layout.getEdgeLayout().setEdgePostProcess(null);
// finalize workspace
annotationModel = new AnnotationModel();
metadata = null;
setName(settings.getName());
loadMapIfExist();
this.configuration = new ConfigurationFacade(this);
}
示例8: export
import org.neo4j.tooling.GlobalGraphOperations; //导入方法依赖的package包/类
@Override
public Optional<Dataset> export() throws DMPGraphException {
tx.ensureRunningTx();
try {
/*
* // all nodes would also return endnodes without further outgoing relations final Iterable<Node> recordNodes;
* GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(database); recordNodes =
* globalGraphOperations.getAllNodes();
*/
final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(database);
// TODO: maybe slice this a bit, and deliver the whole graph in pieces
final Iterable<Relationship> relations = globalGraphOperations.getAllRelationships();
if (relations == null) {
tx.succeedTx();
return Optional.absent();
}
dataset = DatasetFactory.createMem();
for (final Relationship recordNode : relations) {
relationshipHandler.handleRelationship(recordNode);
}
// please also note that the Jena model implementation has its size limits (~1 mio statements (?) -> so one graph
// (of
// one data resource) need to keep this size in mind)
if (BaseRDFExporter.JENA_MODEL_WARNING_SIZE == successfullyProcessedStatements) {
GraphRDFExporter.LOG.warn("reached {} statements. This is approximately the jena model implementation size limit.",
BaseRDFExporter.JENA_MODEL_WARNING_SIZE);
}
tx.succeedTx();
} catch (final Exception e) {
final String mesage = "couldn't finish read RDF TX successfully";
tx.failTx();
GraphRDFExporter.LOG.error(mesage, e);
throw new DMPGraphException(mesage);
}
return Optional.fromNullable(dataset);
}