本文整理汇总了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;
}
示例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())));
}
示例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)));
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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())));
}
示例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));
}
示例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())));
}
示例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")));
}
示例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;
}
示例13: relationship
import org.neo4j.graphdb.RelationshipType; //导入方法依赖的package包/类
public RelationshipType relationship(final String label) {
return RelationshipType.withName(label);
}
示例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);
}
示例15: getRelationshipType
import org.neo4j.graphdb.RelationshipType; //导入方法依赖的package包/类
public RelationshipType getRelationshipType(String relatedEntityName){
return RelationshipType.withName(relatedEntityName);
}