當前位置: 首頁>>代碼示例>>Java>>正文


Java RelationshipType.withName方法代碼示例

本文整理匯總了Java中org.neo4j.graphdb.RelationshipType.withName方法的典型用法代碼示例。如果您正苦於以下問題:Java RelationshipType.withName方法的具體用法?Java RelationshipType.withName怎麽用?Java RelationshipType.withName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.neo4j.graphdb.RelationshipType的用法示例。


在下文中一共展示了RelationshipType.withName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveRelationships

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
private Set<DirectedRelationshipType> resolveRelationships(String key, String value) {
  Set<DirectedRelationshipType> rels = new HashSet<>();
  String cypherIn = String.format("[%s:%s]", key, value);
  String cypherOut = cypherUtil.resolveRelationships(cypherIn);
  Matcher m = ENTAILMENT_PATTERN.matcher(cypherOut);
  while (m.find()) {
    String types = m.group(2);
    String[] cypherRels = types.split("\\|");
    for (String cypherRel : cypherRels) {
      String unquotedCypherRel = cypherRel.replaceAll("^`|`$","");
      RelationshipType relType = RelationshipType.withName(unquotedCypherRel);
      DirectedRelationshipType dirRelType = new DirectedRelationshipType(relType, Direction.OUTGOING);
      rels.add(dirRelType);
    }
  }
  return rels;
}
 
開發者ID:SciGraph,項目名稱:golr-loader,代碼行數:18,代碼來源:GolrLoader.java

示例2: testSubclass

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
/**
 * See https://github.com/SciCrunch/SciGraph/wiki/MappingToOWL#subclassof-axioms
 * 
 * Reduction step should give us a simple edge {sub p super}
 */
