mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-12 17:02:23 +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);
|
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
|
// If an entity being restored contains other **deleted** children entities, restore them
|
||||||
List<EntityRelationshipRecord> records =
|
List<EntityRelationshipRecord> records =
|
||||||
daoCollection.relationshipDAO().findTo(id.toString(), entityType, Relationship.CONTAINS.ordinal());
|
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
|
// Finally set entity deleted flag to false
|
||||||
LOG.info("Restoring the {} {}", entityType, id);
|
LOG.info("Restoring the {} {}", entityType, id);
|
||||||
T entity = dao.findEntityById(id, DELETED);
|
T original = dao.findEntityById(id, DELETED);
|
||||||
entity.setDeleted(false);
|
setFieldsInternal(original, putFields);
|
||||||
dao.update(entity.getId(), JsonUtils.pojoToJson(entity));
|
T updated = JsonUtils.readValue(JsonUtils.pojoToJson(original), entityClass);
|
||||||
return entity;
|
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) {
|
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 {
|
public Response restoreEntity(UriInfo uriInfo, SecurityContext securityContext, UUID id) throws IOException {
|
||||||
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.EDIT_ALL);
|
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.EDIT_ALL);
|
||||||
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
|
||||||
T entity = addHref(uriInfo, dao.restoreEntity(securityContext.getUserPrincipal().getName(), entityType, id));
|
PutResponse<T> response = dao.restoreEntity(securityContext.getUserPrincipal().getName(), entityType, id);
|
||||||
LOG.info("Restored {}:{}", Entity.getEntityTypeFromObject(entity), entity.getId());
|
addHref(uriInfo, response.getEntity());
|
||||||
return Response.ok(entity.getHref()).entity(entity).build();
|
LOG.info("Restored {}:{}", Entity.getEntityTypeFromObject(response.getEntity()), response.getEntity().getId());
|
||||||
|
return response.toResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String exportCsvInternal(SecurityContext securityContext, String name) throws IOException {
|
public String exportCsvInternal(SecurityContext securityContext, String name) throws IOException {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user