Interface EntryGroupService

All Known Implementing Classes:
DefaultEntryGroupService

public interface EntryGroupService
Service that exposes methods to deal with EntryGroup operations.
  • Method Details

    • getNestedGroups

      @Nonnull List<EntryGroup> getNestedGroups(@Nonnull EntryGroup entryGroup)
      Gets all nested EntryGroups of given one, including the given one.
      Parameters:
      entryGroup - root EntryGroup
      Returns:
      all EntryGroups for subtree where the given EntryGroup is root, including the root
    • getLeaves

      @Nonnull List<EntryGroup> getLeaves(@Nonnull EntryGroup entryGroup)
      Returns all leaf EntryGroups of given one. If that one is already leaf it will return itself.
      Parameters:
      entryGroup - root EntryGroup
      Returns:
      all leaf EntryGroups for subtree where the given EntryGroup is root or given EntryGroup if it is a leaf.
    • getGroup

      @Nonnull EntryGroup getGroup(@Nonnull AbstractOrderModel order, @Nonnull Integer groupNumber)
      Returns EntryGroup by groupNumber
      Parameters:
      groupNumber - number of the group to search for
      order - order containing entry group trees
      Returns:
      EntryGroup with given groupNumber from the order
      Throws:
      IllegalArgumentException - if no group with given groupNumber in the order
    • getRoot

      @Nonnull EntryGroup getRoot(@Nonnull AbstractOrderModel order, @Nonnull Integer groupNumber)
      Returns root of the tree within the order's entry group trees which has given group.
      Parameters:
      order - order to take trees from
      groupNumber - number of group to search for
      Returns:
      root of the tree that contains groupNumber
      Throws:
      IllegalArgumentException - if group is not found
    • getParent

      EntryGroup getParent(@Nonnull AbstractOrderModel order, @Nonnull Integer groupNumber)
      Returns parent entry group of the tree within the order's entry group trees which has given group.
      Parameters:
      order - order to take trees from
      groupNumber - number of group to search for
      Returns:
      parent of the groupNumber or null if it is root
      Throws:
      IllegalArgumentException - if group is not found in the cart
    • forceOrderSaving

      void forceOrderSaving(@Nonnull AbstractOrderModel order)
      As EntryGroup is not a DB entity, changing it does not cause parent order to save. This method updates the whole entryGroups field, so the order is marked as changes and correctly saved to DB.
      Parameters:
      order - order to save
    • findMaxGroupNumber

      int findMaxGroupNumber(List<EntryGroup> roots)
      Searches for maximum value of EntryGroup.getGroupNumber(). Is useful for assigning unique values to entry group numbers.
      Parameters:
      roots - list of root groups
      Returns:
      maximum value of groupNumber field
    • getGroupOfType

      EntryGroup getGroupOfType(@Nonnull AbstractOrderModel order, @Nonnull Collection<Integer> groupNumbers, @Nonnull GroupType type)
      Find entry group in the cart by number and type.
      Parameters:
      order - user's cart
      groupNumbers - group numbers of the entry
      type - group type
      Returns:
      EntryGroup object or null if no groups of given type in collection
      Throws:
      AmbiguousIdentifierException - if more than one EntryGroup with provided group type was found