Package net.sf.basedb.core
Class Trashcan
java.lang.Object
net.sf.basedb.core.Trashcan
This class contains functionality to manage items that
have been marked for deletion.
- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2021-06-04 12:40:45 +0200 (Fri, 04 Jun 2021) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
Helper class for holding information about a single item, other items using it and other information that is relevant for resolving circular references. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static int
breakCircularReferences
(SessionControl sc, Set<Identifiable> itemsToRemove) static int
delete
(SessionControl sc, Collection<? extends Identifiable> items, boolean ignoreFlag, ProgressReporter progress) Delete items permanently.static int
deleteAll
(SessionControl sc, ProgressReporter progress) Delete all items in the trashcan of the logged in user.static ResultList<Removable>
static ResultList<Removable>
getItems
(DbControl dc, Set<Item> itemTypes, int firstItem, int maxItems, Restriction restriction) Load all items flagged for deletion that are owned by or removed by the logged in user.static ResultList<Removable>
-
Field Details
-
log
Log trashcan events. -
isDebug
private static final boolean isDebug
-
-
Constructor Details
-
Trashcan
public Trashcan()
-
-
Method Details
-
getItems
public static ResultList<Removable> getItems(DbControl dc, Item itemType, int firstItem, int maxItems) throws BaseException - Throws:
BaseException
- See Also:
-
getItems
public static ResultList<Removable> getItems(DbControl dc, Set<Item> itemTypes, int firstItem, int maxItems) throws BaseException - Throws:
BaseException
- See Also:
-
getItems
public static ResultList<Removable> getItems(DbControl dc, Set<Item> itemTypes, int firstItem, int maxItems, Restriction restriction) throws BaseException Load all items flagged for deletion that are owned by or removed by the logged in user. A restriction may be specified to limit the returned items. Note that separate queries are used for each item type but the same restriction is applied to all of them. It is recommended that the restriction is created withRestrictions.conditionalRestriction(Filter, Restriction, Restriction, boolean)
so that a restriction on, for example, the 'name' is only applied toNameable
items.- Parameters:
dc
- TheDbControl
to use for database accessitemTypes
- Limit the list to only return items of the types, included in the set, use null or an empty set to return items of all typesfirstItem
- The index of the first item to return (0-based)maxItems
- The maximum number of items to return, or 0 to return all itemsrestriction
- A restriction to apply when loading items- Returns:
- A list containing removable items
- Throws:
BaseException
- If there is an error of some kind- Since:
- 3.7
-
delete
public static int delete(SessionControl sc, Collection<? extends Identifiable> items, boolean ignoreFlag, ProgressReporter progress) throws BaseException Delete items permanently. This method only delete items that- have been marked for deletion (unless the ignoreFlag parameter is set)
- the logged in user has permission to delete
- not are used by other items
- Parameters:
sc
- The session control to use for connecting to the database. To avoid multithread-related problems the session control is cloned before being used by this method.items
- The items to removeignoreFlag
- TRUE to also remove items that hasn't been flagged for removalprogress
- An optional progress reporter- Returns:
- The number of deleted items
- Throws:
BaseException
- If an item can't be deleted.- Since:
- 2.4
-
deleteAll
Delete all items in the trashcan of the logged in user. This method callsgetItems(DbControl, Item, int, int)
to load all items that have been flagged for removal and thendelete(SessionControl, Collection, boolean, ProgressReporter)
to remove those items. See thedelete
for more information about transactions.- Parameters:
sc
- The session control to use for connecting to the databaseprogress
- An optional progress reporter- Returns:
- The number of deleted items
- Since:
- 2.4
-
breakCircularReferences
-