mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-27 01:45:32 +00:00
GEN-1662 : Fix - on dashboard soft delete, chart should not be visible (#18283)
This commit is contained in:
parent
4ac6111893
commit
f10de7f4d2
@ -528,7 +528,7 @@ public class SearchRepository {
|
|||||||
} catch (Exception ie) {
|
} catch (Exception ie) {
|
||||||
LOG.error(
|
LOG.error(
|
||||||
String.format(
|
String.format(
|
||||||
"Issue in Creating new search document for entityType [%s]. Reason[%s], Cause[%s], Stack [%s]",
|
"Issue in deleting new search document for entityType [%s]. Reason[%s], Cause[%s], Stack [%s]",
|
||||||
entityType, ie.getMessage(), ie.getCause(), ExceptionUtils.getStackTrace(ie)));
|
entityType, ie.getMessage(), ie.getCause(), ExceptionUtils.getStackTrace(ie)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,6 +637,16 @@ public class SearchRepository {
|
|||||||
new ImmutablePair<>(
|
new ImmutablePair<>(
|
||||||
REMOVE_TAGS_CHILDREN_SCRIPT,
|
REMOVE_TAGS_CHILDREN_SCRIPT,
|
||||||
Collections.singletonMap("fqn", entity.getFullyQualifiedName())));
|
Collections.singletonMap("fqn", entity.getFullyQualifiedName())));
|
||||||
|
case Entity.DASHBOARD -> {
|
||||||
|
String scriptTxt =
|
||||||
|
String.format(
|
||||||
|
"if (ctx._source.dashboards.size() == 1) { ctx._source.put('deleted', '%s') }",
|
||||||
|
true);
|
||||||
|
searchClient.softDeleteOrRestoreChildren(
|
||||||
|
indexMapping.getChildAliases(clusterAlias),
|
||||||
|
scriptTxt,
|
||||||
|
List.of(new ImmutablePair<>("dashboards.id", docId)));
|
||||||
|
}
|
||||||
case Entity.TEST_SUITE -> {
|
case Entity.TEST_SUITE -> {
|
||||||
TestSuite testSuite = (TestSuite) entity;
|
TestSuite testSuite = (TestSuite) entity;
|
||||||
if (Boolean.TRUE.equals(testSuite.getExecutable())) {
|
if (Boolean.TRUE.equals(testSuite.getExecutable())) {
|
||||||
@ -687,6 +697,16 @@ public class SearchRepository {
|
|||||||
indexMapping.getChildAliases(clusterAlias),
|
indexMapping.getChildAliases(clusterAlias),
|
||||||
scriptTxt,
|
scriptTxt,
|
||||||
List.of(new ImmutablePair<>("service.id", docId)));
|
List.of(new ImmutablePair<>("service.id", docId)));
|
||||||
|
case Entity.DASHBOARD -> {
|
||||||
|
scriptTxt =
|
||||||
|
String.format(
|
||||||
|
"if (ctx._source.dashboards.size() == 1) { ctx._source.put('deleted', '%s') }",
|
||||||
|
delete);
|
||||||
|
searchClient.softDeleteOrRestoreChildren(
|
||||||
|
indexMapping.getChildAliases(clusterAlias),
|
||||||
|
scriptTxt,
|
||||||
|
List.of(new ImmutablePair<>("dashboards.id", docId)));
|
||||||
|
}
|
||||||
default -> searchClient.softDeleteOrRestoreChildren(
|
default -> searchClient.softDeleteOrRestoreChildren(
|
||||||
indexMapping.getChildAliases(clusterAlias),
|
indexMapping.getChildAliases(clusterAlias),
|
||||||
scriptTxt,
|
scriptTxt,
|
||||||
|
@ -1178,7 +1178,6 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void updateSearch(UpdateRequest updateRequest) {
|
public void updateSearch(UpdateRequest updateRequest) {
|
||||||
if (updateRequest != null) {
|
if (updateRequest != null) {
|
||||||
updateRequest.docAsUpsert(true);
|
|
||||||
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
LOG.debug(SENDING_REQUEST_TO_ELASTIC_SEARCH, updateRequest);
|
LOG.debug(SENDING_REQUEST_TO_ELASTIC_SEARCH, updateRequest);
|
||||||
client.update(updateRequest, RequestOptions.DEFAULT);
|
client.update(updateRequest, RequestOptions.DEFAULT);
|
||||||
@ -1568,6 +1567,7 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
if (isClientAvailable) {
|
if (isClientAvailable) {
|
||||||
UpdateRequest updateRequest = new UpdateRequest(indexName, docId);
|
UpdateRequest updateRequest = new UpdateRequest(indexName, docId);
|
||||||
updateRequest.doc(doc, XContentType.JSON);
|
updateRequest.doc(doc, XContentType.JSON);
|
||||||
|
updateRequest.docAsUpsert(true);
|
||||||
updateSearch(updateRequest);
|
updateSearch(updateRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1577,6 +1577,7 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
if (isClientAvailable) {
|
if (isClientAvailable) {
|
||||||
UpdateRequest updateRequest = new UpdateRequest(indexName, docId);
|
UpdateRequest updateRequest = new UpdateRequest(indexName, docId);
|
||||||
updateRequest.doc(doc, XContentType.JSON);
|
updateRequest.doc(doc, XContentType.JSON);
|
||||||
|
updateRequest.docAsUpsert(true);
|
||||||
updateSearch(updateRequest);
|
updateSearch(updateRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user