Interface CatalogService

    • Method Detail

      • getAvailableCatalogs

        java.util.List<CatalogModel> getAvailableCatalogs​(UserModel user)
        Get the available catalogs for an user
        Parameters:
        user - the user
        Returns:
        a list of catalogs
      • getCatalogVersions

        java.util.List<CatalogVersionModel> getCatalogVersions​(CatalogModel catalog,
                                                               UserModel user)
        Get the catalog versions for a catalog
        Parameters:
        catalog - the catalog containing the versions
        user - the user
        Returns:
        a list of catalog versions
      • getAllCatalogVersions

        java.util.List<CatalogVersionModel> getAllCatalogVersions​(UserModel user)
        Get all available catalog versions for an user
        Parameters:
        user - the user
        Returns:
        a list of catalog versions
      • getAvailableCatalogVersions

        java.util.List<CatalogVersionModel> getAvailableCatalogVersions()
        Get the available catalog versions for the current user
        Returns:
        a list of catalog versions
      • getSortedCatalogVersions

        java.util.List<CatalogVersionModel> getSortedCatalogVersions​(UserModel user)
        Get the available catalog versions for an user in an alternative order
        Parameters:
        user - the user
        Returns:
        a list of catalog versions
      • getCategories

        java.util.List<CategoryModel> getCategories​(CatalogVersionModel version)
        Get all root categories under a catalog version
        Parameters:
        version - the catalog version
        Returns:
        a list of categories
      • getCategoryCount

        long getCategoryCount​(CatalogVersionModel version)
        get the number of root categories under a catalog version
        Parameters:
        version - the catalog version
        Returns:
        the number of root categories
      • getCategories

        java.util.List<CategoryModel> getCategories​(CategoryModel category)
        Get all direct sub-categories for a category
        Parameters:
        category - the super-category
        Returns:
        the list of sub-categories
      • getCategoryCount

        long getCategoryCount​(CategoryModel category)
        Get the number of sub-categories for a category
        Parameters:
        category - the category
        Returns:
        the number of direct sub-categories
      • getCatalog

        CatalogModel getCatalog​(CatalogVersionModel version)
        Get the catalog for the given catalog version
        Parameters:
        version - the catalog version
        Returns:
        the catalog containing the catalog version
      • getCatalogVersion

        CatalogVersionModel getCatalogVersion​(CategoryModel category)
        Get the catalog versions containing the given category
        Parameters:
        category - the category
        Returns:
        the containing catalog version
      • getCategoryPath

        java.util.List<CategoryModel> getCategoryPath​(CategoryModel category)
        Get a list of categories representing the path from the given category through all supercategories to the root category
        Parameters:
        category - the category
        Returns:
        a list of categories
      • getSubcategoriesHavingSubcategories

        java.util.Collection<java.lang.String> getSubcategoriesHavingSubcategories​(ItemModel item)
        Get a collection of all non-empty sub-categories for a given category or catalog version
        Parameters:
        item - the catalog or catalog version
        Returns:
        a list of categories
      • getCatalogVersion

        CatalogVersionModel getCatalogVersion​(PK pk)
        Get the CatalogVersion for a Catalog item, specified by PK
        Parameters:
        pk - the pk of the item
        Returns:
        the catalog version if it exists, null otherwise
      • getItems

        java.util.List<MacFinderTreeNode> getItems​(MacFinderTreeNode wrappedCategory,
                                                   CatalogVersionModel version,
                                                   boolean includeSubCategory,
                                                   MacFinderTreeNode connectedItem)
        Get the products for a given category.
        Parameters:
        wrappedCategory - the category
        includeSubCategory - if true, also include products from sub-categories
        Returns:
        a list of products
      • isMoveCategoriesPermitted

        boolean isMoveCategoriesPermitted​(java.util.Collection<TypedObject> categories,
                                          CategoryModel newSuperCategory,
                                          CategoryModel removeCategory)
        Checks if user is allowed to move categories from one to other
        Parameters:
        categories - categories to be moved
        newSuperCategory - new parent category for categories
        removeCategory - parent category from which categories should be removed
        Returns:
        true if allowed
      • isMoveCategoryPermitted

        boolean isMoveCategoryPermitted​(CategoryModel category,
                                        CategoryModel newSuperCategory,
                                        CategoryModel removeCategory)
        Checks if user is allowed to move category from one to other
        Parameters:
        category - category to be moved
        newSuperCategory - new parent category for category
        removeCategory - parent category from which category should be removed
        Returns:
        true if allowed
      • isAssignProductPermitted

        boolean isAssignProductPermitted​(TypedObject product,
                                         CategoryModel newSuperCategory,
                                         CategoryModel removeFromCategory)
        Checks if user is allowed to assing product to a category
        Parameters:
        product - product to be assigned
        newSuperCategory - new parent category
        removeFromCategory - parent category from which product should be removed
        Returns:
        true if allowed
      • moveCategory

        boolean moveCategory​(CategoryModel category,
                             CategoryModel newSuperCategory,
                             CategoryModel removeCategory)
        Moves category from one to other
        Parameters:
        category - category to be moved
        newSuperCategory - new parent category for category
        removeCategory - parent category from which category should be removed
        Returns:
        true if moving was successfully performed
      • moveCategories

        boolean moveCategories​(java.util.Collection<TypedObject> categories,
                               CategoryModel newSuperCategory,
                               CategoryModel removeCategory)
        Moves categories from one to other
        Parameters:
        categories - categories to be moved
        newSuperCategory - new parent category for categories
        removeCategory - parent category from which categories should be removed
        Returns:
        true if moving was successfully performed
      • setAsRootCategory

        boolean setAsRootCategory​(CategoryModel category)
        Marks a category as root
        Parameters:
        category - root category
        Returns:
        true is category was successfully marked as root
      • assignProduct

        boolean assignProduct​(TypedObject product,
                              CategoryModel newSuperCategory,
                              CategoryModel removeFromCategory)
        Assigns product to category
        Parameters:
        product - product to be assigned
        newSuperCategory - new parent category
        removeFromCategory - parent category from which product should be removed
        Returns:
        true if moving was successfully performed
      • assignProducts

        boolean assignProducts​(java.util.Collection<TypedObject> products,
                               CategoryModel newSuperCategory,
                               CategoryModel removeFromCategory)
        Assigns products to category
        Parameters:
        products - products to be assigned
        newSuperCategory - new parent category
        removeFromCategory - parent category from which products should be removed
        Returns:
        true if moving was successfully performed
      • assignProduct

        boolean assignProduct​(TypedObject product,
                              CatalogVersionModel catalogVersionModel,
                              CategoryModel removeFromCategory)
        Assigns product to catalog version
        Parameters:
        product - product to be assigned
        catalogVersionModel - new catalog version
        removeFromCategory - parent category from which product should be removed
        Returns:
        true if moving was successfully performed
      • wrapCategory

        CategoryModel wrapCategory​(TypedObject typedObject)
        Extracts category model from provided typedObject
        Parameters:
        typedObject - object to extract category from
        Returns:
        category extracted or null if @typedObject is not category
      • wrapCatalogVersion

        CatalogVersionModel wrapCatalogVersion​(TypedObject typedObject)
        Extracts catalog version model from provided typedObject
        Parameters:
        typedObject - object to extract catalog version from
        Returns:
        catalog version extracted or null if @typedObject is not catalog version
      • getCatalogVersionTypedObject

        TypedObject getCatalogVersionTypedObject​(CatalogVersionModel catVer)
        Converts catalog version into TypedObject
        Parameters:
        catVer - catalog version to be converted
        Returns:
        converted catalog version
      • getSupercategories

        java.util.List<TypedObject> getSupercategories​(TypedObject categorizableItem,
                                                       boolean fromSameCatalogVersionOnly)
        Returns list of supercategories of the given categorizable item.
        Parameters:
        categorizableItem - a categorizable item (product, category..)
        fromSameCatalogVersionOnly - if true, only supercategories belonging to the same catalog version as given categorizable item are returned
        Returns:
        list of supercategories of the given categorizable item
      • addToCategories

        void addToCategories​(TypedObject categorizableItem,
                             java.util.List<TypedObject> categories)
        Adds given categorizable item to given categories.
        Parameters:
        categorizableItem - the categorizable item to be added
        categories - the categories to add to
      • removeFromCategories

        void removeFromCategories​(TypedObject categorizableItem,
                                  java.util.List<TypedObject> categories)
        Removes given categorizable item from given categories.
        Parameters:
        categorizableItem - the categorizable item to be removed
        categories - the categories to remove from