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


Java Relationship类代码示例

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


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

示例1: getChildrenConnectedBy

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
public static List<Node> getChildrenConnectedBy(Node node, String edgeType)
{
	List<Node> retval = new LinkedList<Node>();

	long nodeId = node.getId();

	Iterable<Relationship> rels = node.getRelationships();
	for (Relationship rel : rels)
	{
		if (!rel.getType().name().equals(edgeType))
			continue;
		Node childNode = rel.getEndNode();
		if (childNode.getId() == nodeId)
			continue;

		retval.add(childNode);
	}
	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Traversals.java

示例2: getParentsConnectedBy

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
public static List<Node> getParentsConnectedBy(Node node, String edgeType)
{
	List<Node> retval = new LinkedList<Node>();

	long nodeId = node.getId();

	Iterable<Relationship> rels = node.getRelationships();
	for (Relationship rel : rels)
	{
		if (!rel.getType().name().equals(edgeType))
			continue;
		Node parentNode = rel.getStartNode();
		if (parentNode.getId() == nodeId)
			continue;

		retval.add(parentNode);
	}
	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Traversals.java

示例3: getDDGForFunction

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
public static DDG getDDGForFunction(Node funcNode)
{
	DDG retval = new DDG();
	for (Node statement : Traversals.getStatementsForFunction(funcNode))
	{
		Iterable<Relationship> rels = statement
				.getRelationships(Direction.OUTGOING);
		long srcId = statement.getId();

		for (Relationship rel : rels)
		{
			if (!rel.getType().toString().equals(EdgeTypes.REACHES))
				continue;
			long dstId = rel.getEndNode().getId();
			String symbol = rel.getProperty("var").toString();
			retval.add(srcId, dstId, symbol);
		}

	}
	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:22,代码来源:Traversals.java

示例4: alternatingOrder

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
static ArrayList<Node> alternatingOrder (Node order) {
    ArrayList<Node> products = new ArrayList<>();
    Relationship prevRel = order.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
    if (prevRel != null) {
        Node prevOrder = prevRel.getEndNode();
        prevRel = prevOrder.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
        if (prevRel != null) {
            prevOrder = prevRel.getEndNode();
            for (Relationship r1 : prevOrder.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
                Node product = r1.getEndNode();
                products.add(product);
            }
        }
    }
    return products;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:17,代码来源:Predictions.java

示例5: diffFromCurrent

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Procedure(value = "graph.versioner.diff.from.current", mode = DEFAULT)
@Description("graph.versioner.diff.from.current(state) - Get a list of differences that must be applied to the given state in order to become the current entity state")
public Stream<DiffOutput> diffFromCurrent(
		@Name("state") Node state) {

	Optional<Node> currentState = Optional.ofNullable(state.getSingleRelationship(RelationshipType.withName(Utility.HAS_STATE_TYPE), Direction.INCOMING))
			.map(Relationship::getStartNode).map(entity -> entity.getSingleRelationship(RelationshipType.withName(Utility.CURRENT_TYPE), Direction.OUTGOING))
			.map(Relationship::getEndNode);

	Stream<DiffOutput> result = Stream.empty();

	if(currentState.isPresent() && !currentState.equals(Optional.of(state))){
		result = diffBetweenStates(Optional.of(state), currentState);
	}

	return result;
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:18,代码来源:Diff.java

示例6: jMenuItem2ActionPerformed

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    // TODO add your handling code here:
    try (Transaction tx = db.beginTx()) {
        Node vols = db.createNode(Main.Tables.Vol);
        Node avions = db.createNode(Main.Tables.Avion);
        Node departs = db.createNode(Main.Tables.Depart);
        Node passagers = db.createNode(Main.Tables.Passager);
        Node personnels = db.createNode(Main.Tables.Personnel);
        Node naviguants = db.createNode(Main.Tables.Naviguant);
        Node nonNaviguants = db.createNode(Main.Tables.NonNaviguant);
        Node pilotes = db.createNode(Main.Tables.Pilote);
        Node quantiteAvion = db.createNode(Main.Tables.QuantiteAvion);
        Relationship constituer = vols.createRelationshipTo(departs, Relations.Constituer);
        Relationship enregistrer = passagers.createRelationshipTo(departs, Relations.Enregistrer);
        Relationship affecterPersonnel = personnels.createRelationshipTo(departs, Relations.AffecterPersonnel);
        Relationship affecterAvion = avions.createRelationshipTo(departs, Relations.AffecterAvion);
    }
}
 
开发者ID:ATF19,项目名称:flight-management-system-java,代码行数:19,代码来源:MainWindow.java

示例7: matchUser

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Procedure(name = "com.maxdemarzi.match.user", mode = Mode.READ)
@Description("CALL com.maxdemarzi.match.user(username) - find matching rules")
public Stream<NodeResult> matchUser(@Name("username") String username) throws IOException {
    // We start by finding the user
    Node user = db.findNode(Labels.User, "username", username);
    if (user != null) {
        // Gather all of their attributes in to a Set
        Set<Node> userAttributes = new HashSet<>();
        Collection<String> attributes = new HashSet<>();

        for (Relationship r : user.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
            userAttributes.add(r.getEndNode());
            attributes.add((String)r.getEndNode().getProperty("id"));
        }
        // Find the rules
        Set<Node> rules = findRules(attributes, userAttributes);
        return rules.stream().map(NodeResult::new);
    }

    return null;
}
 
开发者ID:maxdemarzi,项目名称:rule_matcher,代码行数:22,代码来源:Matcher.java

示例8: validates_supported_simple_types

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Test
public void validates_supported_simple_types()
{
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( String.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Number.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Long.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.LONG ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Double.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.DOUBLE ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Boolean.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( TypeKind.BOOLEAN ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Path.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Node.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Relationship.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Object.class ) ) ).isTrue();
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:17,代码来源:TypeValidationTestSuite.java

示例9: validates_supported_generic_types

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Test
public void validates_supported_generic_types()
{
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( Map.class, String.class, Object.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( HashMap.class, String.class, Object.class ) ) )
            .isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( LinkedHashMap.class, String.class, Object.class ) ) )
            .isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, String.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( LinkedList.class, Number.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( ArrayList.class, Long.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Double.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Boolean.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Path.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Node.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Relationship.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils().typeOf( List.class, Object.class ) ) ).isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils()
            .typeOf( List.class, typeMirrorTestUtils().typeOf( Map.class, String.class, Object.class ) ) ) )
            .isTrue();
    assertThat( visitor().visit( typeMirrorTestUtils()
            .typeOf( List.class, typeMirrorTestUtils().typeOf( LinkedList.class, Long.class ) ) ) ).isTrue();
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:24,代码来源:TypeValidationTestSuite.java

