当前位置: 首页>>代码示例>>Java>>正文


Java GlobalGraphOperations.at方法代码示例

本文整理汇总了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;
	}
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:18,代码来源:Neo4JDatabase.java

示例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();
	}
}
 
开发者ID:5agado,项目名称:knowledge-extraction,代码行数:30,代码来源:Neo4JDb.java

示例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<>();
}
 
开发者ID:technige,项目名称:zerograph,代码行数:9,代码来源:Database.java

示例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;
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:30,代码来源:Neo4jWorkspace.java

示例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);
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:30,代码来源:Neo4jNodeTypeAnalysis.java

示例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);
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:8,代码来源:TrialTestNeo4jTopologyEditorEmbeddedDb.java

示例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);
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:71,代码来源:Neo4jWorkspace.java

示例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);
}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:56,代码来源:GraphRDFExporter.java


注:本文中的org.neo4j.tooling.GlobalGraphOperations.at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。