Source:
<code>public void updatePlaceInRelationship(Context context, Relationship relationship, boolean isCreation) throws SQLException, AuthorizeException { Item leftItem = relationship.getLeftItem(); List<Relationship> leftRelationships = findByItemAndRelationshipType(context, leftItem, relationship.getRelationshipType(), true); Item rightItem = relationship.getRightItem(); List<Relationship> rightRelationships = findByItemAndRelationshipType(context, rightItem, relationship.getRelationshipType(), false); context.turnOffAuthorisationSystem(); if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) { if (!leftRelationships.isEmpty()) { leftRelationships.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace()); for (int i = 0; i < leftRelationships.size(); i++) { leftRelationships.get(leftRelationships.size() - 1 - i).setLeftPlace(i); } relationship.setLeftPlace(leftRelationships.get(0).getLeftPlace() + 1); } else { <START> relationship.setLeftPlace(0); <END> } } else { updateItem(context, leftItem); } if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) { if (!rightRelationships.isEmpty()) { rightRelationships.sort((o1, o2) -> o2.getRightPlace() - o1.getRightPlace()); for (int i = 0; i < rightRelationships.size(); i++) { rightRelationships.get(rightRelationships.size() - 1 - i).setRightPlace(i); } relationship.setRightPlace(rightRelationships.get(0).getRightPlace() + 1); } else { relationship.setRightPlace(0); } } else { updateItem(context, rightItem); } if (isCreation) { handleCreationPlaces(context, relationship); } context.restoreAuthSystemState(); }</code><technical_language>this is this? relationship.setLeftPlace(leftRelationships.size()); I this more readable leftRelationships.get(0).getLeftPlace() + 1 work for case if relationships empty. is reason, sorting reordering is done descending of list front? this work? leftRelationships.sort((o1, o2) -> o1.getLeftPlace() - o2.getLeftPlace()); for (int i = 0; i < leftRelationships.size(); i++) { leftRelationships.get(i).setLeftPlace(i); }</technical_language>

Target:
public void updatePlaceInRelationship(Context context, Relationship relationship, boolean isCreation) throws SQLException, AuthorizeException { Item leftItem = relationship.getLeftItem(); List<Relationship> leftRelationships = findByItemAndRelationshipType(context, leftItem, relationship.getRelationshipType(), true); Item rightItem = relationship.getRightItem(); List<Relationship> rightRelationships = findByItemAndRelationshipType(context, rightItem, relationship.getRelationshipType(), false); context.turnOffAuthorisationSystem(); if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) { if (!leftRelationships.isEmpty()) { leftRelationships.sort(Comparator.comparingInt(Relationship::getLeftPlace)); for (int i = 0; i < leftRelationships.size(); i++) { leftRelationships.get(i).setLeftPlace(i); } relationship.setLeftPlace(leftRelationships.size()); } else { relationship.setLeftPlace(0); } } else { updateItem(context, leftItem); } if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) { if (!rightRelationships.isEmpty()) { rightRelationships.sort(Comparator.comparingInt(Relationship::getRightPlace)); for (int i = 0; i < rightRelationships.size(); i++) { rightRelationships.get(i).setRightPlace(i); } relationship.setRightPlace(rightRelationships.size()); } else { relationship.setRightPlace(0); } } else { updateItem(context, rightItem); } if (isCreation) { handleCreationPlaces(context, relationship); } context.restoreAuthSystemState(); }