mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-28 07:58:31 +00:00
[AlertNotication] Fix formatting (#15800)
* - Remove sourceHash from the Activity Feed - Update Test Case Page Uri Link * - Remove lifeCycle * - Add To Field Change List * - Add asset Url to conversations and Task Updates * - Make Redirect to Activity Feed Task Page
This commit is contained in:
parent
4a310e4e11
commit
5f9a565f3a
@ -53,11 +53,11 @@ public class EmailMessageDecorator implements MessageDecorator<EmailMessage> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn, String additionalParams) {
|
||||
public String getEntityUrl(String prefix, String fqn, String additionalParams) {
|
||||
return String.format(
|
||||
"<a href = '%s/%s/%s%s'>%s</a>",
|
||||
getSmtpSettings().getOpenMetadataUrl(),
|
||||
entityType,
|
||||
prefix,
|
||||
fqn.trim(),
|
||||
nullOrEmpty(additionalParams) ? "" : String.format("/%s", additionalParams),
|
||||
fqn.trim());
|
||||
|
||||
@ -51,11 +51,11 @@ public class FeedMessageDecorator implements MessageDecorator<FeedMessage> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn, String additionalParams) {
|
||||
public String getEntityUrl(String prefix, String fqn, String additionalParams) {
|
||||
return String.format(
|
||||
"[%s](/%s/%s%s)",
|
||||
fqn,
|
||||
entityType,
|
||||
prefix,
|
||||
fqn.trim(),
|
||||
nullOrEmpty(additionalParams) ? "" : String.format("/%s", additionalParams));
|
||||
}
|
||||
|
||||
@ -55,11 +55,11 @@ public class GChatMessageDecorator implements MessageDecorator<GChatMessage> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn, String additionalParams) {
|
||||
public String getEntityUrl(String prefix, String fqn, String additionalParams) {
|
||||
return String.format(
|
||||
"<%s/%s/%s%s|%s>",
|
||||
getSmtpSettings().getOpenMetadataUrl(),
|
||||
entityType,
|
||||
prefix,
|
||||
fqn.trim().replace(" ", "%20"),
|
||||
nullOrEmpty(additionalParams) ? "" : String.format("/%s", additionalParams),
|
||||
fqn.trim());
|
||||
|
||||
@ -55,12 +55,12 @@ public class MSTeamsMessageDecorator implements MessageDecorator<TeamsMessage> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityUrl(String entityType, String fqn, String additionalParams) {
|
||||
public String getEntityUrl(String prefix, String fqn, String additionalParams) {
|
||||
return String.format(
|
||||
"[%s](/%s/%s%s)",
|
||||
fqn.trim(),
|
||||
getSmtpSettings().getOpenMetadataUrl(),
|
||||
entityType,
|
||||
prefix,
|
||||
nullOrEmpty(additionalParams) ? "" : String.format("/%s", additionalParams));
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import org.openmetadata.schema.entity.feed.Thread;
|
||||
import org.openmetadata.schema.tests.TestCase;
|
||||
import org.openmetadata.schema.type.ChangeEvent;
|
||||
import org.openmetadata.schema.type.Include;
|
||||
import org.openmetadata.schema.type.ThreadType;
|
||||
import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.exception.UnhandledServerException;
|
||||
import org.openmetadata.service.resources.feeds.MessageParser;
|
||||
@ -60,7 +61,7 @@ public interface MessageDecorator<T> {
|
||||
|
||||
String getRemoveMarkerClose();
|
||||
|
||||
String getEntityUrl(String entityType, String fqn, String additionalInput);
|
||||
String getEntityUrl(String prefix, String fqn, String additionalInput);
|
||||
|
||||
T buildEntityMessage(ChangeEvent event);
|
||||
|
||||
@ -77,10 +78,8 @@ public interface MessageDecorator<T> {
|
||||
// Hande Test Case
|
||||
if (entityType.equals(Entity.TEST_CASE)) {
|
||||
TestCase testCase = (TestCase) entityInterface;
|
||||
MessageParser.EntityLink link = MessageParser.EntityLink.parse(testCase.getEntityLink());
|
||||
// TODO: this needs to be fixed no way to know the UI redirection
|
||||
return getEntityUrl(
|
||||
link.getEntityType(), link.getEntityFQN(), "profiler?activeTab=Data%20Quality");
|
||||
"incident-manager", testCase.getFullyQualifiedName(), "test-case-results");
|
||||
}
|
||||
|
||||
// Glossary Term
|
||||
@ -98,6 +97,38 @@ public interface MessageDecorator<T> {
|
||||
return getEntityUrl(entityType, fqn, "");
|
||||
}
|
||||
|
||||
default String buildThreadUrl(
|
||||
ThreadType threadType, String entityType, EntityInterface entityInterface) {
|
||||
String activeTab =
|
||||
threadType.equals(ThreadType.Task) ? "activity_feed/tasks" : "activity_feed/all";
|
||||
String fqn = entityInterface.getFullyQualifiedName();
|
||||
if (CommonUtil.nullOrEmpty(fqn)) {
|
||||
EntityInterface result =
|
||||
Entity.getEntity(entityType, entityInterface.getId(), "id", Include.NON_DELETED);
|
||||
fqn = result.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
// Hande Test Case
|
||||
if (entityType.equals(Entity.TEST_CASE)) {
|
||||
TestCase testCase = (TestCase) entityInterface;
|
||||
return getEntityUrl("incident-manager", testCase.getFullyQualifiedName(), "issues");
|
||||
}
|
||||
|
||||
// Glossary Term
|
||||
if (entityType.equals(Entity.GLOSSARY_TERM)) {
|
||||
// Glossary Term is a special case where the URL is different
|
||||
return getEntityUrl(Entity.GLOSSARY, fqn, activeTab);
|
||||
}
|
||||
|
||||
// Tag
|
||||
if (entityType.equals(Entity.TAG)) {
|
||||
// Tags need to be redirected to Classification Page
|
||||
return getEntityUrl("tags", fqn.split("\\.")[0], "");
|
||||
}
|
||||
|
||||
return getEntityUrl(entityType, fqn, activeTab);
|
||||
}
|
||||
|
||||
default T buildOutgoingMessage(ChangeEvent event) {
|
||||
if (event.getEntityType().equals(Entity.THREAD)) {
|
||||
return buildThreadMessage(event);
|
||||
@ -195,18 +226,21 @@ public interface MessageDecorator<T> {
|
||||
|
||||
String headerMessage = "";
|
||||
List<String> attachmentList = new ArrayList<>();
|
||||
|
||||
String assetUrl =
|
||||
getThreadAssetsUrl(thread.getType(), MessageParser.EntityLink.parse(thread.getAbout()));
|
||||
switch (thread.getType()) {
|
||||
case Conversation -> {
|
||||
switch (event.getEventType()) {
|
||||
case THREAD_CREATED -> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s started a conversation for asset %s",
|
||||
thread.getCreatedBy(), thread.getAbout());
|
||||
"@%s started a conversation for asset %s", thread.getCreatedBy(), assetUrl);
|
||||
attachmentList.add(replaceEntityLinks(thread.getMessage()));
|
||||
}
|
||||
case POST_CREATED -> {
|
||||
headerMessage = String.format("@%s posted a message", thread.getCreatedBy());
|
||||
headerMessage =
|
||||
String.format("@%s posted a message on asset %s", thread.getCreatedBy(), assetUrl);
|
||||
attachmentList.add(
|
||||
String.format(
|
||||
"@%s : %s", thread.getCreatedBy(), replaceEntityLinks(thread.getMessage())));
|
||||
@ -221,7 +255,9 @@ public interface MessageDecorator<T> {
|
||||
}
|
||||
case THREAD_UPDATED -> {
|
||||
headerMessage =
|
||||
String.format("@%s posted update on Conversation", thread.getUpdatedBy());
|
||||
String.format(
|
||||
"@%s posted update on Conversation for asset %s",
|
||||
thread.getUpdatedBy(), assetUrl);
|
||||
attachmentList.add(replaceEntityLinks(thread.getMessage()));
|
||||
}
|
||||
}
|
||||
@ -232,7 +268,7 @@ public interface MessageDecorator<T> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s created a Task for %s %s",
|
||||
thread.getCreatedBy(), entityLink.getEntityType(), entityUrl);
|
||||
thread.getCreatedBy(), entityLink.getEntityType(), assetUrl);
|
||||
attachmentList.add(String.format("Task Type : %s", thread.getTask().getType().value()));
|
||||
attachmentList.add(
|
||||
String.format(
|
||||
@ -246,8 +282,8 @@ public interface MessageDecorator<T> {
|
||||
case POST_CREATED -> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s posted a message on the Task with Id : %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId());
|
||||
"@%s posted a message on the Task with Id : %s for Asset %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId(), assetUrl);
|
||||
thread
|
||||
.getPosts()
|
||||
.forEach(
|
||||
@ -260,8 +296,8 @@ public interface MessageDecorator<T> {
|
||||
case THREAD_UPDATED -> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s posted update on the Task with Id : %s",
|
||||
thread.getUpdatedBy(), thread.getTask().getId());
|
||||
"@%s posted update on the Task with Id : %s for Asset %s",
|
||||
thread.getUpdatedBy(), thread.getTask().getId(), assetUrl);
|
||||
attachmentList.add(String.format("Task Type : %s", thread.getTask().getType().value()));
|
||||
attachmentList.add(
|
||||
String.format(
|
||||
@ -275,15 +311,15 @@ public interface MessageDecorator<T> {
|
||||
case TASK_CLOSED -> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s closed Task with Id : %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId());
|
||||
"@%s closed Task with Id : %s for Asset %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId(), assetUrl);
|
||||
attachmentList.add(String.format("Current Status : %s", thread.getTask().getStatus()));
|
||||
}
|
||||
case TASK_RESOLVED -> {
|
||||
headerMessage =
|
||||
String.format(
|
||||
"@%s resolved Task with Id : %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId());
|
||||
"@%s resolved Task with Id : %s for Asset %s",
|
||||
thread.getCreatedBy(), thread.getTask().getId(), assetUrl);
|
||||
attachmentList.add(String.format("Current Status : %s", thread.getTask().getStatus()));
|
||||
}
|
||||
}
|
||||
@ -341,6 +377,18 @@ public interface MessageDecorator<T> {
|
||||
return message;
|
||||
}
|
||||
|
||||
default String getThreadAssetsUrl(
|
||||
ThreadType threadType, MessageParser.EntityLink aboutEntityLink) {
|
||||
try {
|
||||
return this.buildThreadUrl(
|
||||
threadType,
|
||||
aboutEntityLink.getEntityType(),
|
||||
Entity.getEntity(aboutEntityLink, "id", Include.ALL));
|
||||
} catch (Exception ex) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getDateString(long epochTimestamp) {
|
||||
Instant instant = Instant.ofEpochSecond(epochTimestamp);
|
||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
|
||||
@ -55,11 +55,11 @@ public class SlackMessageDecorator implements MessageDecorator<SlackMessage> {
|
||||
return "~";
|
||||
}
|
||||
|
||||
public String getEntityUrl(String entityType, String fqn, String additionalParams) {
|
||||
public String getEntityUrl(String prefix, String fqn, String additionalParams) {
|
||||
return String.format(
|
||||
"<%s/%s/%s%s|%s>",
|
||||
getSmtpSettings().getOpenMetadataUrl(),
|
||||
entityType,
|
||||
prefix,
|
||||
fqn.trim().replaceAll(" ", "%20"),
|
||||
nullOrEmpty(additionalParams) ? "" : String.format("/%s", additionalParams),
|
||||
fqn.trim());
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
{
|
||||
"name": "matchAnyFieldChange",
|
||||
"effect": "exclude",
|
||||
"condition": "matchAnyFieldChange({'usageSummary'})"
|
||||
"condition": "matchAnyFieldChange({'usageSummary', 'sourceHash', 'lifeCycle'})"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -81,7 +81,9 @@
|
||||
{
|
||||
"name": "fieldChangeList",
|
||||
"input": [
|
||||
"usageSummary"
|
||||
"usageSummary",
|
||||
"sourceHash",
|
||||
"lifeCycle"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user