示例10: supported_simple_type_is_valid

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Test
public void supported_simple_type_is_valid()
{
    assertThat( validator.test( typeMirrorTestUtils.typeOf( BOOLEAN ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( LONG ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( DOUBLE ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Boolean.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Long.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Double.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( String.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Number.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Object.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Node.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Relationship.class ) ) ).isTrue();
    assertThat( validator.test( typeMirrorTestUtils.typeOf( Path.class ) ) ).isTrue();
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:17,代码来源:AllowedTypesValidatorTest.java

示例11: accept

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Override
public <R, E extends Throwable> R accept(Visitor<R, E> visitor) throws E {
    //filternodes:
    for (Node node : nodes) {
        visitor.visitNode(node);
        for (Relationship relationship : node.getRelationships(Direction.OUTGOING)) {
            if (nodes.contains(relationship.getOtherNode(node))) {

                if (!relationshipLabels.contains(relationship.getType().name())) {
                    continue;
                }

                visitor.visitRelationship(relationship);
            }
        }
    }
    return visitor.done();
}
 
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:19,代码来源:CfgWalker.java

示例12: accept

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Override
public <R, E extends Throwable> R accept(Visitor<R, E> visitor) throws E {
    for (Node node : dbServices.getAllNodes()) {
        if (node.hasLabel(Label.label("CompilationUnit"))) {
            continue;
        }
        if (node.hasLabel(Label.label("SourceSpan"))) {
            continue;
        }
        if (node.hasLabel(Label.label("SourceLocation"))) {
            continue;
        }

        visitor.visitNode(node);
        for (Relationship edge : node.getRelationships(Direction.OUTGOING)) {
            if (edge.isType(RelationshipType.withName("location"))) {
                continue;
            }
            visitor.visitRelationship(edge);
        }
    }
    return visitor.done();
}
 
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:24,代码来源:SimpleWalker.java

示例13: deleteRelations

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Override
public Set<Node> deleteRelations(DocumentRelationContext context) {
	Set<Node> orphans = new HashSet<>();

	String documentKey = context.getDocumentKey();
	if(StringUtils.isBlank(documentKey))
	{
		return orphans;
	}
	
	Result result = db.execute("MATCH (p)-[r:"+documentKey+"]->(c) RETURN r");
	result.forEachRemaining((res)->{
		Relationship rel = (Relationship) res.get("r");
		Node parent = rel.getStartNode();
		Node child = rel.getEndNode();
		rel.delete();
		if(log.isDebugEnabled())
		{
			log.debug("Delete relation "+rel);
		}
		updateOrphans(orphans, parent);
		updateOrphans(orphans, child);
	});
	
	return orphans;
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:27,代码来源:DocumentRelationBuilderByKey.java

示例14: shuldCreateRelation

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Test
public void shuldCreateRelation() {
	context.setDocumentKey("key");
	
	Node parent = db.createNode();
	parent.setProperty("type", "album");
	
	Node child = db.createNode();
	child.setProperty("type", "artist");
	
	Relationship rel = this.docrel.buildRelation(parent, child, context);

	Assert.assertEquals(parent.getId(), rel.getStartNode().getId());
	Assert.assertEquals(child.getId(), rel.getEndNode().getId());
	Assert.assertEquals("key", rel.getType().name());

}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:18,代码来源:DocumentRelationBuilderByKeyTest.java

示例15: shuldAddRelation

import org.neo4j.graphdb.Relationship; //导入依赖的package包/类
@Test
public void shuldAddRelation() {
	context.setDocumentKey("key1");
	
	Node parent = db.createNode();
	parent.setProperty("type", "album");
	
	Node child = db.createNode();
	child.setProperty("type", "artist");
	
	Relationship rel1 = this.docrel.buildRelation(parent, child, context);

	context.setDocumentKey("key2");
	Relationship rel2 = this.docrel.buildRelation(parent, child, context);
	
	Assert.assertNotEquals(rel1.getId(), rel2.getId());
	
	Assert.assertEquals("key1", rel1.getType().name());
	Assert.assertEquals("key2", rel2.getType().name());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:21,代码来源:DocumentRelationBuilderByKeyTest.java


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