本文整理了Java中org.neo4j.graphdb.Relationship.delete
方法的一些代码示例,展示了Relationship.delete
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Relationship.delete
方法的具体详情如下:
包路径:org.neo4j.graphdb.Relationship
类名称:Relationship
方法名:delete
[英]Deletes this relationship. Invoking any methods on this relationship after delete()
has returned is invalid and will lead to NotFoundException being thrown.
[中]删除此关系。在delete()
返回后调用此关系上的任何方法无效,并将导致引发NotFoundException。
代码示例来源:origin: neo4j/neo4j
private void deleteAlistairAndStefanNodes()
{
try ( Transaction tx = graphDb.beginTx() )
{
aKnowsS.delete();
sKnowsA.delete();
alistair.delete();
stefan.delete();
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void canCreateRelationshipBetweenTwoNodesWithLoopsThenDeleteOneOfTheNodesAndItsRelationships()
{
Node source = getGraphDb().createNode();
Node target = getGraphDb().createNode();
source.createRelationshipTo( source, TEST );
target.createRelationshipTo( target, TEST );
source.createRelationshipTo( target, TEST );
newTransaction();
for ( Relationship rel : target.getRelationships() )
{
rel.delete();
}
target.delete();
}
代码示例来源:origin: neo4j/neo4j
@Test( expected = NotFoundException.class )
public void deletionOfAlreadyDeletedRelationshipShouldThrow()
{
// Given
GraphDatabaseService db = getGraphDb();
// transaction is opened by test
Node node1 = db.createNode();
Node node2 = db.createNode();
Relationship relationship = node1.createRelationshipTo( node2, TEST );
commit();
try ( Transaction tx = db.beginTx() )
{
relationship.delete();
tx.success();
}
// When
try ( Transaction tx = db.beginTx() )
{
relationship.delete();
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAdvertiseRelationshipTypesThatCurrentlyExistInTheDatabase() throws Throwable
{
try ( Transaction tx = db.beginTx() )
{
db.getRelationshipById( relId ).delete();
tx.success();
}
Database database = new WrappedDatabase( db );
DatabaseMetadataService service = new DatabaseMetadataService( database );
try ( Transaction tx = db.beginTx() )
{
Response response = service.getRelationshipTypes( false );
assertEquals( 200, response.getStatus() );
List<Map<String,Object>> jsonList = JsonHelper.jsonToList( response.getEntity()
.toString() );
assertEquals( 3, jsonList.size() );
}
database.stop();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void canDeleteNodeAfterDeletingItsRelationshipsIfThoseRelationshipsIncludeLoops()
{
Node node = getGraphDb().createNode();
txCreateLoop( node );
txCreateRel( node );
txCreateLoop( node );
for ( Relationship rel : node.getRelationships() )
{
rel.delete();
}
node.delete();
commit();
}
代码示例来源:origin: neo4j/neo4j
d = graphDb.createNode();
a.createRelationshipTo( a, withName( "ALPHA" ) );
a.createRelationshipTo( b, withName( "BETA" ) );
a.createRelationshipTo( c, withName( "GAMMA" ) );
a.createRelationshipTo( d, withName( "DELTA" ) );
dead.delete();
node.delete();
代码示例来源:origin: neo4j/neo4j
private void testGetRelationshipTypes( Node node, Set<String> expectedTypes )
{
assertExpectedRelationshipTypes( expectedTypes, node, false );
node.createRelationshipTo( getGraphDb().createNode(), RelType.TYPE1 );
expectedTypes.add( RelType.TYPE1.name() );
assertExpectedRelationshipTypes( expectedTypes, node, false );
node.createRelationshipTo( getGraphDb().createNode(), RelType.TYPE1 );
assertExpectedRelationshipTypes( expectedTypes, node, true );
Relationship rel = node.createRelationshipTo( getGraphDb().createNode(), RelType.TYPE2 );
expectedTypes.add( RelType.TYPE2.name() );
assertExpectedRelationshipTypes( expectedTypes, node, false );
rel.delete();
expectedTypes.remove( RelType.TYPE2.name() );
assertExpectedRelationshipTypes( expectedTypes, node, true );
node.createRelationshipTo( getGraphDb().createNode(), RelType.TYPE2 );
node.createRelationshipTo( getGraphDb().createNode(), RelType.TYPE2 );
expectedTypes.add( RelType.TYPE2.name() );
node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST );
expectedTypes.add( MyRelTypes.TEST.name() );
assertExpectedRelationshipTypes( expectedTypes, node, true );
for ( Relationship r : node.getRelationships( RelType.TYPE1 ) )
{
assertExpectedRelationshipTypes( expectedTypes, node, false );
r.delete();
}
expectedTypes.remove( RelType.TYPE1.name() );
assertExpectedRelationshipTypes( expectedTypes, node, true );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testDeletedRelationship()
{
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship relationship = node1.createRelationshipTo( node2, TEST );
relationship.delete();
try
{
relationship.setProperty( "key1", 1 );
fail( "Adding property to deleted rel should throw exception." );
}
catch ( Exception e )
{ // good
}
node1.delete();
node2.delete();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAllowToStringOnCreatedRelationshipInAfterCommit()
relationship = startNode.createRelationshipTo( endNode, type );
tx.success();
try ( Transaction tx = dbRule.beginTx() )
relationship.delete();
tx.success();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAdvertiseRelationshipTypesThatCurrentlyInUseInTheDatabase() throws Throwable
{
try ( Transaction tx = db.beginTx() )
{
db.getRelationshipById( relId ).delete();
tx.success();
}
Database database = new WrappedDatabase( db );
DatabaseMetadataService service = new DatabaseMetadataService( database );
try ( Transaction tx = db.beginTx() )
{
Response response = service.getRelationshipTypes( true );
assertEquals( 200, response.getStatus() );
List<Map<String,Object>> jsonList = JsonHelper.jsonToList( response.getEntity()
.toString() );
assertEquals( 2, jsonList.size() );
}
database.stop();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void createBatchNodeAndRelationshipsDeleteAllInEmbedded() throws Exception
{
/*
* ()--[REL_TYPE1]-->(node)--[BATCH_TEST]->()
*/
BatchInserter inserter = newBatchInserter();
long nodeId = inserter.createNode( null );
inserter.createRelationship( nodeId, inserter.createNode( null ),
RelTypes.BATCH_TEST, null );
inserter.createRelationship( inserter.createNode( null ), nodeId,
RelTypes.REL_TYPE1, null );
// Delete node and all its relationships
GraphDatabaseService db = switchToEmbeddedGraphDatabaseService( inserter );
try ( Transaction tx = db.beginTx() )
{
Node node = db.getNodeById( nodeId );
for ( Relationship relationship : node.getRelationships() )
{
relationship.delete();
}
node.delete();
tx.success();
}
db.shutdown();
}
代码示例来源:origin: neo4j/neo4j
private static void delete( Node node )
{
for ( Relationship rel : node.getRelationships() )
{
rel.delete();
}
node.delete();
}
代码示例来源:origin: neo4j/neo4j
for ( int i = 0; i < initialSize; i++ )
me.createRelationshipTo( getGraphDb().createNode(), RelType.INITIAL );
me.createRelationshipTo( otherNode, spec.type );
otherNode.createRelationshipTo( me, spec.type );
if ( !otherNode.equals( me ) )
otherNode.delete();
rel.delete();
me.delete();
代码示例来源:origin: neo4j/neo4j
d = graphDb.createNode(), e = graphDb.createNode(), f = graphDb.createNode();
a.createRelationshipTo( b, withName( "CIRCLE" ) );
b.createRelationshipTo( c, withName( "CIRCLE" ) );
one = c.createRelationshipTo( d, withName( "CIRCLE" ) ).getId();
d.createRelationshipTo( e, withName( "CIRCLE" ) );
e.createRelationshipTo( f, withName( "CIRCLE" ) );
try ( Transaction tx = graphDb.beginTx() )
deleted.delete();
for ( Relationship relationship : graphDb.getAllRelationships() )
代码示例来源:origin: neo4j/neo4j
@Test
public void testMultipleDeleteRelationship()
{
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST );
rel.delete();
node1.delete();
node2.delete();
try
{
rel.delete();
Transaction tx = getTransaction();
tx.success();
tx.close();
fail( "Should not validate" );
}
catch ( Exception e )
{
// ok
}
}
代码示例来源:origin: neo4j/neo4j
@Test( expected = NotFoundException.class )
public void deletionOfSameRelationshipTwiceInOneTransactionShouldNotRollbackIt()
Relationship relationship = node1.createRelationshipTo( node2, TEST );
commit();
relationship.delete();
try
relationship.delete();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLetDetectedDeadlocksDuringCommitBeThrownInTheirOriginalForm() throws Exception
r2.delete();
t1Tx.success();
try
代码示例来源:origin: neo4j/neo4j
@Test
public void testDeleteReferenceNodeOrLastNodeIsOk()
{
Transaction tx = getTransaction();
for ( int i = 0; i < 10; i++ )
{
getGraphDb().createNode();
}
// long numNodesPre = getNodeManager().getNumberOfIdsInUse( Node.class
// );
// empty the DB instance
for ( Node node : getGraphDb().getAllNodes() )
{
for ( Relationship rel : node.getRelationships() )
{
rel.delete();
}
node.delete();
}
tx.success();
tx.close();
tx = getGraphDb().beginTx();
assertFalse( getGraphDb().getAllNodes().iterator().hasNext() );
// TODO: this should be valid, fails right now!
// assertEquals( 0, numNodesPost );
tx.success();
tx.close();
}
代码示例来源:origin: neo4j/neo4j
public void clear()
{
for ( Node node : nodes.values() )
{
for ( Relationship relationship : node.getRelationships() )
{
relationship.delete();
}
node.delete();
}
nodes.clear();
nodeNames.clear();
edges.clear();
}
代码示例来源:origin: neo4j/neo4j
.createRelationshipTo( random.among( nodes ), randomRelationshipType() );
if ( random.nextBoolean() )
relationship.delete();
node.delete();
nodes.remove( node );
} );
内容来源于网络,如有侵权,请联系作者删除!