mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-07 13:07:22 +00:00
This commit is contained in:
parent
e1bfdf5ae7
commit
becdd38cae
@ -2461,7 +2461,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
||||
updated.setExperts(updatedExperts);
|
||||
}
|
||||
|
||||
private void updateReviewers() {
|
||||
protected void updateReviewers() {
|
||||
if (!supportsReviewers) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,6 +90,7 @@ import org.openmetadata.service.util.EntityUtil;
|
||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||
import org.openmetadata.service.util.FullyQualifiedName;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
import org.openmetadata.service.util.RestUtil;
|
||||
import org.openmetadata.service.util.WebsocketNotificationHandler;
|
||||
|
||||
@Slf4j
|
||||
@ -777,6 +778,33 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||
super(original, updated, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReviewers() {
|
||||
super.updateReviewers();
|
||||
|
||||
// adding the reviewer should add the person as assignee to the task
|
||||
if (updated.getStatus() == Status.DRAFT) {
|
||||
|
||||
EntityLink about = new EntityLink(GLOSSARY_TERM, updated.getFullyQualifiedName());
|
||||
FeedRepository feedRepository = Entity.getFeedRepository();
|
||||
Thread originalTask = feedRepository.getTask(about, TaskType.RequestApproval);
|
||||
|
||||
if (TaskStatus.Open.equals(originalTask.getTask().getStatus())) {
|
||||
|
||||
Thread updatedTask = JsonUtils.deepCopy(originalTask, Thread.class);
|
||||
updatedTask.getTask().withAssignees(updated.getReviewers());
|
||||
JsonPatch patch = JsonUtils.getJsonPatch(originalTask, updatedTask);
|
||||
|
||||
RestUtil.PatchResponse<Thread> thread =
|
||||
feedRepository.patchThread(
|
||||
null, originalTask.getId(), updatedTask.getUpdatedBy(), patch);
|
||||
|
||||
// Send WebSocket Notification
|
||||
WebsocketNotificationHandler.handleTaskNotification(thread.entity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transaction
|
||||
@Override
|
||||
public void entitySpecificUpdate() {
|
||||
|
||||
@ -283,6 +283,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
public static Role DATA_STEWARD_ROLE;
|
||||
public static EntityReference DATA_STEWARD_ROLE_REF;
|
||||
public static User DATA_CONSUMER;
|
||||
public static EntityReference DATA_CONSUMER_REF;
|
||||
public static Role DATA_CONSUMER_ROLE;
|
||||
public static EntityReference DATA_CONSUMER_ROLE_REF;
|
||||
public static Role ROLE1;
|
||||
|
||||
@ -436,6 +436,31 @@ public class GlossaryTermResourceTest extends EntityResourceTest<GlossaryTerm, C
|
||||
GlossaryTerm g2t4Updated = patchEntity(g2t4.getId(), json2, g2t4, authHeaders(USER1.getName()));
|
||||
assertEquals(Status.REJECTED, g2t4Updated.getStatus());
|
||||
assertApprovalTask(g2t4, TaskStatus.Closed); // The Request Approval task is closed
|
||||
|
||||
// Creating a glossary term g2t5 should be in `Draft` mode (because glossary has reviewers)
|
||||
// adding a new reviewer should add the person as assignee to the task
|
||||
|
||||
GlossaryTerm g2t5 = createTerm(glossary2, null, "g2t5");
|
||||
assertEquals(Status.DRAFT, g2t5.getStatus());
|
||||
assertApprovalTask(g2t5, TaskStatus.Open); // A Request Approval task is opened
|
||||
|
||||
String origJson = JsonUtils.pojoToJson(g2t5);
|
||||
|
||||
// Add reviewer DATA_CONSUMER in PATCH request
|
||||
g2t5.withReviewers(List.of(DATA_CONSUMER_REF, USER1_REF, USER2_REF));
|
||||
|
||||
ChangeDescription change = getChangeDescription(g2t5, MINOR_UPDATE);
|
||||
fieldAdded(change, "reviewers", List.of(DATA_CONSUMER_REF));
|
||||
g2t5 = patchEntityUsingFqnAndCheck(g2t5, origJson, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
|
||||
Thread approvalTask1 =
|
||||
assertApprovalTask(g2t5, TaskStatus.Open); // A Request Approval task is opened
|
||||
|
||||
// adding the reviewer should add the person as assignee to the task
|
||||
assertTrue(
|
||||
approvalTask1.getTask().getAssignees().stream()
|
||||
.anyMatch(assignee -> assignee.getId().equals(DATA_CONSUMER_REF.getId())),
|
||||
"The list of assignees does not contain the expected ID: " + DATA_CONSUMER_REF.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -170,6 +170,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
createRequest("user-data-consumer", "", "", null)
|
||||
.withRoles(List.of(DATA_CONSUMER_ROLE.getId()));
|
||||
DATA_CONSUMER = createEntity(create, ADMIN_AUTH_HEADERS);
|
||||
DATA_CONSUMER_REF = DATA_CONSUMER.getEntityReference();
|
||||
|
||||
// USER_TEAM21 is part of TEAM21
|
||||
create = createRequest(test, 2).withTeams(List.of(TEAM21.getId()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user