Skip to content

Commit

Permalink
update respective index with the assets (#13843)
Browse files Browse the repository at this point in the history
* update respective index with the assets

* checkstyle

* addressing comments

* add listorempty
  • Loading branch information
07Himank authored Nov 8, 2023
1 parent 04f6bc7 commit 1a14ac6
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
import static org.openmetadata.service.util.EntityUtil.entityReferenceMatch;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.jdbi.v3.sqlobject.transaction.Transaction;
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.entity.domains.DataProduct;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.domains.DataProductResource;
Expand Down Expand Up @@ -91,6 +95,18 @@ public void restorePatchAttributes(DataProduct original, DataProduct updated) {
updated.withDomain(original.getDomain()); // Domain can't be changed
}

@Override
protected void postUpdate(DataProduct original, DataProduct updated) {
super.postUpdate(original, updated);
Map<String, EntityReference> assetsMap = new HashMap<>();
listOrEmpty(original.getAssets()).forEach(asset -> assetsMap.put(asset.getId().toString(), asset));
listOrEmpty(updated.getAssets()).forEach(asset -> assetsMap.put(asset.getId().toString(), asset));
for (EntityReference assetRef : assetsMap.values()) {
EntityInterface asset = Entity.getEntity(assetRef, "*", Include.ALL);
searchRepository.updateEntity(asset);
}
}

public class DataProductUpdater extends EntityUpdater {
public DataProductUpdater(DataProduct original, DataProduct updated, Operation operation) {
super(original, updated, operation);
Expand Down

0 comments on commit 1a14ac6

Please sign in to comment.