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


Java Neo4j2Graph类代码示例

本文整理汇总了Java中com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph的典型用法代码示例。如果您正苦于以下问题:Java Neo4j2Graph类的具体用法?Java Neo4j2Graph怎么用?Java Neo4j2Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Neo4j2Graph类属于com.tinkerpop.blueprints.impls.neo4j2包,在下文中一共展示了Neo4j2Graph类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: entityRepresentation

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@Override
public Map<String, Object> entityRepresentation(Object entity) {
    Map<String, Object> result = new HashMap<>();
    if (entity instanceof Neo4j2Vertex) {
        result.put(NODE_COLUMN_NAME, ((Neo4j2Vertex) entity).getRawVertex());
        return result;
    } else if (entity instanceof Neo4j2Edge) {
        result.put(EDGE_COLUMN_NAME, ((Neo4j2Edge) entity).getRawEdge());
        return result;
    } else if (entity instanceof Neo4j2Graph) {
        result.put(GRAPH_COLUMN_NAME, ((Neo4j2Graph) entity).getRawGraph().toString());
        return result;
    } else {
        return super.entityRepresentation(entity);
    }
}
 
开发者ID:SMB-TEC,项目名称:xo-neo4j-query,代码行数:17,代码来源:Neo4jGremlinQuery.java

