Class ListServiceUtils


  • public final class ListServiceUtils
    extends java.lang.Object
    Utility functions for dealing with list requests.
    Author:
    Alex Kalderimis
    • Method Detail

      • castBagsToCommonType

        public static java.util.Collection<InterMineBag> castBagsToCommonType​(java.util.Collection<InterMineBag> bags,
                                                                              java.lang.String type,
                                                                              java.util.Set<java.lang.String> nameAccumulator,
                                                                              Profile profile,
                                                                              java.util.Map<java.lang.String,​java.util.List<FieldDescriptor>> classKeys)
                                                                       throws UnknownBagTypeException,
                                                                              ClassKeysNotFoundException,
                                                                              ObjectStoreException
        Given a common type, return a collection of bags cast to that type. The contents of the returned bags is guaranteed to be the same as the input bags, and they may be the same objects (if they do not need casting). The caller is responsible for deleting the temporary lists accumulated in the name accumulator.
        Parameters:
        bags - The bags to cast
        type - The type common to all bags
        nameAccumulator - A set of strings to hold the names of temporary lists.
        profile - A profile to use to create temporary bags
        classKeys - A classKeys to use to create bags
        Returns:
        A set of bags of the given type.
        Throws:
        UnknownBagTypeException - if the bag type is wrong
        ClassKeysNotFoundException - if the classKeys is empty
        ObjectStoreException - if there is a problem storing or creating bags.
      • getBagsAndClasses

        public static void getBagsAndClasses​(java.util.Set<ClassDescriptor> classes,
                                             java.util.Set<InterMineBag> lists,
                                             Profile profile,
                                             BagManager manager,
                                             Model model,
                                             java.lang.String[] listNames)
        Given an array of bag names, populate both a set of bags, and a set of class-descriptors with the objects these names refer to.
        Parameters:
        classes - A set to hold the class descriptors for the given lists
        lists - A set to hold the resolved lists
        profile - The profile to use to get lists from (if not global lists)
        manager - A bag manager to use.
        model - A model to resolve list types to class-descriptors with.
        listNames - An array of list names
        Throws:
        BadRequestException - if the lists cannot be resolved
      • ensureBagIsDeleted

        public static void ensureBagIsDeleted​(Profile profile,
                                              java.lang.String name)
                                       throws ObjectStoreException
        After this method returns, the will be no bag with the given name in the given profile.
        Parameters:
        profile - The profile to target for list deletion.
        name - The name of the bag that must not exist.
        Throws:
        ObjectStoreException - If there is a problem deleting the bag.
      • findCommonSuperTypeOf

        public static java.lang.String findCommonSuperTypeOf​(java.util.Set<ClassDescriptor> classes)
        Finds the common class for a set of classes. So for a set with the members Employee, Manager and CEO, Employee will be returned. For a set with the members Employee, Company, and CEO, an exception will be thrown.
        Parameters:
        classes - The classes that should have a common type.
        Returns:
        A class name.
      • findMostSpecificCommonTypeOf

        public static java.lang.String findMostSpecificCommonTypeOf​(java.util.Set<ClassDescriptor> classes)
        Parameters:
        classes - The classes we want to reduce to a common type.
        Returns:
        The most specific common type.
      • findCommonClasses

        public static java.util.List<ClassDescriptor> findCommonClasses​(java.util.Set<ClassDescriptor> classes)
        Parameters:
        classes - The classes we want to reduce to a set of common types.
        Returns:
        The common types.