mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 19:18:05 +00:00
fixed elastic search update issue when entity is restored (#11488)
Co-authored-by: Himank Mehta <himankmehta@Himanks-MacBook-Air.local> Co-authored-by: Mohit Yadav <105265192+mohityadav766@users.noreply.github.com>
This commit is contained in:
parent
98201724c3
commit
196681b499
@ -1047,7 +1047,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
return RestUtil.getHref(uriInfo, collectionPath, id);
|
||||
}
|
||||
|
||||
public T restoreEntity(String updatedBy, String entityType, UUID id) throws IOException {
|
||||
public PutResponse<T> restoreEntity(String updatedBy, String entityType, UUID id) throws IOException {
|
||||
// If an entity being restored contains other **deleted** children entities, restore them
|
||||
List<EntityRelationshipRecord> records =
|
||||
daoCollection.relationshipDAO().findTo(id.toString(), entityType, Relationship.CONTAINS.ordinal());
|
||||
@ -1062,10 +1062,15 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
|
||||
// Finally set entity deleted flag to false
|
||||
LOG.info("Restoring the {} {}", entityType, id);
|
||||
T entity = dao.findEntityById(id, DELETED);
|
||||
entity.setDeleted(false);
|
||||
dao.update(entity.getId(), JsonUtils.pojoToJson(entity));
|
||||
return entity;
|
||||
T original = dao.findEntityById(id, DELETED);
|
||||
setFieldsInternal(original, putFields);
|
||||
T updated = JsonUtils.readValue(JsonUtils.pojoToJson(original), entityClass);
|
||||
updated.setUpdatedBy(updatedBy);
|
||||
updated.setUpdatedAt(System.currentTimeMillis());
|
||||
EntityUpdater updater = getUpdater(original, updated, Operation.PUT);
|
||||
updater.update();
|
||||
String change = updater.fieldsChanged() ? RestUtil.ENTITY_UPDATED : RestUtil.ENTITY_NO_CHANGE;
|
||||
return new PutResponse<>(Status.OK, updated, change);
|
||||
}
|
||||
|
||||
public void addRelationship(UUID fromId, UUID toId, String fromEntity, String toEntity, Relationship relationship) {
|
||||
|
||||
@ -249,9 +249,10 @@ public abstract class EntityResource<T extends EntityInterface, K extends Entity
|
||||
public Response restoreEntity(UriInfo uriInfo, SecurityContext securityContext, UUID id) throws IOException {
|
||||
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.EDIT_ALL);
|
||||
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
||||
T entity = addHref(uriInfo, dao.restoreEntity(securityContext.getUserPrincipal().getName(), entityType, id));
|
||||
LOG.info("Restored {}:{}", Entity.getEntityTypeFromObject(entity), entity.getId());
|
||||
return Response.ok(entity.getHref()).entity(entity).build();
|
||||
PutResponse<T> response = dao.restoreEntity(securityContext.getUserPrincipal().getName(), entityType, id);
|
||||
addHref(uriInfo, response.getEntity());
|
||||
LOG.info("Restored {}:{}", Entity.getEntityTypeFromObject(response.getEntity()), response.getEntity().getId());
|
||||
return response.toResponse();
|
||||
}
|
||||
|
||||
public String exportCsvInternal(SecurityContext securityContext, String name) throws IOException {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user