Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve certification feed #19632

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.openmetadata.service.formatter.factory;

import static org.openmetadata.service.Entity.FIELD_ASSETS;
import static org.openmetadata.service.Entity.FIELD_CERTIFICATION;
import static org.openmetadata.service.Entity.FIELD_DESCRIPTION;
import static org.openmetadata.service.Entity.FIELD_DOMAIN;
import static org.openmetadata.service.Entity.FIELD_EXTENSION;
Expand All @@ -33,6 +34,7 @@
import org.openmetadata.service.formatter.entity.PipelineFormatter;
import org.openmetadata.service.formatter.entity.QueryFormatter;
import org.openmetadata.service.formatter.field.AssetsFieldFormatter;
import org.openmetadata.service.formatter.field.CertificationFormatter;
import org.openmetadata.service.formatter.field.CustomPropertiesFormatter;
import org.openmetadata.service.formatter.field.DefaultFieldFormatter;
import org.openmetadata.service.formatter.field.DescriptionFormatter;
Expand Down Expand Up @@ -73,6 +75,7 @@ public static DefaultFieldFormatter getFieldParserObject(
case FIELD_EXTENSION -> new CustomPropertiesFormatter(decorator, thread, fieldChange);
case TEST_RESULT_FIELD -> new TestCaseResultFormatter(decorator, thread, fieldChange);
case FIELD_ASSETS -> new AssetsFieldFormatter(decorator, thread, fieldChange);
case FIELD_CERTIFICATION -> new CertificationFormatter(decorator, thread, fieldChange);
default -> new DefaultFieldFormatter(decorator, thread, fieldChange);
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.openmetadata.service.formatter.field;

import org.openmetadata.schema.entity.feed.CertificationFeedInfo;
import org.openmetadata.schema.entity.feed.FeedInfo;
import org.openmetadata.schema.entity.feed.Thread;
import org.openmetadata.schema.type.FieldChange;
import org.openmetadata.service.formatter.decorators.MessageDecorator;

public class CertificationFormatter extends DefaultFieldFormatter {
private static final String HEADER_MESSAGE = "%s %s certification %s for asset %s";

public CertificationFormatter(
MessageDecorator<?> messageDecorator, Thread thread, FieldChange fieldChange) {
super(messageDecorator, thread, fieldChange);
String[] fieldChangeNameParts = fieldChange.getName().split("\\.");
if (fieldChangeNameParts.length > 1) {
this.fieldChangeName = fieldChangeNameParts[1];
} else {
this.fieldChangeName = "";
}
}

@Override
public String formatAddedField() {
String message = getHeaderForCertificationUpdate("", "Added", thread.getEntityUrlLink());
populateCertificationInfo(Thread.FieldOperation.ADDED, message);
return message;
}

@Override
public String formatUpdatedField() {
String message = getHeaderForCertificationUpdate("", "Updated", thread.getEntityUrlLink());
populateCertificationInfo(Thread.FieldOperation.UPDATED, message);
return message;
}

@Override
public String formatDeletedField() {
String message = getHeaderForCertificationUpdate("", "Deleted", thread.getEntityUrlLink());
populateCertificationInfo(Thread.FieldOperation.DELETED, message);
return message;
}

private void populateCertificationInfo(Thread.FieldOperation operation, String threadMessage) {
CertificationFeedInfo certificationFeedInfo =
new CertificationFeedInfo()
.withPreviousValue(fieldChange.getOldValue())
.withUpdatedValue(fieldChange.getNewValue());
FeedInfo feedInfo =
new FeedInfo()
.withHeaderMessage(
getHeaderForCertificationUpdate(
thread.getUpdatedBy(), operation.value(), thread.getEntityUrlLink()))
.withFieldName(fieldChangeName)
.withEntitySpecificInfo(certificationFeedInfo);
populateThreadFeedInfo(
thread, threadMessage, Thread.CardStyle.CERTIFICATION, operation, feedInfo);
}

private String getHeaderForCertificationUpdate(
String prefix, String eventTypeMessage, String entityUrl) {
return String.format(HEADER_MESSAGE, prefix, eventTypeMessage, fieldChangeName, entityUrl);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$id": "https://open-metadata.org/schema/entity/feed/certification.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "CertificationFeedInfo",
"javaType": "org.openmetadata.schema.entity.feed.CertificationFeedInfo",
"description": "This schema defines the certification addition/updation/deletion schema on feed.",
"type": "object",
"properties": {
"previousValue": {
"description": "Previous Certification details."
},
"updatedValue": {
"description": "Updated Certification details."
}
},
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@
"testCaseResult",
"customProperties",
"assets",
"domain"
"domain",
"certification"
],
"default": "default"
},
Expand All @@ -267,6 +268,9 @@
{
"$ref": "./assets.json"
},
{
"$ref": "./certification.json"
},
{
"$ref": "./customProperty.json"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const DomainSelectablTree: FC<DomainSelectableTreeProps> = ({
} else {
let retn: EntityReference[] = [];
if (selectedDomains.length > 0) {

const domain = getEntityReferenceFromEntity<Domain>(
selectedDomains[0],
EntityType.DOMAIN
Expand Down Expand Up @@ -97,10 +96,11 @@ const DomainSelectablTree: FC<DomainSelectableTreeProps> = ({

const onSelect = (selectedKeys: React.Key[]) => {
if (!isMultiple) {

const selectedData = [];
for (const item of selectedKeys) {
selectedData.push(findItemByFqn(domains, item as string, false) as Domain);
selectedData.push(
findItemByFqn(domains, item as string, false) as Domain
);
}

setSelectedDomains(selectedData);
Expand All @@ -113,12 +113,20 @@ const DomainSelectablTree: FC<DomainSelectableTreeProps> = ({
if (Array.isArray(checked)) {
const selectedData = [];
for (const item of checked) {
selectedData.push(findItemByFqn(domains, item as string, false) as Domain);
selectedData.push(
findItemByFqn(domains, item as string, false) as Domain
);
}

setSelectedDomains(selectedData);
} else {
setSelectedDomains([findItemByFqn(domains, checked.checked as unknown as string, false) as Domain]);
setSelectedDomains([
findItemByFqn(
domains,
checked.checked as unknown as string,
false
) as Domain,
]);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2025 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This schema defines the certification addition/updation/deletion schema on feed.
*/
export interface Certification {
/**
* Previous Certification details.
*/
previousValue?: any;
/**
* Updated Certification details.
*/
updatedValue?: any;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Collate.
* Copyright 2025 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -10,9 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/**
/**
* This schema defines the Thread entity. A Thread is a collection of posts made by the
* users. The first post that starts a thread is **about** a data asset **from** a user.
* Other users can respond to this post by creating new posts in the thread. Note that bot
Expand Down Expand Up @@ -139,6 +137,7 @@ export interface AnnouncementDetails {
*/
export enum CardStyle {
Assets = "assets",
Certification = "certification",
CustomProperties = "customProperties",
Default = "default",
Description = "description",
Expand Down Expand Up @@ -248,6 +247,8 @@ export interface FeedInfo {
/**
* This schema defines the schema for Assets addition/deletion Updates.
*
* This schema defines the certification addition/updation/deletion schema on feed.
*
* This schema defines the custom properties addition/deltion schema on feed.
*
* This schema defines the schema for Description Updates.
Expand All @@ -259,10 +260,14 @@ export interface FeedInfo {
export interface Info {
updatedAssets?: EntityReference[];
/**
* Previous Certification details.
*
* Previous Custom Property.
*/
previousValue?: any;
/**
* Updated Certification details.
*
* Updated Custom Property.
*/
updatedValue?: any;
Expand Down
Loading