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

Added dataProduct version on DATA_PRODUCT_ACTIVITY_COMPLETED event #195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,13 @@ private Activity stopActivity(Activity activity, boolean success) {
}

ObjectNode activityOutputNode = ObjectMapperFactory.JSON_MAPPER.createObjectNode();
DataProductVersionDPDS dataProductVersion = readDataProductVersion(activity);

if (success) {
activity.setStatus(ActivityStatus.PROCESSED);
lifecycleService.createLifecycle(activity);
activity = saveActivity(activity);

DataProductVersionDPDS dataProductVersion = readDataProductVersion(activity);
if (!policyServiceProxy.isContextuallyCoherent(mapper.toResource(activity), dataProductVersion)) {
// TODO: replace this exception with something else
throw new InternalServerException(
Expand All @@ -272,7 +273,7 @@ private Activity stopActivity(Activity activity, boolean success) {
activity = saveActivity(activity);
}

devOpsNotificationServiceProxy.notifyActivityCompletion(mapper.toResource(activity));
devOpsNotificationServiceProxy.notifyActivityCompletion(mapper.toResource(activity), dataProductVersion);

return activity;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.opendatamesh.platform.pp.devops.server.services.proxies;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.opendatamesh.dpds.model.DataProductVersionDPDS;
import org.opendatamesh.platform.core.commons.servers.exceptions.BadGatewayException;
import org.opendatamesh.platform.core.commons.servers.exceptions.InternalServerException;
import org.opendatamesh.platform.core.commons.servers.exceptions.ODMApiCommonErrors;
Expand Down Expand Up @@ -54,13 +57,19 @@ public void notifyActivityStart(ActivityResource activity) {
}
}

public void notifyActivityCompletion(ActivityResource activity) {
public void notifyActivityCompletion(ActivityResource activity, DataProductVersionDPDS dataProductVersion) {
ObjectNode afterState = mapper.createObjectNode();
JsonNode activityNode = mapper.valueToTree(activity);
JsonNode dataProductVersionNode = mapper.valueToTree(dataProductVersion);
afterState.set("activity", activityNode);
afterState.set("dataProductVersion", dataProductVersionNode);

if(notificationServiceActive) {
EventResource eventResource = buildActivityEvent(
EventType.DATA_PRODUCT_ACTIVITY_COMPLETED,
activity.getId().toString(),
null,
activity
afterState
);
notifyActivityEvent(eventResource);
}
Expand Down