示例2: executeScript

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@Name("execute_script")
@Description("execute a Gremlin script with 'g' set to the Neo4j2Graph and 'results' containing the results. Only results of one object type is supported.")
@PluginTarget(GraphDatabaseService.class)
public Representation executeScript(
        @Source final GraphDatabaseService neo4j,
        @Description("The Gremlin script") @Parameter(name = "script", optional = false) final String script,
        @Description("JSON Map of additional parameters for script variables") @Parameter(name = "params", optional = true) final Map params ) throws BadInputException
{
    Neo4j2Graph neo4jGraph = getOrCreateGremlin( (GraphDatabaseAPI) neo4j );
    try(Transaction tx = neo4j.beginTx())
    {
        engineReplacementDecision.beforeExecution( script );
        final Bindings bindings = createBindings(params, neo4jGraph);
        final Object result = engine().eval( script, bindings );
        Representation representation = GremlinObjectToRepresentationConverter.convert(result);
        tx.success();
        return representation;
    }
    catch ( final Exception e )
    {
     throw new BadInputException( e.getMessage(), e );
    }
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:24,代码来源:GremlinPlugin.java

示例3: getSingleRepresentation

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
static Representation getSingleRepresentation( Object result )
{
    if ( result == null )
    {
        return ObjectToRepresentationConverter.getSingleRepresentation( result );
    }

    if (result instanceof Neo4j2Vertex)
    {
        return new NodeRepresentation( ((Neo4j2Vertex) result).getRawVertex() );
    }
    if ( result instanceof Neo4j2Edge)
    {
        return new RelationshipRepresentation( ((Neo4j2Edge) result).getRawEdge() );
    }
    if ( result instanceof Neo4j2Graph)
    {
        return ValueRepresentation.string( ((Neo4j2Graph) result).getRawGraph().toString() );
    }

    return ObjectToRepresentationConverter.getSingleRepresentation( result );
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:23,代码来源:GremlinObjectToRepresentationConverter.java

示例4: RepositoryRegistry

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
/**
 * Initializes Sesame repository for Neo4j based on Blueprints
 * implementation.
 *
 * @param database Neo4j database service
 * @throws RepositoryException if there was a problem initializing the
 * Sesame repository
 */
private RepositoryRegistry(GraphDatabaseService database)
		throws RepositoryException {
	initRio();
	Graph graph = new Neo4j2Graph(database);
	String patterns = SPARQLExtensionProps.getProperty("query.patterns");
	Sail sail = new GraphSail((KeyIndexableGraph) graph, patterns);
	this.rep = new SailRepository(sail);
	rep.initialize();
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:18,代码来源:RepositoryRegistry.java

示例5: createNeo4jConnection

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
public static SailRepository createNeo4jConnection(String keyspace) throws RepositoryException {
    String path = "tmp/neo4j/" + keyspace;
    File f = new File(path);
    if (f.exists()) {
        f.delete();
    }

    Neo4j2Graph graph = new Neo4j2Graph(path);
    SailRepository sr = new SailRepository(new GraphSail(graph));
    sr.initialize();
    return sr;
}
 
开发者ID:ale003,项目名称:testGraphDbs,代码行数:13,代码来源:App.java

示例6: setUp

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    graph =
            (TransactionalVersionedGraph<?, Long>) new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<Neo4j2Graph, Long>(
                    new Neo4j2Graph(new ImpermanentGraphDatabase()), new LongGraphIdentifierBehavior()).init(true)
                    .build();
    h = graph.getHistoricGraph();

    // vertex1
    vertex1 = (ActiveVersionedVertex) graph.addVertex("foo");
    vertex1Id = (String) vertex1.getId();
    vertex1.setProperty("fooKey1", "foo1");
    vertex1.setProperty("fooKey2", "foo2");
    graph.commit();
    ver1 = graph.getLatestGraphVersion();
    // vertex2
    vertex2 = (ActiveVersionedVertex) graph.addVertex("bar");
    vertex2Id = (String) vertex2.getId();
    vertex2.setProperty("barKey1", "bar1");
    vertex2.setProperty("barKey2", "bar2");
    vertex1.setProperty("fooKey1", "foo1New");
    graph.commit();
    ver2 = graph.getLatestGraphVersion();
    // edge1
    e1 = graph.addEdge(null, vertex1, vertex2, "LINK");
    graph.commit();
    ver3 = graph.getLatestGraphVersion();
    vc1 = vc(h, ver1);
    assertThat(vc1, notNullValue());
    vc2 = vc(h, ver2);
    assertThat(vc2, notNullValue());
    vc3 = vc(h, ver3);
    assertThat(vc3, notNullValue());
}
 
开发者ID:indexiatech,项目名称:antiquity,代码行数:35,代码来源:VersionContextGraphTest.java

示例7: createBindings

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
private Bindings createBindings(Map params, Neo4j2Graph neo4jGraph)
{
    final Bindings bindings = createInitialBinding(neo4jGraph);
    if ( params != null )
    {
        bindings.putAll( params );
    }
    return bindings;
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:10,代码来源:GremlinPlugin.java

示例8: Neo4jGremlinQuery

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
public Neo4jGremlinQuery(Neo4jDatastoreSession session) {
    super(new Neo4j2Graph(session.getGraphDatabaseService()));
}
 
开发者ID:SMB-TEC,项目名称:xo-neo4j-query,代码行数:4,代码来源:Neo4jGremlinQuery.java

示例9: generateGraph

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@Override
protected ActiveVersionedGraph<?, Long> generateGraph() {
    return new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<Neo4j2Graph, Long>(new Neo4j2Graph(
            new ImpermanentGraphDatabase()), new LongGraphIdentifierBehavior()).init(true).conf(null).build();
}
 
开发者ID:indexiatech,项目名称:antiquity,代码行数:6,代码来源:Neo4j2TxLongVersionedGraphTest.java

示例10: simpleSingleEdgeAddTest

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@Test
public void simpleSingleEdgeAddTest() {
    // -- active assertions
    int aAmount = toList(graph.getEdges()).size();
    Vertex v1 = graph.addVertex(null);
    Vertex v2 = graph.addVertex(null);
    Edge e = graph.addEdge(null, v1, v2, "LINK");
    String eId = (String)e.getId();
    CIT();
    V edgeVer = last();
    e.setProperty("key", "foo");
    CIT();
    //hack
    if (graph.getBaseGraph() instanceof Neo4j2Graph) {
        ((Neo4j2Graph)graph.getBaseGraph()).autoStartTransaction(true);
    }
    e = graph.getEdge(eId);
    // query for active before transaction is committed
    assertThat(e, instanceOf(ActiveVersionedEdge.class));
    assertThat(graph.getEdges(), hasAmount(aAmount + 1));

    Edge aE1L = graph.getEdge(e.getId());
    assertThat(aE1L, notNullValue());
    assertThat(aE1L, instanceOf(ActiveVersionedEdge.class));
    assertThat((String) aE1L.getProperty("key"), is("foo"));
    assertThat(e.getProperty("key"), is(graph.getEdge(aE1L.getId()).getProperty("key")));;
    CIT();
    // expect edge to reach its vertices
    assertThat(aE1L.getVertex(Direction.OUT).getId(), is(v1.getId()));
    assertThat(aE1L.getVertex(Direction.IN).getId(), is(v2.getId()));


    // TODO: Assert after commit the elements look just like as before
    // commit
    // expect same behavior after commit too
    assertThat(graph.getEdges(), hasAmount(aAmount + 1));

    // -- historic assertions
    // query historic after transaction committed
    HistoricVersionedEdge<V> hE1L = (HistoricVersionedEdge<V>) graph.getHistoricGraph().getEdge(e.getId());
    assertThat(hE1L, notNullValue());
    assertThat(hE1L, instanceOf(HistoricVersionedEdge.class));
    assertThat((String) hE1L.getProperty("key"), is("foo"));
    assertThat(graph.utils.getVersionRange(hE1L), is(Range.range(edgeVer, graph.getMaxPossibleGraphVersion())));
    assertThat(hE1L.getVersion(), is(Range.range(edgeVer, edgeVer)));
    // not the same instance but ids shell be equal
    assertThat(aE1L.getId(), is(hE1L.getId()));
    // expect edge to reach its vertices
    assertThat(hE1L.getVertex(Direction.OUT).getId(), is(v1.getId()));
    assertThat(hE1L.getVertex(Direction.IN).getId(), is(v2.getId()));
}
 
开发者ID:indexiatech,项目名称:antiquity,代码行数:52,代码来源:VersionedGraphTestSuite.java

示例11: createInitialBinding

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
private Bindings createInitialBinding(Neo4j2Graph neo4jGraph)
{
    final Bindings bindings = new SimpleBindings();
    bindings.put( g, neo4jGraph);
    return bindings;
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:7,代码来源:GremlinPlugin.java

示例12: setUpBeforeClass

import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph; //导入依赖的package包/类
@BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
        json = new OutputFormat( new JsonFormat(),
                new URI( "http://localhost/" ), null );
        neo4j = new ImpermanentGraphDatabase();
        plugin = new GremlinPlugin();
        Graph graph = new Neo4j2Graph( neo4j );
//        graph.clear();
        Vertex marko = graph.addVertex( "0" );
        marko.setProperty( "name", "marko" );
        marko.setProperty( "age", 29 );

        Vertex vadas = graph.addVertex( "1" );
        vadas.setProperty( "name", "vadas" );
        vadas.setProperty( "age", 27 );

        Vertex lop = graph.addVertex( "2" );
        lop.setProperty( "name", "lop" );
        lop.setProperty( "lang", "java" );

        Vertex josh = graph.addVertex( "3" );
        josh.setProperty( "name", "josh" );
        josh.setProperty( "age", 32 );

        Vertex ripple = graph.addVertex( "4" );
        ripple.setProperty( "name", "ripple" );
        ripple.setProperty( "lang", "java" );

        Vertex peter = graph.addVertex( "5" );
        peter.setProperty( "name", "peter" );
        peter.setProperty( "age", 35 );

        graph.addEdge( "6", marko, vadas, "knows" ).setProperty( "weight", 0.5f );
        graph.addEdge( "7", marko, josh, "knows" ).setProperty( "weight", 1.0f );
        graph.addEdge( "8", marko, lop, "created" ).setProperty( "weight", 0.4f );

        graph.addEdge( "9", josh, ripple, "created" ).setProperty( "weight",
                1.0f );
        graph.addEdge( "10", josh, lop, "created" ).setProperty( "weight", 0.4f );

        graph.addEdge( "11", peter, lop, "created" ).setProperty( "weight",
                0.2f );
    }
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:45,代码来源:GremlinPluginTest.java


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