if ( !relRecord.inUse() )
{
throw new IllegalStateException( "Property remove on relationship[" +
relId + "] illegal since it has been deleted." );
}
PropertyRecord propRecord = getPropertyRecord( propertyId );
if ( propRecord == null )
{
propRecord = getPropertyStore().getRecord( propertyId );
addPropertyRecord( propRecord );
}
if ( !propRecord.inUse() )
{
throw new IllegalStateException( "Unable to delete property[" +
propertyId + "] since it is already deleted." );
}
propRecord.setRelId( relId );
if ( propRecord.isLight() )
{
getPropertyStore().makeHeavy( propRecord );
}
propRecord.setInUse( false );
// TODO: update count on property index record
for ( DynamicRecord valueRecord : propRecord.getValueRecords() )
{
if ( valueRecord.inUse() )
{
valueRecord.setInUse( false, propRecord.getType().intValue() );
}
}
long prevProp = propRecord.getPrevProp();
long nextProp = propRecord.getNextProp();
if ( relRecord.getNextProp() == propertyId )
{
relRecord.setNextProp( nextProp );
// re-adding not a problem
addRelationshipRecord( relRecord );
}
if ( prevProp != Record.NO_PREVIOUS_PROPERTY.intValue() )
{
PropertyRecord prevPropRecord = getPropertyRecord( prevProp );
if ( prevPropRecord == null )
{
prevPropRecord = getPropertyStore().getLightRecord( prevProp );
addPropertyRecord( prevPropRecord );
}
assert prevPropRecord.inUse();
prevPropRecord.setNextProp( nextProp );
}
if ( nextProp != Record.NO_NEXT_PROPERTY.intValue() )
{
PropertyRecord nextPropRecord = getPropertyRecord( nextProp );
if ( nextPropRecord == null )
{
nextPropRecord = getPropertyStore().getLightRecord( nextProp );
addPropertyRecord( nextPropRecord );
}
assert nextPropRecord.inUse();
nextPropRecord.setPrevProp( prevProp );
}
}