public class CategoryItemCollection extends ItemCollection
Modifier and Type | Method and Description |
---|---|
CategoryItemCollection |
clone()
Create a clone of this collection.
|
int |
countCategoryTreeItems(java.util.Set<java.lang.Integer> expandedCategoryIDs)
Return the number of categories that would be visible in the category tree if the given categories are expanded.
|
int |
countTotalCategoryTreeItems()
Return the number of categories that would be visible in the category tree if all categories were expanded.
|
java.util.Set<java.lang.Integer> |
findCategoryIDs(java.lang.String categoryName)
Find categories by their name.
|
CategoryItem |
getCategoryItemByID(int categoryID)
Return a CategoryItem specified by ID.
|
CategoryItem |
getCategoryTreeCatalogRootCategory()
Get the CategoryItem that represents the root of the category tree of the given catalog.
|
CategoryItem |
getCategoryTreeItemByIndex(int index,
java.util.Set<java.lang.Integer> expandedCategoryIDs)
Get the ID of the category specified by index in the tree assuming a set of categories being expanded.
|
int |
getCategoryTreeItemIDByPath(CategoryItem parent,
java.lang.String path)
Returns the ID of the category with the given relative tree path underneath a given category.
|
int |
getCategoryTreeItemIDByPath(java.lang.String path)
Returns the ID of the category with the given tree path.
|
java.util.List<java.lang.Integer> |
getCategoryTreeItemIDs(int startIndex,
int count,
java.util.Set<java.lang.Integer> expandedCategoryIDs,
boolean excludeDisabledCategories)
Get the IDs of all categories in the category tree assuming a set of categories being expanded.
|
int |
getCategoryTreeItemIndex(int categoryItemID,
java.util.Set<java.lang.Integer> expandedCategoryIDs)
Return the index of a given category in the tree assuming a set of categories being expanded.
|
static java.lang.String |
getCategoryTreePath(java.util.List<java.lang.String> categories)
Construct a valid category tree path for the category specified by the list of category names.
|
java.util.Map<java.lang.Integer,java.lang.Integer> |
getNumberOfAssignedRecords(java.util.Set<java.lang.Integer> categoryIDs,
java.util.EnumSet<FindFlag> flags)
Return statistics about how many records are assigned to a given set of categories.
|
boolean |
hasCategoryTreeItem(int categoryItemID)
Return whether the given category (specified by ID) is included in the category tree.
|
java.util.Iterator<Item> |
iterator()
Return an iterator that iterates over all category items in this collection using the tree hierarchy.
|
java.util.List<java.lang.Integer> |
sortCategoryIDsAccordingToCategoryTree(java.util.Set<java.lang.Integer> categoryIDs)
Reorder the given categories according to their position in the category tree.
|
addCatalogingListener, addCollectionListener, addFilter, addFilter, addGlobalCatalogingListener, addGlobalCollectionListener, addItemByID, addItemsByID, catalogAsset, catalogAsset, catalogAsset, catalogAssets, catalogAssets, catalogAssets, close, createItem, createItem, equals, find, find, find, find, findAll, getCatalog, getCumulusSession, getItemByID, getItemCount, getItemIDs, getItemPosition, getItemTotalCount, getLayout, getMultiSorting, getSortDirection, getSorting, getTableName, hashCode, hasItem, matchIDs, moveItem, moveItemByID, removeAllItems, removeCatalogingListener, removeCollectionListener, removeFilter, removeGlobalCatalogingListener, removeGlobalCollectionListener, removeItemsByID, setFreesorted, setMultiSorting, setSortDirection, setSorting, updateItems, updateItems, updateWantedFields, updateWantedFields
public CategoryItemCollection clone()
clone
in class ItemCollection
public CategoryItem getCategoryItemByID(int categoryID) throws ItemNotFoundException, CumulusException
categoryID
- The ID of the category item to be returned.ItemNotFoundException
- if the collection does not contain the given item.CumulusException
- on other errors.ItemCollection.hasItem(int)
,
ItemCollection.addItemByID(int)
,
ItemCollection.addItemsByID(java.util.List)
public CategoryItem getCategoryTreeCatalogRootCategory()
private void walkCategoryTree (CategoryItem categoryItem) { CategoryItem childItem = categoryItem.getFirstChildCategoryItem (); while (childItem != null) { System.out.println ("Category: " + childItem.toString ()); walkCategoryTree (childItem); childItem = childItem.getNextSiblingCategoryItem (); } } ... walkCategoryTree (categoryItemCollection.getCategoryTreeCatalogRootCategory ());
public java.util.Map<java.lang.Integer,java.lang.Integer> getNumberOfAssignedRecords(java.util.Set<java.lang.Integer> categoryIDs, java.util.EnumSet<FindFlag> flags)
categoryIDs
- The IDs of the categories to return the number of assigned records for.flags
- The flags that control how the assignments are calculated.public int countTotalCategoryTreeItems()
public int countCategoryTreeItems(java.util.Set<java.lang.Integer> expandedCategoryIDs)
expandedCategoryIDs
- The IDs of the categories that should be treated as expandedpublic boolean hasCategoryTreeItem(int categoryItemID)
categoryItemID
- The ID of the category to look for.true
if the given category is included in the category tree. Return false
otherwise.public java.util.List<java.lang.Integer> getCategoryTreeItemIDs(int startIndex, int count, java.util.Set<java.lang.Integer> expandedCategoryIDs, boolean excludeDisabledCategories)
0
.startIndex
- The starting index for the categories. The catalog root category has index 0
, the first top-level category
has index 1
and so on.count
- The number of categories to return.expandedCategoryIDs
- The set of categories that should be taken as expanded meaning that this method looks into it's sub-categories.excludeDisabledCategories
- Pass true
if you do not want to include disabled categories that are added to the tree after searching.getCategoryTreeItemByIndex(int, java.util.Set)
public CategoryItem getCategoryTreeItemByIndex(int index, java.util.Set<java.lang.Integer> expandedCategoryIDs) throws InvalidArgumentException
0
.index
- The index for the category to return. The catalog root category has index 0
, the first top-level category has
index 1
and so on.expandedCategoryIDs
- The set of categories that should be taken as expanded meaning that this method looks into it's sub-categories.InvalidArgumentException
- if the index is out of rangegetCategoryTreeItemIDs(int, int, java.util.Set, boolean)
public int getCategoryTreeItemIndex(int categoryItemID, java.util.Set<java.lang.Integer> expandedCategoryIDs) throws InvalidArgumentException
categoryItemID
- The ID of the category to find.expandedCategoryIDs
- The set of categories that should be taken as expanded meaning that this method looks into it's sub-categories.InvalidArgumentException
- if the given category ID is invalid.public java.util.List<java.lang.Integer> sortCategoryIDsAccordingToCategoryTree(java.util.Set<java.lang.Integer> categoryIDs)
categoryIDs
- The IDs of the categories to sort.public java.util.Set<java.lang.Integer> findCategoryIDs(java.lang.String categoryName)
categoryName
- The name to search for.public int getCategoryTreeItemIDByPath(java.lang.String path) throws InvalidArgumentException
"$Sources:Volume:2009::05::18"
specifies the category "2009:05:18" inside
the category "Volume" inside the category "$Sources".path
- The path to the category (similar to paths in file systems) using colons as separators. Colons in category names need to be escaped by using
a double colon character.InvalidArgumentException
- if the path does not specify an existing category.public int getCategoryTreeItemIDByPath(CategoryItem parent, java.lang.String path) throws InvalidArgumentException
parent
- The parent category where the path starts. You can specify null
to start at the root level.path
- The relative path from the parent category.InvalidArgumentException
- if the path does not specify an existing category.public static java.lang.String getCategoryTreePath(java.util.List<java.lang.String> categories)
categories
- A sorted list of category names starting at the top level that specifies the path to the category. Example: new String[]
{"$Sources", "Volume", "2009:05:18"}
specifies the category "2009:05:18" inside the category "Volume" inside the category
"$Sources".public java.util.Iterator<Item> iterator()
for (Item item : categoryItemCollection) { CategoryItem categoryItem = (CategoryItem) item; // use the categoryItem }
iterator
in interface java.lang.Iterable<Item>
iterator
in class ItemCollection
www.canto.com
Canto, the Canto logo, the Cumulus logo, and Cumulus are registered trademarks of Canto GmbH, registered in the U.S. and other countries.