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


Java Relationship.setProperty方法代码示例

本文整理汇总了Java中org.neo4j.graphdb.Relationship.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Relationship.setProperty方法的具体用法?Java Relationship.setProperty怎么用?Java Relationship.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.neo4j.graphdb.Relationship的用法示例。


在下文中一共展示了Relationship.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public final Relationship add(RelationshipType type, Node tail, Node head, double prob) {
	if (null == type)
		throw new IllegalArgumentException("Illegal 'type' argument in Problem.add(RelationshipType, Node, Node, double): " + type);
	if (null == tail)
		throw new IllegalArgumentException("Illegal 'tail' argument in Problem.add(RelationshipType, Node, Node, double): " + tail);
	if (null == head)
		throw new IllegalArgumentException("Illegal 'head' argument in Problem.add(RelationshipType, Node, Node, double): " + head);
	if (prob < 0.0 || prob > 1.0)
		throw new IllegalArgumentException("Illegal 'prob' argument in Problem.add(RelationshipType, Node, Node, double): " + prob);
	Relationship result = null;
	try (Transaction tx = graph.beginTx()) {
		result = tail.createRelationshipTo(head, type);
		result.setProperty("prob", prob);
		count += 1;
		tx.success();
	}
	return result;
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:19,代码来源:Problem.java

示例2: putEdge

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
/**
 * This function inserts the given edge into the underlying storage(s) and
 * updates the cache(s) accordingly.
 *
 * @param incomingEdge edge to insert into the storage
 * @return returns true if the insertion is successful. Insertion is considered
 * not successful if the edge is already present in the storage.
 */
@Override
public boolean putEdge(AbstractEdge incomingEdge)
{
    String hashCode = incomingEdge.bigHashCode();
    if (Cache.isPresent(hashCode))
        return true;

    globalTxCheckin();
    Node srcNode = graphDb.findNode(NodeTypes.VERTEX, PRIMARY_KEY,
            incomingEdge.getChildVertex().bigHashCode());
    Node dstNode = graphDb.findNode(NodeTypes.VERTEX, PRIMARY_KEY,
            incomingEdge.getParentVertex().bigHashCode());
    Relationship newEdge = srcNode.createRelationshipTo(dstNode, RelationshipTypes.EDGE);
    newEdge.setProperty(PRIMARY_KEY, hashCode);
    for (Map.Entry<String, String> currentEntry : incomingEdge.getAnnotations().entrySet())
    {
        String key = currentEntry.getKey();
        String value = currentEntry.getValue();
        newEdge.setProperty(key, value);
    }

    return true;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:32,代码来源:Neo4j.java

示例3: createRelationship

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
/**
 * 
 * @param properties
 * @param labels
 * @return
 */
public static long createRelationship(long startNodeId, long endNodeId, RelationshipType relationshipType, Map<String, Object> properties)
{
  GraphDatabaseService graphDatabaseService = getGraphDatabaseService();

  Node startNode = graphDatabaseService.getNodeById(startNodeId);
  Node endNode = graphDatabaseService.getNodeById(endNodeId);

  Relationship relationship = startNode.createRelationshipTo(endNode, relationshipType);

  for (String key : properties.keySet())
  {
    relationship.setProperty(key, properties.get(key));
  }

  return relationship.getId();
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:23,代码来源:Neo4ArtGraphDatabaseServiceSingleton.java

示例4: populate

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public void populate() {
	if (null == graph)
		throw new IllegalStateException("Illegal state for 'graph' attribute in Propoli.populate(): the db is not connected");
	try (Transaction tx = graph.beginTx()) {
		Node node_a = graph.createNode(LABEL);
		node_a.setProperty(ID, "a");
		Node node_b = graph.createNode(LABEL);
		node_b.setProperty(ID, "b");
		Node node_c = graph.createNode(LABEL);
		node_c.setProperty(ID, "c");

		Relationship relationship;
		relationship = node_a.createRelationshipTo(node_b, RelTypes.LINKS);
		relationship.setProperty(ID, 2);
		relationship.setProperty(PROB, 0.5);
		relationship = node_b.createRelationshipTo(node_c, RelTypes.LINKS);
		relationship.setProperty(ID, 3);
		relationship.setProperty(PROB, 0.4);
		relationship = node_a.createRelationshipTo(node_c, RelTypes.LINKS);
		relationship.setProperty(ID, 4);
		relationship.setProperty(PROB, 0.5);

		root = node_a;
		done = node_c;
		tx.success();
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:28,代码来源:BiDiDi.java

示例5: createEdge

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public EdgeWrapper createEdge(long id, int weight, long startNode, long endNode) {
	Node firstNode = getInnerNode(startNode);
	Node secondNode = getInnerNode(endNode);

	Relationship rel = firstNode.createRelationshipTo(secondNode, KNOWS);
	indexRelationship.add(rel, GraphProperties.REL, KNOWS.name());
	rel.setProperty(GraphProperties.ID, id);
	rel.setProperty(GraphProperties.WEIGHT, weight);

	return new EdgeDB(rel);
}
 
开发者ID:rrocharoberto,项目名称:GraphPartitionFramework,代码行数:13,代码来源:GraphDB.java

示例6: createEdge

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public Relationship createEdge(long idEdge, int newWeight, long startNode, long endNode) {
	Node firstNode = indexName.get(GraphProperties.ID, startNode).getSingle();
	Node secondNode = indexName.get(GraphProperties.ID, endNode).getSingle();

	Relationship rel = firstNode.createRelationshipTo(secondNode, KNOWS);
	indexRelationship.add(rel, GraphProperties.REL, KNOWS.name());
	rel.setProperty(GraphProperties.ID, idEdge);
	rel.setProperty(GraphProperties.WEIGHT, newWeight);

	return rel;
}
 
开发者ID:rrocharoberto,项目名称:GraphPartitionFramework,代码行数:12,代码来源:GrafoNeoDB.java

示例7: testRelationshipAutoIndexFromAPISanity

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void testRelationshipAutoIndexFromAPISanity()
{
    final String propNameToIndex = "test";
    AutoIndexer<Relationship> autoIndexer = graphDb.index().getRelationshipAutoIndexer();
    autoIndexer.startAutoIndexingProperty( propNameToIndex );
    autoIndexer.setEnabled( true );
    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    Node node3 = graphDb.createNode();

    Relationship rel12 = node1.createRelationshipTo( node2,
            DynamicRelationshipType.withName( "DYNAMIC" ) );
    Relationship rel23 = node2.createRelationshipTo( node3,
            DynamicRelationshipType.withName( "DYNAMIC" ) );

    rel12.setProperty( propNameToIndex, "rel12" );
    rel23.setProperty( propNameToIndex, "rel23" );

    newTransaction();

    assertEquals(
            rel12,
            autoIndexer.getAutoIndex().get( propNameToIndex,
                    "rel12" ).getSingle() );
    assertEquals(
            rel23,
            autoIndexer.getAutoIndex().get( propNameToIndex,
                    "rel23" ).getSingle() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:33,代码来源:TestAutoIndexing.java

示例8: testDefaultsAreSeparateForNodesAndRelationships

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void testDefaultsAreSeparateForNodesAndRelationships()
        throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "propName" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    // Now only node properties named propName should be indexed.
    startDb();

    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.setProperty( "propName", "node1" );
    node2.setProperty( "propName", "node2" );
    node2.setProperty( "propName_", "node2" );

    Relationship rel = node1.createRelationshipTo( node2,
            DynamicRelationshipType.withName( "DYNAMIC" ) );
    rel.setProperty( "propName", "rel1" );

    newTransaction();

    ReadableIndex<Node> autoIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex();
    assertEquals( node1, autoIndex.get( "propName", "node1" ).getSingle() );
    assertEquals( node2, autoIndex.get( "propName", "node2" ).getSingle() );
    assertFalse( graphDb.index().getRelationshipAutoIndexer().getAutoIndex().get(
            "propName", "rel1" ).hasNext() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestAutoIndexing.java

示例9: testRemoveRelationshipRemovesDocument

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void testRemoveRelationshipRemovesDocument()
{
    AutoIndexer<Relationship> autoIndexer = graphDb.index().getRelationshipAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "foo" );
    autoIndexer.setEnabled( true );

    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    Relationship rel = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "foo" ) );
    rel.setProperty( "foo", "bar" );

    newTransaction();

    assertThat( graphDb.index().forRelationships( "relationship_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 1 ) );

    newTransaction();

    rel.delete();

    newTransaction();

    assertThat( graphDb.index().forRelationships( "relationship_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 0 ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:29,代码来源:TestAutoIndexing.java

示例10: create

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Procedure(name = "com.maxdemarzi.rules.create", mode = Mode.WRITE)
@Description("CALL com.maxdemarzi.rules.create(id, formula) - create a rule")
public Stream<StringResult> create(@Name("id") String id, @Name("formula") String formula) throws IOException {
    // See if the rule already exists
    Node rule = db.findNode(Labels.Rule, "id", id);
    if (rule == null) {
        // Create the rule
        rule = db.createNode(Labels.Rule);
        rule.setProperty("id", id);
        rule.setProperty("formula", formula);

        // Use the expression to find the required paths
        BooleanExpression boEx = new BooleanExpression(formula);
        boEx.doTabulationMethod();
        boEx.doQuineMcCluskey();
        boEx.doPetricksMethod();

        // Create a relationship from the lead attribute node to the path nodes
        for (String path : boEx.getPathExpressions()) {
            Node pathNode = db.findNode(Labels.Path, "id", path);
            if (pathNode == null) {
                // Create the path node if it doesn't already exist
                pathNode = db.createNode(Labels.Path);
                pathNode.setProperty("id", path);

                // Create the attribute nodes if they don't already exist
                String[] attributes = path.split("[!&]");
                for (int i = 0; i < attributes.length; i++) {
                    String attributeId = attributes[i];
                    Node attribute = db.findNode(Labels.Attribute, "id", attributeId);
                    if (attribute == null) {
                        attribute = db.createNode(Labels.Attribute);
                        attribute.setProperty("id", attributeId);
                    }
                    // Create the relationship between the lead attribute node to the path node
                    if (i == 0) {
                        Relationship inPath = attribute.createRelationshipTo(pathNode, RelationshipTypes.IN_PATH);
                        inPath.setProperty("path", path);
                    }
                }

            }

            // Create a relationship between the path and the rule
            pathNode.createRelationshipTo(rule, RelationshipTypes.HAS_RULE);
        }
    }

    return Stream.of(new StringResult("Rule " + formula + " created."));
}
 
开发者ID:maxdemarzi,项目名称:rule_matcher,代码行数:51,代码来源:Rules.java

示例11: buildRelation

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) {
	String relationName = buildRelationName(parent, child, context);
	
	RelationshipType type = RelationshipType.withName( relationName );
	
	//check if already exists
	Iterable<Relationship> relationships = child.getRelationships(Direction.INCOMING,type);
	
	Relationship relationship;

	//find only relation between parent and child node
	List<Relationship> rels = StreamSupport.stream(relationships.spliterator(), false)
			.filter(rel -> rel.getStartNode().getId() == parent.getId())
			.collect(Collectors.toList());

	if(rels.isEmpty())
	{
		relationship = parent.createRelationshipTo(child, type);
		if(log.isDebugEnabled())
			log.debug("Create new Relation "+relationship);
	}else
	{
		relationship = rels.get(0);
		if(log.isDebugEnabled())
			log.debug("Update Relation "+relationship);
	}

	//manage array of keys
	
	String[] keys = new String[0];
	
	//create property if doesn't exists (new relation)
	if(relationship.getAllProperties().containsKey(DOC_KEYS))
	{
		keys = (String[]) relationship.getProperty(DOC_KEYS);
	}
	
	//set document key into property
	String documentKey = context.getDocumentKey();
	if(! ArrayUtils.contains(keys, documentKey))
	{
		keys = ArrayUtils.add(keys, documentKey);			
		relationship.setProperty(DOC_KEYS, keys);
	}
	
	
	return relationship;
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:50,代码来源:DocumentRelationBuilderTypeArrayKey.java

示例12: createEdge

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Edge createEdge(int weight, long startNode, long endNode) {
    Edge edge = null;
    long id = 0;
    try {
        beginTransaction();

        Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.INDEX DESC LIMIT 1");
        Iterator<Relationship> edges = result.columnAs("r");
        if (edges.hasNext()) {
            id = ((int) edges.next().getId()) + 1;
        }

        result = graphDb.execute("MATCH (a:NODE{INDEX:" + startNode + "})-[r:LINK]-(b:NODE{INDEX:" + endNode + "}) RETURN r ORDER BY r.INDEX DESC LIMIT 1");
        edges = result.columnAs("r");
        if (!edges.hasNext()) {
            Node firstNode = getInnerNode(startNode);
            Node secondNode = getInnerNode(endNode);

            result = graphDb.execute("MATCH (a:NODE{INDEX:" + startNode + "}), (b:NODE{INDEX:" + endNode + "}) "
                    + "CREATE (a)-[r:LINK]->(b) "
                    + "RETURN r");

            Iterator<Relationship> n_column = result.columnAs("r");
            Relationship rel = null;
            for (Relationship r : IteratorUtil.asIterable(n_column)) {
                rel = r;
            }
            rel.setProperty(NetworkNeo4jProperties.INDEX, id);
            rel.setProperty(NetworkNeo4jProperties.WEIGHT, weight);

            Vertex v1 = getVertex(startNode);
            Vertex v2 = getVertex(endNode);

            edge = new Edge(id, weight, v1, v2);
        }

    } finally {
        endTransaction();
    }

    return edge;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:44,代码来源:NetworkNeo4j.java

示例13: createNodespace

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public void createNodespace() {
	try (Transaction tx = graphDb.beginTx()) {
		// Create matrix node
		Node matrix = graphDb.createNode();
		matrixNodeId = matrix.getId();

		// Create Neo
		Node thomas = graphDb.createNode();
		thomas.setProperty("name", "Thomas Anderson");
		thomas.setProperty("age", 29);

		// connect Neo/Thomas to the matrix node
		matrix.createRelationshipTo(thomas, RelTypes.NEO_NODE);

		Node trinity = graphDb.createNode();
		trinity.setProperty("name", "Trinity");
		Relationship rel = thomas.createRelationshipTo(trinity, RelTypes.KNOWS);
		rel.setProperty("age", "3 days");
		Node morpheus = graphDb.createNode();
		morpheus.setProperty("name", "Morpheus");
		morpheus.setProperty("rank", "Captain");
		morpheus.setProperty("occupation", "Total badass");
		thomas.createRelationshipTo(morpheus, RelTypes.KNOWS);
		rel = morpheus.createRelationshipTo(trinity, RelTypes.KNOWS);
		rel.setProperty("age", "12 years");
		Node cypher = graphDb.createNode();
		cypher.setProperty("name", "Cypher");
		cypher.setProperty("last name", "Reagan");
		trinity.createRelationshipTo(cypher, RelTypes.KNOWS);
		rel = morpheus.createRelationshipTo(cypher, RelTypes.KNOWS);
		rel.setProperty("disclosure", "public");
		Node smith = graphDb.createNode();
		smith.setProperty("name", "Agent Smith");
		smith.setProperty("version", "1.0b");
		smith.setProperty("language", "C++");
		rel = cypher.createRelationshipTo(smith, RelTypes.KNOWS);
		rel.setProperty("disclosure", "secret");
		rel.setProperty("age", "6 months");
		Node architect = graphDb.createNode();
		architect.setProperty("name", "The Architect");
		smith.createRelationshipTo(architect, RelTypes.CODED_BY);

		tx.success();
	}
}
 
开发者ID:stefano-bragaglia,项目名称:NeoDD,代码行数:46,代码来源:Quel.java

示例14: setUpDb

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@BeforeClass
public static void setUpDb()
{
    graphDb = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
    try ( Transaction tx = graphDb.beginTx() )
    {
        // START SNIPPET: createIndexes
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        Index<Node> movies = index.forNodes( "movies" );
        RelationshipIndex roles = index.forRelationships( "roles" );
        // END SNIPPET: createIndexes

        // START SNIPPET: createNodes
        // Actors
        Node reeves = graphDb.createNode();
        reeves.setProperty( "name", "Keanu Reeves" );
        actors.add( reeves, "name", reeves.getProperty( "name" ) );
        Node bellucci = graphDb.createNode();
        bellucci.setProperty( "name", "Monica Bellucci" );
        actors.add( bellucci, "name", bellucci.getProperty( "name" ) );
        // multiple values for a field, in this case for search only
        // and not stored as a property.
        actors.add( bellucci, "name", "La Bellucci" );
        // Movies
        Node theMatrix = graphDb.createNode();
        theMatrix.setProperty( "title", "The Matrix" );
        theMatrix.setProperty( "year", 1999 );
        movies.add( theMatrix, "title", theMatrix.getProperty( "title" ) );
        movies.add( theMatrix, "year", theMatrix.getProperty( "year" ) );
        Node theMatrixReloaded = graphDb.createNode();
        theMatrixReloaded.setProperty( "title", "The Matrix Reloaded" );
        theMatrixReloaded.setProperty( "year", 2003 );
        movies.add( theMatrixReloaded, "title", theMatrixReloaded.getProperty( "title" ) );
        movies.add( theMatrixReloaded, "year", 2003 );
        Node malena = graphDb.createNode();
        malena.setProperty( "title", "Malèna" );
        malena.setProperty( "year", 2000 );
        movies.add( malena, "title", malena.getProperty( "title" ) );
        movies.add( malena, "year", malena.getProperty( "year" ) );
        // END SNIPPET: createNodes

        // START SNIPPET: createRelationships
        // we need a relationship type
        DynamicRelationshipType ACTS_IN = DynamicRelationshipType.withName( "ACTS_IN" );
        // create relationships
        Relationship role1 = reeves.createRelationshipTo( theMatrix, ACTS_IN );
        role1.setProperty( "name", "Neo" );
        roles.add( role1, "name", role1.getProperty( "name" ) );
        Relationship role2 = reeves.createRelationshipTo( theMatrixReloaded, ACTS_IN );
        role2.setProperty( "name", "Neo" );
        roles.add( role2, "name", role2.getProperty( "name" ) );
        Relationship role3 = bellucci.createRelationshipTo( theMatrixReloaded, ACTS_IN );
        role3.setProperty( "name", "Persephone" );
        roles.add( role3, "name", role3.getProperty( "name" ) );
        Relationship role4 = bellucci.createRelationshipTo( malena, ACTS_IN );
        role4.setProperty( "name", "Malèna Scordia" );
        roles.add( role4, "name", role4.getProperty( "name" ) );
        // END SNIPPET: createRelationships

        tx.success();
    }

    try ( Transaction tx = graphDb.beginTx() )
    {
        String title = "Movie and Actor Graph";
        try ( PrintWriter pw = AsciiDocGenerator.getPrintWriter( "target/docs/dev", title ) )
        {
            pw.println( AsciidocHelper.createGraphVizDeletingReferenceNode( title, graphDb, "initial" ) );
            pw.flush();
        }
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:74,代码来源:ImdbDocTest.java

示例15: populateGraph

import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
static void populateGraph(GraphDatabaseService graphDb) {
  try (Transaction tx = graphDb.beginTx()) {
    Relationship r1 = addRelationship("http://x.org/a_a", "http://x.org/a_b", OwlRelationships.RDFS_SUBCLASS_OF);
    Relationship r2 = addRelationship("http://x.org/a_b", "http://x.org/a_c", OwlRelationships.RDFS_SUBCLASS_OF);
    Relationship r3 = addRelationship("http://x.org/a_c", "http://x.org/a_d", OwlRelationships.RDF_TYPE);
    Relationship r4 = addRelationship("http://x.org/a_e", "http://x.org/a_d", RelationshipType.withName("CAUSES"));
    Relationship r5 = addRelationship("http://x.org/a_f", "http://x.org/a_e", RelationshipType.withName("partOf"));
    graph.setRelationshipProperty(r4.getId(), CommonProperties.IRI, "http://x.org/a_causes");
    addRelationship("http://x.org/a_causes_parent", "http://x.org/a_causes", OwlRelationships.RDFS_SUB_PROPERTY_OF);
    addRelationship("_:anon", "http://x.org/a_b", OwlRelationships.RDFS_SUBCLASS_OF);
    r1.getEndNode().setProperty(NodeProperties.LABEL, "A");
    r2.getStartNode().setProperty(NodeProperties.LABEL, "C");
    a = r1.getEndNode();
    b = r2.getEndNode();
    c = r2.getStartNode();
    d = r3.getStartNode();
    e = r4.getEndNode();
    f = r5.getEndNode();
    Node assn = createNode("http://x.org/a_assn");
    Node assnParent = createNode("http://x.org/a_assn_parent");
    assn.createRelationshipTo(assnParent, OwlRelationships.RDFS_SUBCLASS_OF);
    Node evidence = createNode("http://x.org/a_evidence");
    assn.createRelationshipTo(evidence, RelationshipType.withName("http://purl.obolibrary.org/obo/RO_0002558"));
    assn.createRelationshipTo(d, RelationshipType.withName("http://purl.org/oban/association_has_subject"));
    assn.createRelationshipTo(e, RelationshipType.withName("http://purl.org/oban/association_has_object"));
    
    Node gene = createNode("http://x.org/gene");
    gene.addLabel(Label.label("gene"));
    Node ortholog = createNode("http://x.org/gene_ortholog");
    ortholog.addLabel(Label.label("gene"));
    gene.createRelationshipTo(ortholog, RelationshipType.withName("http://purl.obolibrary.org/obo/RO_HOM0000017"));

    Node foo = createNode("http://x.org/gene");
    foo.addLabel(Label.label("gene"));

    Node forebrain = createNode("http://purl.obolibrary.org/obo/UBERON_0001890");
    forebrain.addLabel(Label.label("forebrain"));
    forebrain.addLabel(Label.label("anatomical entity"));
    Relationship foo2forebrain = foo.createRelationshipTo(forebrain, RelationshipType.withName("http://purl.obolibrary.org/obo/RO_0002206"));
    foo2forebrain.setProperty(CommonProperties.IRI, "http://purl.obolibrary.org/obo/RO_0002206");

    Node brain = createNode("http://purl.obolibrary.org/obo/UBERON_0000955");
    brain.addLabel(Label.label("brain"));
    brain.addLabel(Label.label("anatomical entity"));
    Relationship forebrain2brain = forebrain.createRelationshipTo(brain, RelationshipType.withName("http://purl.obolibrary.org/obo/BFO_0000050"));
    forebrain2brain.setProperty(CommonProperties.IRI, "http://purl.obolibrary.org/obo/BFO_0000050");

    Node neuralTube = createNode("http://purl.obolibrary.org/obo/UBERON_0001049");
    neuralTube.addLabel(Label.label("neural tube"));
    neuralTube.addLabel(Label.label("anatomical entity"));
    Relationship brain2neuralTube = brain.createRelationshipTo(neuralTube, RelationshipType.withName("http://purl.obolibrary.org/obo/RO_0002202"));
    brain2neuralTube.setProperty(CommonProperties.IRI, "http://purl.obolibrary.org/obo/RO_0002202");

    Node head = createNode("http://purl.obolibrary.org/obo/UBERON_0000033");
    head.addLabel(Label.label("head"));
    head.addLabel(Label.label("anatomical entity"));
    Relationship brain2head = brain.createRelationshipTo(head, RelationshipType.withName("http://purl.obolibrary.org/obo/BFO_0000050"));
    brain2head.setProperty(CommonProperties.IRI, "http://purl.obolibrary.org/obo/BFO_0000050");

    Node bodyPart = createNode("http://x.org/body_part");
    bodyPart.addLabel(Label.label("body part"));
    bodyPart.addLabel(Label.label("anatomical entity"));
    Relationship head2bodyPart = head.createRelationshipTo(bodyPart, OwlRelationships.RDFS_SUBCLASS_OF);
    head2bodyPart.setProperty(CommonProperties.IRI, OwlRelationships.RDFS_SUBCLASS_OF.name());

    Node anatomicalEntity = createNode("http://purl.obolibrary.org/obo/UBERON_0001062");
    anatomicalEntity.addLabel(Label.label("anatomical entity"));
    Relationship bodyPart2anatomicalEntity = bodyPart.createRelationshipTo(anatomicalEntity, OwlRelationships.RDFS_SUBCLASS_OF);
    bodyPart2anatomicalEntity.setProperty(CommonProperties.IRI, OwlRelationships.RDFS_SUBCLASS_OF.name());

    tx.success();
  }
}
 
开发者ID:SciGraph,项目名称:golr-loader,代码行数:74,代码来源:GolrLoadSetup.java


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