Package org.fcrepo.kernel.api
Interface ContainmentIndex
-
public interface ContainmentIndex
An interface for retrieving resource IDs by their containment relationships.- Since:
- 6.0.0
- Author:
- dbernstein
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddContainedBy(String txId, FedoraId parent, FedoraId child)Add a contained by relation between the child resource and its parent.voidaddContainedBy(String txId, FedoraId parent, FedoraId child, Instant startTime, Instant endTime)Add a contained by relation between the child resource and its parent for a range of time in the past.voidcommitTransaction(String txId)Commit the changes made in the transaction.InstantcontainmentLastUpdated(String txId, FedoraId fedoraId)Find the timestamp of the last child added or deletedStringgetContainedBy(String txId, FedoraId resource)Return the ID of the containing resource for resourceID.FedoraIdgetContainerIdByPath(String txId, FedoraId fedoraId, boolean checkDeleted)Find the ID for the container of the provided resource by iterating up the path until you find a real resource.Stream<String>getContains(String txId, FedoraId fedoraId)Return a stream of fedora identifiers contained by the specified fedora resource for the current state of the repository.Stream<String>getContainsDeleted(String txId, FedoraId fedoraId)Return a stream of fedora identifiers contained by the specified fedora resource that have deleted relationships.booleanhasResourcesStartingWith(String txId, FedoraId fedoraId)Find whether there are any resources that starts with the ID provided.voidpurgeResource(String txId, FedoraId resource)Remove all relationships to the specified resource.voidremoveContainedBy(String txId, FedoraId parent, FedoraId child)Mark a contained by relation between the child resource and its parent as deleted.voidremoveResource(String txId, FedoraId resource)Mark all relationships to the specified resource as deleted.voidreset()Truncates the containment index.booleanresourceExists(String txId, FedoraId fedoraId, boolean includeDeleted)Check if the resourceID exists in the containment index.voidrollbackTransaction(String txId)Rollback the containment index changes in the transaction.
-
-
-
Method Detail
-
getContains
Stream<String> getContains(String txId, FedoraId fedoraId)
Return a stream of fedora identifiers contained by the specified fedora resource for the current state of the repository.- Parameters:
txId- The transaction id, or null if no transactionfedoraId- The ID of the containing fedora resource- Returns:
- A stream of contained identifiers
-
getContainsDeleted
Stream<String> getContainsDeleted(String txId, FedoraId fedoraId)
Return a stream of fedora identifiers contained by the specified fedora resource that have deleted relationships.- Parameters:
txId- The transaction id, or null if no transactionfedoraId- The ID of the containing fedora resource- Returns:
- A stream of contained identifiers
-
getContainedBy
String getContainedBy(String txId, FedoraId resource)
Return the ID of the containing resource for resourceID.- Parameters:
txId- The transaction id, or null if no transactionresource- The FedoraId of the resource to find the containing resource for.- Returns:
- The id of the containing resource or null if none found.
-
removeContainedBy
void removeContainedBy(@Nonnull String txId, FedoraId parent, FedoraId child)
Mark a contained by relation between the child resource and its parent as deleted.- Parameters:
txId- The transaction ID.parent- The containing resource fedoraID.child- The contained resource fedoraID.
-
removeResource
void removeResource(@Nonnull String txId, FedoraId resource)
Mark all relationships to the specified resource as deleted.- Parameters:
txId- The transaction ID.resource- The FedoraId of resource to remove.
-
purgeResource
void purgeResource(@Nonnull String txId, FedoraId resource)
Remove all relationships to the specified resource.- Parameters:
txId- The transaction ID.resource- The FedoraId of resource to remove.
-
addContainedBy
void addContainedBy(@Nonnull String txId, FedoraId parent, FedoraId child)
Add a contained by relation between the child resource and its parent.- Parameters:
txId- The transaction ID.parent- The containing resource fedoraID.child- The contained resource fedoraID.
-
addContainedBy
void addContainedBy(@Nonnull String txId, FedoraId parent, FedoraId child, Instant startTime, Instant endTime)
Add a contained by relation between the child resource and its parent for a range of time in the past.- Parameters:
txId- The transaction ID.parent- The containing resource fedoraID.child- The contained resource fedoraID.startTime- The start instant of the containment relationship.endTime- The end instant of the containment relationship.
-
commitTransaction
void commitTransaction(String txId)
Commit the changes made in the transaction.- Parameters:
txId- The transaction id.
-
rollbackTransaction
void rollbackTransaction(String txId)
Rollback the containment index changes in the transaction.- Parameters:
txId- The transaction id.
-
resourceExists
boolean resourceExists(String txId, FedoraId fedoraId, boolean includeDeleted)
Check if the resourceID exists in the containment index. Which should mean it exists.- Parameters:
txId- The transaction id, or null if no transactionfedoraId- The resource's FedoraId.includeDeleted- Include deleted resources in the search.- Returns:
- True if it is in the index.
-
getContainerIdByPath
FedoraId getContainerIdByPath(String txId, FedoraId fedoraId, boolean checkDeleted)
Find the ID for the container of the provided resource by iterating up the path until you find a real resource.- Parameters:
txId- The transaction id, or null if no transactionfedoraId- The resource's ID.checkDeleted- Whether to include deleted resource (tombstones) in the search.- Returns:
- The container ID.
-
reset
void reset()
Truncates the containment index. This should only be called when rebuilding the index.
-
hasResourcesStartingWith
boolean hasResourcesStartingWith(String txId, FedoraId fedoraId)
Find whether there are any resources that starts with the ID provided.- Parameters:
txId- The transaction id, or null if no transaction.fedoraId- The ID to use to look for other IDs.- Returns:
- Are there any matching IDs.
-
containmentLastUpdated
Instant containmentLastUpdated(String txId, FedoraId fedoraId)
Find the timestamp of the last child added or deleted- Parameters:
txId- The transaction id, or null if no transaction.fedoraId- The ID of the containing resource to check.- Returns:
- Timestamp of last child added or deleted or null if none
-
-