@Test
public void testSubclass() {
  Node subclass = getNode("http://example.org/subclass");
  Node superclass = getNode("http://example.org/superclass");

  RelationshipType p = RelationshipType.withName("http://example.org/p");
  Relationship relationship = getOnlyElement(GraphUtil.getRelationships(subclass, superclass, p));
  assertThat("subclassOf relationship should start with the subclass.",
      relationship.getStartNode(), is(subclass));
  assertThat("subclassOf relationship should end with the superclass.",
      relationship.getEndNode(), is(superclass));
  assertThat("relationship has the correct iri",
      GraphUtil.getProperty(relationship, CommonProperties.IRI, String.class),
      is(Optional.of("http://example.org/p")));
  assertThat("relationship is asserted",
      GraphUtil.getProperty(relationship, CommonProperties.CONVENIENCE, Boolean.class),
      is(Optional.of(true)));
  assertThat("owltype is added",
      GraphUtil.getProperty(relationship, CommonProperties.OWL_TYPE, String.class),
      is(Optional.of(OwlRelationships.RDFS_SUBCLASS_OF.name())));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:27,代碼來源:TestSubClassOfExistential.java

示例3: testPun

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void testPun() {
  Node i = getNode("http://example.org/i");
  Node j = getNode("http://example.org/j");
  Node k = getNode("http://example.org/k");

  RelationshipType p = RelationshipType.withName("http://example.org/p");
  Relationship relationship = getOnlyElement(GraphUtil.getRelationships(i, j, p));
  assertThat("OPE edge should start with the subject.", relationship.getStartNode(), is(i));
  assertThat("OPE edge should end with the target.", relationship.getEndNode(), is(j));
  relationship = getOnlyElement(GraphUtil.getRelationships(i, k, OwlRelationships.RDFS_SUBCLASS_OF));
  assertThat("Subclass edge should start with i.", relationship.getStartNode(), is(i));
  assertThat("Subclass edge should end with k.", relationship.getEndNode(), is(k));
  assertThat("i is both a class an a named individual" , i.getLabels(), 
      is(IsIterableContainingInAnyOrder.containsInAnyOrder(OwlLabels.OWL_CLASS, OwlLabels.OWL_NAMED_INDIVIDUAL)));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:17,代碼來源:TestPun.java

示例4: buildRelation

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Override
public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) {
	String documentKey = context.getDocumentKey();
	if(StringUtils.isBlank(documentKey))
	{
		return null;
	}
	
	RelationshipType relationType = RelationshipType.withName( documentKey );
	
	//check if already exists
	Iterable<Relationship> relationships = child.getRelationships(Direction.INCOMING,relationType);
	
	//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());

	Relationship relationship;
	
	if(rels.isEmpty())
	{
		relationship = parent.createRelationshipTo(child, relationType);
		if(log.isDebugEnabled())
			log.debug("Create new Relation "+relationship);
	}else
	{
		relationship = rels.get(0);
		if(log.isDebugEnabled())
			log.debug("Update Relation "+relationship);
	}
	
	return relationship;
}
 
開發者ID:larusba,項目名稱:doc2graph,代碼行數:35,代碼來源:DocumentRelationBuilderByKey.java

示例5: getObjectPropertyRelationship

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
long getObjectPropertyRelationship(
    OWLPropertyAssertionAxiom<OWLObjectPropertyExpression, OWLIndividual> axiom) {
  long subject = getOrCreateNode(getIri(axiom.getSubject()));
  String property = getIri(axiom.getProperty());
  long object = getOrCreateNode(getIri(axiom.getObject()));
  RelationshipType type = RelationshipType.withName(property.toString());

  long relationship = getOrCreateRelationship(subject, object, type);
  graph.setRelationshipProperty(relationship, CommonProperties.IRI, property.toString());
  return relationship;
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:12,代碼來源:GraphOwlVisitor.java

示例6: processSomeValuesFrom

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
public void processSomeValuesFrom() {
  logger.info("Processing someValuesFrom classes");
  try (Transaction tx = graphDb.beginTx()) {
    Result results =
        graphDb.execute("MATCH (n)-[relationship]->(svf:someValuesFrom)-[:property]->(p) "
            + "RETURN n, relationship, svf, p");
    while (results.hasNext()) {
      Map<String, Object> result = results.next();
      Node subject = (Node) result.get("n");
      Relationship relationship = (Relationship) result.get("relationship");
      Node svf = (Node) result.get("svf");
      Node property = (Node) result.get("p");
      for (Relationship r : svf.getRelationships(OwlRelationships.FILLER)) {
        Node object = r.getEndNode();
        String relationshipName =
            GraphUtil.getProperty(property, CommonProperties.IRI, String.class).get();
        RelationshipType type = RelationshipType.withName(relationshipName);
        String propertyUri =
            GraphUtil.getProperty(property, CommonProperties.IRI, String.class).get();
        Relationship inferred = subject.createRelationshipTo(object, type);
        inferred.setProperty(CommonProperties.IRI, propertyUri);
        inferred.setProperty(CommonProperties.CONVENIENCE, true);
        inferred.setProperty(CommonProperties.OWL_TYPE, relationship.getType().name());
      }
    }
    tx.success();
    tx.close();
  }
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:30,代碼來源:OwlPostprocessor.java

示例7: verifyEquals

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void verifyEquals() {
  RelationshipType foo = RelationshipType.withName("foo");
  RelationshipType bar = RelationshipType.withName("bar");
  EqualsVerifier.forClass(DirectedRelationshipType.class)
  .withPrefabValues(RelationshipType.class, foo, bar)
  .suppress(Warning.NULL_FIELDS).verify();
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:9,代碼來源:DirectedRelationshipTypeTest.java

示例8: testAnnotationAssertion

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void testAnnotationAssertion() {
  Node i = getNode("http://example.org/i");
  Node j = getNode("http://example.org/j");

  RelationshipType p = RelationshipType.withName("http://example.org/p");
  Relationship relationship = getOnlyElement(GraphUtil.getRelationships(i, j, p));
  assertThat("OPE edge should start with the subject.", relationship.getStartNode(), is(i));
  assertThat("OPE edge should start with the target.", relationship.getEndNode(), is(j));
  assertThat(GraphUtil.getProperty(relationship, CommonProperties.OWL_TYPE, String.class),
      is(Optional.of(OwlRelationships.OWL_ANNOTATION.name())));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:13,代碼來源:TestAnnotationAssertionObject.java

示例9: testObjectPropertyAssertion

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void testObjectPropertyAssertion() {
  Node i = getNode("http://example.org/i");
  Node j = getNode("http://example.org/j");

  RelationshipType p = RelationshipType.withName("http://example.org/p");
  Relationship relationship = getOnlyElement(GraphUtil.getRelationships(i, j, p));
  assertThat("OPE edge should start with the subject.", relationship.getStartNode(), is(i));
  assertThat("OPE edge should start with the target.", relationship.getEndNode(), is(j));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:11,代碼來源:TestObjectPropertyAssertion.java

示例10: testEquivalentToIntersectionOf

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void testEquivalentToIntersectionOf() {
  Node anonymousClass = graphDb.findNodes(OwlLabels.OWL_INTERSECTION_OF).next();
  Node fillerClass = getNode("http://example.org/fillerClass");

  RelationshipType p = RelationshipType.withName("http://example.org/p");
  Relationship r = getOnlyElement(GraphUtil.getRelationships(anonymousClass, fillerClass, p));

  assertThat(GraphUtil.getProperty(r, CommonProperties.CONVENIENCE, Boolean.class),
      is(Optional.of(true)));
  assertThat(GraphUtil.getProperty(r, CommonProperties.OWL_TYPE, String.class),
      is(Optional.of(OwlRelationships.OPERAND.name())));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:14,代碼來源:TestEquivalentToIntersectionOf.java

示例11: testSubclass

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@Test
public void testSubclass() {
  Node i = getNode("http://example.org/i");
  Node c = getNode("http://example.org/c");
  RelationshipType p = RelationshipType.withName("http://example.org/p");

  Relationship r = getOnlyElement(GraphUtil.getRelationships(i, c, p, true));
  assertThat(GraphUtil.getProperty(r, CommonProperties.CONVENIENCE, Boolean.class),
      is(Optional.of(true)));
  assertThat(GraphUtil.getProperty(r, CommonProperties.OWL_TYPE, String.class),
      is(Optional.of("type")));
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:13,代碼來源:TestExistentialClassAssertion.java

示例12: buildRelation

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的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

示例13: relationship

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
public RelationshipType relationship(final String label) {
	return RelationshipType.withName(label);
}
 
開發者ID:FTSRG,項目名稱:trainbenchmark,代碼行數:4,代碼來源:Neo4jGraphSerializer.java

示例14: DirectedRelationshipType

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
@JsonCreator
public DirectedRelationshipType(@JsonProperty("type") String type, @JsonProperty("direction") String direction) {
  this.type = RelationshipType.withName(type);
  this.direction = Direction.valueOf(direction);
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:6,代碼來源:DirectedRelationshipType.java

示例15: getRelationshipType

import org.neo4j.graphdb.RelationshipType; //導入方法依賴的package包/類
public RelationshipType getRelationshipType(String relatedEntityName){
	return RelationshipType.withName(relatedEntityName);
}
 
開發者ID:EsfingeFramework,項目名稱:querybuilder,代碼行數:4,代碼來源:MappingInfo.java


注:本文中的org.neo4j.graphdb.RelationshipType.withName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。