Class RelationshipVersioningUtils


  • public class RelationshipVersioningUtils
    extends Object
    Class with utility methods to manipulate relationships that are linked to versioned items. Specifically focussed on the "latest version status" of relationships, which controls which related items are relevant (visible) to any given item.
    • Constructor Detail

      • RelationshipVersioningUtils

        public RelationshipVersioningUtils()
    • Method Detail

      • otherSideIsLatest

        public boolean otherSideIsLatest​(boolean isLeft,
                                         Relationship.LatestVersionStatus latestVersionStatus)
        Given a latest version status, check if the other side is "latest". If we look from the left, this implies BOTH and RIGHT_ONLY return true. If we look from the right, this implies BOTH and LEFT_ONLY return true.
        Parameters:
        isLeft - whether we should look from the left or right side.
        latestVersionStatus - the latest version status.
        Returns:
        true if the other side has "latest" status, false otherwise.
      • updateLatestVersionStatus

        public RelationshipVersioningUtils.LatestVersionStatusChangelog updateLatestVersionStatus​(Relationship relationship,
                                                                                                  boolean updateLeftSide,
                                                                                                  boolean isLatest)
                                                                                           throws IllegalStateException
        Update Relationship.latestVersionStatus of the given relationship. If isLatest = true, this method will never throw IllegalStateException. If isLatest = false, you should make sure that the selected side of given relationship currently has "latest" status, otherwise IllegalStateException will be thrown.
        Parameters:
        relationship - the relationship.
        updateLeftSide - whether the status of the left item or the right item should be updated.
        isLatest - to what the status should be set.
        Throws:
        IllegalStateException - if the operation would result in both the left side and the right side being set to non-latest.