Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MET-6303-Implement-tombstone-deletion-in-Metis #708

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,45 @@ public boolean removeRecord(String rdfAbout) throws IndexerRelatedIndexingExcept
}
}

/**
* Removes the tombstone of the record with the given rdf:about value. Also removes any associated entities (i.e. those entities
* that are always part of only one record and the removal of which can not invalidate references from other records):
* <ul>
* <li>Aggregation</li>
* <li>EuropeanaAggregation</li>
* <li>ProvidedCHO</li>
* <li>Proxy (both provider and Europeana proxies)</li>
* </ul>
* However, entities that are potentially shared are not removed.
*
* @param rdfAbout The about value of the record to remove. Is not null.
* @return Whether the record was removed.
* @throws IndexerRelatedIndexingException In case something went wrong.
*/
public boolean removeTombstone(String rdfAbout) throws IndexerRelatedIndexingException {
try {
// Obtain the Mongo record
final Datastore datastore = tombstoneDao.getDatastore();
final FullBeanImpl recordToDelete = datastore.find(FullBeanImpl.class)
.filter(Filters.eq(ABOUT_FIELD, rdfAbout)).first();

// Remove mongo record and dependencies
if (recordToDelete != null) {
datastore.delete(recordToDelete);
recordToDelete.getAggregations().forEach(datastore::delete);
datastore.delete(recordToDelete.getEuropeanaAggregation());
recordToDelete.getProvidedCHOs().forEach(datastore::delete);
recordToDelete.getProxies().forEach(datastore::delete);
}

// Done
return recordToDelete != null;

} catch (RuntimeException e) {
throw new IndexerRelatedIndexingException("Could not remove tombstone '" + rdfAbout + "'.", e);
}
}

/**
* <p>Removes all records that belong to a given dataset. For details on what parts of the record
* are removed, see the documentation of {@link #removeRecord(String)}.</p>
Expand Down
11 changes: 11 additions & 0 deletions metis-indexing/src/main/java/eu/europeana/indexing/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ TierResults indexAndGetTierCalculations(InputStream recordContent,
*/
boolean indexTombstone(String rdfAbout, DepublicationReason depublicationReason) throws IndexingException;

/**
* Removes the tombstone of the record with the given rdf:about value. This method also removes the associated objects (i.e.
* those objects that are always part of only one record and the removal of which can not invalidate references from other
* records):
*
* @param rdfAbout the id of the record
* @return information if tombstone really existed.
* @throws IndexingException in case something went wrong.
*/
boolean removeTombstone(String rdfAbout) throws IndexingException;

/**
* <p>
* Removes all records that belong to a given dataset. This method also removes the associated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public FullBeanImpl getTombstone(String rdfAbout) {
return this.connectionProvider.getIndexedRecordAccess().getTombstoneFullbean(rdfAbout);
}

@Override
public boolean removeTombstone(String rdfAbout) throws IndexerRelatedIndexingException {
return this.connectionProvider.getIndexedRecordAccess().removeTombstone(rdfAbout);
}

@Override
public boolean indexTombstone(String rdfAbout, DepublicationReason depublicationReason) throws IndexingException {
if (depublicationReason == DepublicationReason.LEGACY) {
Expand Down
Loading