Skip to content

Commit

Permalink
resync indexes of dataAssets based on database & databaseSchema displ…
Browse files Browse the repository at this point in the history
…ayName change
  • Loading branch information
sonika-shah committed Sep 21, 2024
1 parent a36b041 commit e4c6db8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.csv.CSVPrinter;
Expand Down Expand Up @@ -105,6 +106,18 @@ public EntityInterface getParentEntity(Database entity, String fields) {
return Entity.getEntity(entity.getService(), fields, Include.ALL);
}

@Override
public void entityRelationshipReindex(Database original, Database updated) {
super.entityRelationshipReindex(original, updated);

// Update search indexes of assets and entity on database displayName change
if (!Objects.equals(original.getDisplayName(), updated.getDisplayName())) {
searchRepository
.getSearchClient()
.reindexAcrossIndices("database.fullyQualifiedName", original.getEntityReference());
}
}

@Override
public String exportToCsv(String name, String user) throws IOException {
Database database = getByName(null, name, Fields.EMPTY_FIELDS); // Validate database name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.csv.CSVPrinter;
Expand Down Expand Up @@ -179,6 +180,18 @@ private void populateDatabase(DatabaseSchema schema) {
.withServiceType(database.getServiceType());
}

@Override
public void entityRelationshipReindex(DatabaseSchema original, DatabaseSchema updated) {
super.entityRelationshipReindex(original, updated);

// Update search indexes of assets and entity on databaseSchema displayName change
if (!Objects.equals(original.getDisplayName(), updated.getDisplayName())) {
searchRepository
.getSearchClient()
.reindexAcrossIndices("databaseSchema.fullyQualifiedName", original.getEntityReference());
}
}

@Override
public String exportToCsv(String name, String user) throws IOException {
DatabaseSchema schema = getByName(null, name, Fields.EMPTY_FIELDS); // Validate database schema
Expand Down

0 comments on commit e4c6db8

Please sign in to comment.