本文整理汇总了Java中org.neo4j.graphdb.Relationship.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Relationship.delete方法的具体用法?Java Relationship.delete怎么用?Java Relationship.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Relationship
的用法示例。
在下文中一共展示了Relationship.delete方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void activate(final Collection<Neo4jConnectedSegmentsInjectMatch> matches) {
for (final Neo4jConnectedSegmentsInjectMatch match : matches) {
// create (segment2) node
final Node segment2 = driver.getGraphDb().createNode(Neo4jConstants.labelSegment);
segment2.setProperty(ModelConstants.ID, driver.generateNewVertexId());
segment2.setProperty(ModelConstants.LENGTH, TrainBenchmarkConstants.DEFAULT_SEGMENT_LENGTH);
// (segment2)-[:monitoredBy]->(sensor)
segment2.createRelationshipTo(match.getSensor(), Neo4jConstants.relationshipTypeMonitoredBy);
// (segment1)-[:connectsTo]->(segment2)
match.getSegment1().createRelationshipTo(segment2, Neo4jConstants.relationshipTypeConnectsTo);
// (segment2)-[:connectsTo]->(segment3)
segment2.createRelationshipTo(match.getSegment3(), Neo4jConstants.relationshipTypeConnectsTo);
// remove (segment1)-[:connectsTo]->(segment3)
final Iterable<Relationship> connectsToEdges = match.getSegment1().getRelationships(Direction.OUTGOING,
Neo4jConstants.relationshipTypeConnectsTo);
for (final Relationship connectsToEdge : connectsToEdges) {
if (connectsToEdge.getEndNode().equals(match.getSegment3())) {
connectsToEdge.delete();
}
}
}
}
示例2: BDD
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public BDD(Set<Set<Relationship>> expression, Set<Relationship> relationships) {
if (null == relationships)
throw new IllegalArgumentException("Illegal 'relationships' argument in BDD(Set<Set<Relationship>>, Set<Relationship>): " + relationships);
if (null == expression)
throw new IllegalArgumentException("Illegal 'paths' argument in BDD(Set<Set<Relationship>>, Set<Relationship>): " + expression);
try {
File db = Files.createTempDirectory("neo4j_bdd").toFile();
db.deleteOnExit();
this.graph = new GraphDatabaseFactory().newEmbeddedDatabase(db.toString());
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
graph.shutdown();
}
});
try (Transaction tx = graph.beginTx()) {
for (Relationship relationship : GlobalGraphOperations.at(graph).getAllRelationships())
relationship.delete();
for (Node node : GlobalGraphOperations.at(graph).getAllNodes())
node.delete();
this.zero = graph.createNode();
this.zero.setProperty(REFERENCE, "0");
this.one = graph.createNode();
this.one.setProperty(REFERENCE, "1");
this.root = build(expression, relationships);
this.max = 1 + relationships.size();
tx.success();
}
} catch (IOException e) {
throw new IllegalArgumentException("Cannot create a temporary Neo4j db for BDDs...");
}
}
示例3: testNodeLocalRelationshipIndex
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void testNodeLocalRelationshipIndex()
{
RelationshipIndex index = relationshipIndex(
LuceneIndexImplementation.EXACT_CONFIG );
RelationshipType type = DynamicRelationshipType.withName( "YO" );
Node startNode = graphDb.createNode();
Node endNode1 = graphDb.createNode();
Node endNode2 = graphDb.createNode();
Relationship rel1 = startNode.createRelationshipTo( endNode1, type );
Relationship rel2 = startNode.createRelationshipTo( endNode2, type );
index.add( rel1, "name", "something" );
index.add( rel2, "name", "something" );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.query( "name:something" ), contains( rel1, rel2 ) );
assertThat( index.query( "name:something", null, endNode1 ), contains( rel1 ) );
assertThat( index.query( "name:something", startNode, endNode2 ), contains( rel2 ) );
assertThat( index.query( null, startNode, endNode1 ), contains( rel1 ) );
assertThat( index.get( "name", "something", null, endNode1 ), contains( rel1 ) );
assertThat( index.get( "name", "something", startNode, endNode2 ), contains( rel2 ) );
assertThat( index.get( null, null, startNode, endNode1 ), contains( rel1 ) );
restartTx();
}
rel2.delete();
rel1.delete();
startNode.delete();
endNode1.delete();
endNode2.delete();
index.delete();
}
示例4: 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 ) );
}
示例5: deleteFollowing
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void deleteFollowing(Following following) {
Node node = getUserNode(following.getFollower());
for (Relationship r : node.getRelationships(Direction.OUTGOING,
UserRelationship.FOLLOWS)) {
if (r.getEndNode().getProperty(ID_PROPERTY)
.equals(following.getFollowed().getId())) {
r.delete();
return;
}
}
}
示例6: delete
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public <T> void delete(Class<?> clazz, T id) {
Node node = index.getSingleNode(clazz.getName() + ID_SUFFIX, id);
for (Relationship r : node.getRelationships()) {
r.delete();
}
node.delete();
}
示例7: activate
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void activate(final Collection<Neo4jConnectedSegmentsMatch> matches) {
for (final Neo4jConnectedSegmentsMatch match : matches) {
// delete segment2 with all its relationships
final Node segment2 = match.getSegment2();
for (final Relationship relationship : segment2.getRelationships()) {
relationship.delete();
}
segment2.delete();
// (segment1)-[:connectsTo]->(segment3)
match.getSegment1().createRelationshipTo(match.getSegment3(), Neo4jConstants.relationshipTypeConnectsTo);
}
}
示例8: activate
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void activate(final Collection<Neo4jSemaphoreNeighborInjectMatch> matches) {
for (final Neo4jSemaphoreNeighborInjectMatch match : matches) {
final Iterable<Relationship> entries = match.getRoute().getRelationships(Neo4jConstants.relationshipTypeEntry);
for (final Relationship entry : entries) {
if (entry.getEndNode().equals(match.getSemaphore())) {
entry.delete();
}
}
}
}
示例9: activate
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void activate(final Collection<Neo4jRouteSensorInjectMatch> matches) {
for (final Neo4jRouteSensorInjectMatch match : matches) {
final Iterable<Relationship> requiress = match.getRoute().getRelationships(Neo4jConstants.relationshipTypeRequires);
for (final Relationship requires : requiress) {
if (requires.getEndNode().equals(match.getSensor())) {
requires.delete();
}
}
}
}
示例10: activate
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void activate(final Collection<Neo4jSwitchMonitoredInjectMatch> matches) {
for (final Neo4jSwitchMonitoredInjectMatch match : matches) {
final Iterable<Relationship> monitoredBys = match.getSw()
.getRelationships(Neo4jConstants.relationshipTypeMonitoredBy);
for (final Relationship monitoredBy : monitoredBys) {
monitoredBy.delete();
}
}
}
示例11: delete
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public void delete( Relationship entity )
{
entity.delete();
}