Interface CategoryLinkService


public interface CategoryLinkService
  • Field Details

  • Method Details

    • getLinkedIds

      List<Long> getLinkedIds(CategoryObject object)
      Parameters:
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)
      Returns:
      List of linked Category identifiers
    • getLinkedIds

      Map<String,List<Long>> getLinkedIds(String objectType, List<String> objectIds)
      The categories each of several objects is filed under, in one query.

      getLinkedIds(CategoryObject) is the right call for a reader looking at one thing, and the wrong one for a list: a page of rows showing what each is filed under would ask it once per row. This answers the whole page, so the caller decorates its rows by lookup instead of by a query each.

      Parameters:
      objectType - CategoryObject type, example: Space, Activity ...
      objectIds - the objects' identifiers, in stored form. Unlike getLinkedIds(CategoryObject), this read does not put its ids through CategoryPluginService.getObject(io.meeds.social.category.model.CategoryObject) first, so a plugin that rewrites the object - the space one resolves any id form to the space's technical id, the activity one redirects to the activity's metadata object and changes the type with it - is not applied here. Passing a form the plugin would have normalised returns no categories for that id. The keys of the returned map are the ids as given.
      Returns:
      Map of linked Category identifiers keyed by object id; an object with no category is absent from the map rather than present with an empty list
    • getLinkedIds

      List<Long> getLinkedIds(String objectType)
      Parameters:
      objectType - CategoryObject type, example: Space, Activity ...
      Returns:
      List of linked Category identifiers
    • getLinkedObjects

      List<CategoryObject> getLinkedObjects(long categoryId, List<String> objectTypes, int offset, int limit)
      Parameters:
      categoryId - Category identifier
      objectTypes - List of CategoryObject types to filter by
      offset - offset of objects to retrieve
      limit - limit of objects to retrieve
      Returns:
      List of CategoryObject linked to the category, ordered by last modification date descending
    • isLinked

      boolean isLinked(long categoryId, CategoryObject object)
      Parameters:
      categoryId - Category identifier
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)
      Returns:
      true if the object is linked to the category
    • link

      void link(long categoryId, CategoryObject object, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, org.exoplatform.commons.ObjectAlreadyExistsException, IllegalAccessException
      Creates a link from the designated object to the category
      Parameters:
      categoryId - Category identifier
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)
      username - User name/login
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the category doesn't exist
      org.exoplatform.commons.ObjectAlreadyExistsException - when the object is already linked to the category
      IllegalAccessException - when the user doesn't have 'Link' permission on the category or not having 'edit' permission on the object
    • link

      void link(long categoryId, CategoryObject object)
      Creates a link from the designated object to the category
      Parameters:
      categoryId - Category identifier
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)
    • unlink

      void unlink(long categoryId, CategoryObject object, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Deletes a link of the designated object from the category
      Parameters:
      categoryId - Category identifier
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)
      username - User name/login
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the link doesn't exist
      IllegalAccessException - when the user doesn't have 'Link' permission on the category or not having 'edit' permission on the object
    • unlink

      void unlink(long categoryId, CategoryObject object)
      Deletes a link of the designated object from the category
      Parameters:
      categoryId - Category identifier
      object - CategoryObject using type/id to designate any object in the platform (Space, Activity ...)