Java Code Examples for org.neo4j.graphdb.RelationshipType#withName()
The following examples show how to use
org.neo4j.graphdb.RelationshipType#withName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSubClassOfExistential.java From SciGraph with Apache License 2.0 | 6 votes |
/** * 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()))); }
Example 2
Source File: TestPun.java From SciGraph with Apache License 2.0 | 6 votes |
@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))); }
Example 3
Source File: AbstractEmbeddedNeo4jDatastore.java From extended-objects with Apache License 2.0 | 6 votes |
@Override public DatastoreMetadataFactory<NodeMetadata<EmbeddedLabel>, EmbeddedLabel, RelationshipMetadata<EmbeddedRelationshipType>, EmbeddedRelationshipType> getMetadataFactory() { return new AbstractNeo4jMetadataFactory<EmbeddedLabel, EmbeddedRelationshipType>() { protected EmbeddedLabel createLabel(String value) { return new EmbeddedLabel(value); } protected EmbeddedRelationshipType createRelationshipType(String name) { return new EmbeddedRelationshipType(RelationshipType.withName(name)); } @Override protected boolean isBatchableDefault() { return false; } }; }
Example 4
Source File: GraphOwlVisitor.java From SciGraph with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: OwlPostprocessor.java From SciGraph with Apache License 2.0 | 5 votes |
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(); } }
Example 6
Source File: DirectedRelationshipTypeTest.java From SciGraph with Apache License 2.0 | 5 votes |
@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(); }
Example 7
Source File: TestAnnotationAssertionObject.java From SciGraph with Apache License 2.0 | 5 votes |
@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()))); }
Example 8
Source File: TestObjectPropertyAssertion.java From SciGraph with Apache License 2.0 | 5 votes |
@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)); }
Example 9
Source File: TestEquivalentToIntersectionOf.java From SciGraph with Apache License 2.0 | 5 votes |
@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()))); }
Example 10
Source File: TestExistentialClassAssertion.java From SciGraph with Apache License 2.0 | 5 votes |
@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"))); }
Example 11
Source File: Neo4jGraphSerializer.java From trainbenchmark with Eclipse Public License 1.0 | 4 votes |
public RelationshipType relationship(final String label) { return RelationshipType.withName(label); }
Example 12
Source File: DirectedRelationshipType.java From SciGraph with Apache License 2.0 | 4 votes |
@JsonCreator public DirectedRelationshipType(@JsonProperty("type") String type, @JsonProperty("direction") String direction) { this.type = RelationshipType.withName(type); this.direction = Direction.valueOf(direction); }