org.neo4j.graphdb.Relationship.removeProperty()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.neo4j.graphdb.Relationship.removeProperty方法的一些代码示例,展示了Relationship.removeProperty的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Relationship.removeProperty方法的具体详情如下:
包路径:org.neo4j.graphdb.Relationship
类名称:Relationship
方法名:removeProperty

Relationship.removeProperty介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

public void removeRelationshipProperty( long relationshipId, String key )
    throws RelationshipNotFoundException, NoSuchPropertyException
{
  Relationship relationship = relationship( relationshipId );
  if ( relationship.removeProperty( key ) == null )
  {
    throw new NoSuchPropertyException( relationship, key );
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
  void perform( Graph graph, ExpectedTransactionData expectations )
  {
    Relationship relationship = graph.randomRelationship();
    if ( relationship != null )
    {
      String key = graph.randomPropertyKey();
      if ( relationship.hasProperty( key ) )
      {
        Object valueBefore = relationship.removeProperty( key );
        expectations.removedProperty( relationship, key, valueBefore );
        debug( relationship + " " + key + "=" + valueBefore );
      }
    }
  }
},

代码示例来源:origin: neo4j/neo4j

if ( rel1.removeProperty( key1 ) != null )
  rel1.removeProperty( null );
  fail( "Remove null property should throw exception." );
try
  rel1.removeProperty( null );
  fail( "Null argument should result in exception." );
assertEquals( int1, rel1.removeProperty( key1 ) );
assertEquals( string1, rel2.removeProperty( key1 ) );
  if ( rel2.removeProperty( key1 ) != null )

代码示例来源:origin: neo4j/neo4j

@Test
public void testNodeRemoveProperty()
{
  Node node1 = getGraphDb().getNodeById( node1Id );
  Node node2 = getGraphDb().getNodeById( node2Id );
  Relationship rel = node1.getSingleRelationship( MyRelTypes.TEST,
    Direction.BOTH );
  // test remove property
  assertEquals( 1, node1.removeProperty( key1 ) );
  assertEquals( 2, node2.removeProperty( key1 ) );
  assertEquals( 1, rel.removeProperty( key1 ) );
  assertEquals( string1, node1.removeProperty( key2 ) );
  assertEquals( string2, node2.removeProperty( key2 ) );
  assertEquals( string1, rel.removeProperty( key2 ) );
  assertNotNull( node1.removeProperty( arrayKey ) );
  assertNotNull( node2.removeProperty( arrayKey ) );
  assertNotNull( rel.removeProperty( arrayKey ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void testChangeProperty()
{
  Node node1 = getGraphDb().createNode();
  Node node2 = getGraphDb().createNode();
  Relationship rel = node1.createRelationshipTo( node2, TEST );
  rel.setProperty( "test", "test1" );
  newTransaction();
  rel.setProperty( "test", "test2" );
  rel.removeProperty( "test" );
  rel.setProperty( "test", "test3" );
  assertEquals( "test3", rel.getProperty( "test" ) );
  rel.removeProperty( "test" );
  rel.setProperty( "test", "test4" );
  newTransaction();
  assertEquals( "test4", rel.getProperty( "test" ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void testRelationshipChangeProperty2()
{
  Integer int1 = 1;
  Integer int2 = 2;
  String string1 = "1";
  String string2 = "2";
  Node node1 = getGraphDb().createNode();
  Node node2 = getGraphDb().createNode();
  Relationship rel1 = node1.createRelationshipTo( node2, TEST );
  rel1.setProperty( key1, int1 );
  rel1.setProperty( key1, int2 );
  assertEquals( int2, rel1.getProperty( key1 ) );
  rel1.removeProperty( key1 );
  rel1.setProperty( key1, string1 );
  rel1.setProperty( key1, string2 );
  assertEquals( string2, rel1.getProperty( key1 ) );
  rel1.removeProperty( key1 );
  rel1.setProperty( key1, true );
  rel1.setProperty( key1, false );
  assertEquals( false, rel1.getProperty( key1 ) );
  rel1.removeProperty( key1 );
  rel1.delete();
  node2.delete();
  node1.delete();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void testChangeProperty2()
{
  // Create relationship with "test"="test1"
  Node node1 = getGraphDb().createNode();
  Node node2 = getGraphDb().createNode();
  Relationship rel = node1.createRelationshipTo( node2, TEST );
  rel.setProperty( "test", "test1" );
  newTransaction(); // commit
  // Remove "test" and set "test"="test3" instead
  rel.removeProperty( "test" );
  rel.setProperty( "test", "test3" );
  assertEquals( "test3", rel.getProperty( "test" ) );
  newTransaction(); // commit
  // Remove "test" and set "test"="test4" instead
  assertEquals( "test3", rel.getProperty( "test" ) );
  rel.removeProperty( "test" );
  rel.setProperty( "test", "test4" );
  newTransaction(); // commit
  // Should still be "test4"
  assertEquals( "test4", rel.getProperty( "test" ) );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void testRelMultiRemoveProperty()
{
  Node node1 = getGraphDb().createNode();
  Node node2 = getGraphDb().createNode();
  Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST );
  rel.setProperty( "key0", "0" );
  rel.setProperty( "key1", "1" );
  rel.setProperty( "key2", "2" );
  rel.setProperty( "key3", "3" );
  rel.setProperty( "key4", "4" );
  newTransaction();
  rel.removeProperty( "key3" );
  rel.removeProperty( "key2" );
  rel.removeProperty( "key3" );
  newTransaction();
  assertEquals( "0", rel.getProperty( "key0" ) );
  assertEquals( "1", rel.getProperty( "key1" ) );
  assertEquals( "4", rel.getProperty( "key4" ) );
  assertTrue( !rel.hasProperty( "key2" ) );
  assertTrue( !rel.hasProperty( "key3" ) );
  rel.delete();
  node1.delete();
  node2.delete();
}

代码示例来源:origin: neo4j/neo4j

@Test
public void testRemovePropertyDeletedRelationship()
{
  Node node1 = getGraphDb().createNode();
  Node node2 = getGraphDb().createNode();
  Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST );
  rel.setProperty( key, 1 );
  rel.delete();
  try
  {
    rel.removeProperty( key );
    Transaction tx = getTransaction();
    tx.success();
    tx.close();
    fail( "Remove property on deleted rel should not validate" );
  }
  catch ( Exception e )
  {
    // ok
  }
  node1.delete();
  node2.delete();
}

代码示例来源:origin: neo4j/neo4j

rel1.removeProperty( key3 );

代码示例来源:origin: neo4j/neo4j

@Test
public void queryResultsMustNotIncludeRelationshipsWithRemovedIndexedProperties()
{
  db = createDatabase();
  try ( Transaction tx = db.beginTx() )
  {
    createSimpleRelationshipIndex();
    tx.success();
  }
  long relId;
  try ( Transaction tx = db.beginTx() )
  {
    awaitIndexesOnline();
    Node node = db.createNode();
    Relationship rel = node.createRelationshipTo( node, REL );
    rel.setProperty( PROP, "value" );
    relId = rel.getId();
    tx.success();
  }
  try ( Transaction tx = db.beginTx() )
  {
    db.getRelationshipById( relId ).removeProperty( PROP );
    assertQueryFindsIds( db, false, "rels", "value" );
    tx.success();
  }
}

代码示例来源:origin: neo4j/neo4j

expectedData.expectedDeletedRelationships.add( rel2 );
rel1.removeProperty( "number" );
expectedData.removedProperty( rel1, "number", 4.5D );
rel1.setProperty( "description", "Ignored" );

代码示例来源:origin: neo4j/neo4j

@Test
public void queryResultsMustIncludeOldRelationshipPropertyValuesWhenRemovalsAreUndone()
{
  db = createDatabase();
  try ( Transaction tx = db.beginTx() )
  {
    createSimpleRelationshipIndex();
    tx.success();
  }
  long relId;
  try ( Transaction tx = db.beginTx() )
  {
    awaitIndexesOnline();
    Node node = db.createNode();
    Relationship rel = node.createRelationshipTo( node, REL );
    rel.setProperty( PROP, "primo" );
    relId = rel.getId();
    tx.success();
  }
  try ( Transaction tx = db.beginTx() )
  {
    Relationship rel = db.getRelationshipById( relId );
    assertQueryFindsIds( db, false, "rels", "primo", relId );
    rel.removeProperty( PROP );
    assertQueryFindsIds( db, false, "rels", "primo" );
    rel.setProperty( PROP, "primo" );
    assertQueryFindsIds( db, false, "rels", "primo", relId );
    tx.success();
  }
}

代码示例来源:origin: neo4j/neo4j

relationship.removeProperty( testPropertyKey );
tx.success();

代码示例来源:origin: neo4j/neo4j

relationship.removeProperty( testPropertyKey );
tx.success();

代码示例来源:origin: neo4j/neo4j

onRandomRelationship( nodes, relationship -> relationship.removeProperty( randomKey() ) );

代码示例来源:origin: neo4j/neo4j

assertEquals( j * 10 + i, rel.removeProperty( "int" + ( j * 10 + i ) ) );
if ( i == PropertyType.getPayloadSize() - 1 && j != propRecCount - 1 )

代码示例来源:origin: neo4j/neo4j

rel1.removeProperty( "key1" );
fail( "Should throw exception" );
rel1.removeProperty( "key1" );
fail( "Should throw exception" );

代码示例来源:origin: neo4j/neo4j

rel.removeProperty( "key1" );
fail( "Write operation and no transaction should throw exception" );

代码示例来源:origin: org.neo4j/neo4j-remote-graphdb

Object removeRelationshipProperty( GraphDatabaseService graphDb, long relationshipId,
  String key )
{
  return graphDb.getRelationshipById( relationshipId ).removeProperty( key );
}

相关文章