Package org.fcrepo.kernel.impl
Class ContainmentIndexImpl
- java.lang.Object
-
- org.fcrepo.kernel.impl.ContainmentIndexImpl
-
- All Implemented Interfaces:
ContainmentIndex
@Component("containmentIndexImpl") public class ContainmentIndexImpl extends Object implements ContainmentIndex- Since:
- 6.0.0
- Author:
- peichman, whikloj
-
-
Field Summary
Fields Modifier and Type Field Description static StringFEDORA_ID_COLUMNstatic StringRESOURCES_TABLE
-
Constructor Summary
Constructors Constructor Description ContainmentIndexImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContainedBy(Transaction tx, FedoraId parent, FedoraId child)Add a contained by relation between the child resource and its parent.voidaddContainedBy(Transaction tx, 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(Transaction tx)Commit the changes made in the transaction.InstantcontainmentLastUpdated(Transaction tx, FedoraId fedoraId)Find the timestamp of the last child added or deletedStringgetContainedBy(Transaction tx, FedoraId resource)Return the ID of the containing resource for resourceID.FedoraIdgetContainerIdByPath(Transaction tx, 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(Transaction tx, FedoraId fedoraId)Return a stream of fedora identifiers contained by the specified fedora resource for the current state of the repository.Stream<String>getContainsDeleted(Transaction tx, FedoraId fedoraId)Return a stream of fedora identifiers contained by the specified fedora resource that have deleted relationships.DataSourcegetDataSource()Get the data source backing this containment indexbooleanhasResourcesStartingWith(Transaction tx, FedoraId fedoraId)Find whether there are any resources that starts with the ID provided.voidpurgeResource(Transaction tx, FedoraId resource)Remove all relationships to the specified resource.voidremoveContainedBy(Transaction tx, FedoraId parent, FedoraId child)Mark a contained by relation between the child resource and its parent as deleted.voidremoveResource(Transaction tx, FedoraId resource)Mark all relationships to the specified resource as deleted.voidreset()Truncates the containment index.booleanresourceExists(Transaction tx, FedoraId fedoraId, boolean includeDeleted)Check if the resourceID exists in the containment index.voidrollbackTransaction(Transaction tx)Rollback the containment index changes in the transaction.voidsetDataSource(DataSource dataSource)Set the data source backing this containment index
-
-
-
Field Detail
-
RESOURCES_TABLE
public static final String RESOURCES_TABLE
- See Also:
- Constant Field Values
-
FEDORA_ID_COLUMN
public static final String FEDORA_ID_COLUMN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ContainmentIndexImpl
public ContainmentIndexImpl()
-
-
Method Detail
-
getContains
public Stream<String> getContains(@Nonnull Transaction tx, FedoraId fedoraId)
Description copied from interface:ContainmentIndexReturn a stream of fedora identifiers contained by the specified fedora resource for the current state of the repository.- Specified by:
getContainsin interfaceContainmentIndex- Parameters:
tx- The transaction, or null if no transactionfedoraId- The ID of the containing fedora resource- Returns:
- A stream of contained identifiers
-
getContainsDeleted
public Stream<String> getContainsDeleted(@Nonnull Transaction tx, FedoraId fedoraId)
Description copied from interface:ContainmentIndexReturn a stream of fedora identifiers contained by the specified fedora resource that have deleted relationships.- Specified by:
getContainsDeletedin interfaceContainmentIndex- Parameters:
tx- The transaction, or null if no transactionfedoraId- The ID of the containing fedora resource- Returns:
- A stream of contained identifiers
-
getContainedBy
public String getContainedBy(@Nonnull Transaction tx, FedoraId resource)
Description copied from interface:ContainmentIndexReturn the ID of the containing resource for resourceID.- Specified by:
getContainedByin interfaceContainmentIndex- Parameters:
tx- The transaction, 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.
-
addContainedBy
public void addContainedBy(@Nonnull Transaction tx, FedoraId parent, FedoraId child)
Description copied from interface:ContainmentIndexAdd a contained by relation between the child resource and its parent.- Specified by:
addContainedByin interfaceContainmentIndex- Parameters:
tx- The transaction.parent- The containing resource fedoraID.child- The contained resource fedoraID.
-
addContainedBy
public void addContainedBy(@Nonnull Transaction tx, FedoraId parent, FedoraId child, Instant startTime, Instant endTime)
Description copied from interface:ContainmentIndexAdd a contained by relation between the child resource and its parent for a range of time in the past.- Specified by:
addContainedByin interfaceContainmentIndex- Parameters:
tx- The transaction.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.
-
removeContainedBy
public void removeContainedBy(@Nonnull Transaction tx, FedoraId parent, FedoraId child)
Description copied from interface:ContainmentIndexMark a contained by relation between the child resource and its parent as deleted.- Specified by:
removeContainedByin interfaceContainmentIndex- Parameters:
tx- The transaction.parent- The containing resource fedoraID.child- The contained resource fedoraID.
-
removeResource
public void removeResource(@Nonnull Transaction tx, FedoraId resource)
Description copied from interface:ContainmentIndexMark all relationships to the specified resource as deleted.- Specified by:
removeResourcein interfaceContainmentIndex- Parameters:
tx- The transaction.resource- The FedoraId of resource to remove.
-
purgeResource
public void purgeResource(@Nonnull Transaction tx, FedoraId resource)
Description copied from interface:ContainmentIndexRemove all relationships to the specified resource.- Specified by:
purgeResourcein interfaceContainmentIndex- Parameters:
tx- The transaction.resource- The FedoraId of resource to remove.
-
commitTransaction
public void commitTransaction(Transaction tx)
Description copied from interface:ContainmentIndexCommit the changes made in the transaction.- Specified by:
commitTransactionin interfaceContainmentIndex- Parameters:
tx- The transaction.
-
rollbackTransaction
@Transactional(propagation=NOT_SUPPORTED) public void rollbackTransaction(Transaction tx)
Description copied from interface:ContainmentIndexRollback the containment index changes in the transaction.- Specified by:
rollbackTransactionin interfaceContainmentIndex- Parameters:
tx- The transaction.
-
resourceExists
public boolean resourceExists(@Nonnull Transaction tx, FedoraId fedoraId, boolean includeDeleted)
Description copied from interface:ContainmentIndexCheck if the resourceID exists in the containment index. Which should mean it exists.- Specified by:
resourceExistsin interfaceContainmentIndex- Parameters:
tx- The transaction, 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
public FedoraId getContainerIdByPath(Transaction tx, FedoraId fedoraId, boolean checkDeleted)
Description copied from interface:ContainmentIndexFind the ID for the container of the provided resource by iterating up the path until you find a real resource.- Specified by:
getContainerIdByPathin interfaceContainmentIndex- Parameters:
tx- The transaction, or null if no transactionfedoraId- The resource's ID.checkDeleted- Whether to include deleted resource (tombstones) in the search.- Returns:
- The container ID.
-
reset
public void reset()
Description copied from interface:ContainmentIndexTruncates the containment index. This should only be called when rebuilding the index.- Specified by:
resetin interfaceContainmentIndex
-
hasResourcesStartingWith
public boolean hasResourcesStartingWith(Transaction tx, FedoraId fedoraId)
Description copied from interface:ContainmentIndexFind whether there are any resources that starts with the ID provided.- Specified by:
hasResourcesStartingWithin interfaceContainmentIndex- Parameters:
tx- The transaction, or null if no transaction.fedoraId- The ID to use to look for other IDs.- Returns:
- Are there any matching IDs.
-
containmentLastUpdated
public Instant containmentLastUpdated(Transaction tx, FedoraId fedoraId)
Description copied from interface:ContainmentIndexFind the timestamp of the last child added or deleted- Specified by:
containmentLastUpdatedin interfaceContainmentIndex- Parameters:
tx- The transaction, 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
-
getDataSource
public DataSource getDataSource()
Get the data source backing this containment index- Returns:
- data source
-
setDataSource
public void setDataSource(DataSource dataSource)
Set the data source backing this containment index- Parameters:
dataSource- data source
-
-