{
prevRel.setSecondNextRel( rel.getFirstNextRel() );
}
else
{
throw new InvalidRecordException(
prevRel + " don't match " + rel );
}
}
// update first node next
if ( rel.getFirstNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue() )
{
Relationship lockableRel = new LockableRelationship(
rel.getFirstNextRel() );
getWriteLock( lockableRel );
RelationshipRecord nextRel = getRelationshipRecord(
rel.getFirstNextRel() );
if ( nextRel == null )
{
nextRel = getRelationshipStore().getRecord(
rel.getFirstNextRel() );
addRelationshipRecord( nextRel );
}
if ( nextRel.getFirstNode() == rel.getFirstNode() )
{
nextRel.setFirstPrevRel( rel.getFirstPrevRel() );
}
else if ( nextRel.getSecondNode() == rel.getFirstNode() )
{
nextRel.setSecondPrevRel( rel.getFirstPrevRel() );
}
else
{
throw new InvalidRecordException( nextRel + " don't match "
+ rel );
}
}
// update second node prev
if ( rel.getSecondPrevRel() != Record.NO_NEXT_RELATIONSHIP.intValue() )
{
Relationship lockableRel = new LockableRelationship(
rel.getSecondPrevRel() );
getWriteLock( lockableRel );
RelationshipRecord prevRel = getRelationshipRecord(
rel.getSecondPrevRel() );
if ( prevRel == null )
{
prevRel = getRelationshipStore().getRecord(
rel.getSecondPrevRel() );
addRelationshipRecord( prevRel );
}
if ( prevRel.getFirstNode() == rel.getSecondNode() )
{
prevRel.setFirstNextRel( rel.getSecondNextRel() );
}
else if ( prevRel.getSecondNode() == rel.getSecondNode() )
{
prevRel.setSecondNextRel( rel.getSecondNextRel() );
}
else
{
throw new InvalidRecordException( prevRel + " don't match " +
rel );
}
}
// update second node next
if ( rel.getSecondNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue() )
{
Relationship lockableRel = new LockableRelationship(
rel.getSecondNextRel() );
getWriteLock( lockableRel );
RelationshipRecord nextRel = getRelationshipRecord(
rel.getSecondNextRel() );
if ( nextRel == null )
{
nextRel = getRelationshipStore().getRecord(
rel.getSecondNextRel() );
addRelationshipRecord( nextRel );
}
if ( nextRel.getFirstNode() == rel.getSecondNode() )
{
nextRel.setFirstPrevRel( rel.getSecondPrevRel() );
}
else if ( nextRel.getSecondNode() == rel.getSecondNode() )
{
nextRel.setSecondPrevRel( rel.getSecondPrevRel() );
}
else
{
throw new InvalidRecordException( nextRel + " don't match " +
rel );
}
}
}