Skip to content

Commit

Permalink
fix(governance-workflows): defined interface in workflow schema
Browse files Browse the repository at this point in the history
- defined types for workflow nodes
- fixed updateEdge method in WorkflowDefinitionRepository
  • Loading branch information
sushi30 committed Jan 15, 2025
1 parent 195857a commit e9771bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.openmetadata.service.jdbi3;

import static org.openmetadata.service.util.EntityUtil.objectMatch;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -10,6 +8,8 @@
import lombok.extern.slf4j.Slf4j;
import org.jdbi.v3.sqlobject.transaction.Transaction;
import org.openmetadata.schema.governance.workflows.WorkflowDefinition;
import org.openmetadata.schema.governance.workflows.elements.EdgeDefinition;
import org.openmetadata.schema.governance.workflows.elements.WorkflowNodeDefinitionInterface;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.service.Entity;
import org.openmetadata.service.governance.workflows.Workflow;
Expand Down Expand Up @@ -95,27 +95,27 @@ private void updateTrigger() {
}

private void updateNodes() {
List<Object> addedNodes = new ArrayList<>();
List<Object> deletedNodes = new ArrayList<>();
List<WorkflowNodeDefinitionInterface> addedNodes = new ArrayList<>();
List<WorkflowNodeDefinitionInterface> deletedNodes = new ArrayList<>();
recordListChange(
"nodes",
(List<Object>) original.getNodes(),
(List<Object>) updated.getNodes(),
original.getNodes(),
updated.getNodes(),
addedNodes,
deletedNodes,
objectMatch);
WorkflowNodeDefinitionInterface::equals);
}

private void updateEdges() {
List<Object> addedEdges = new ArrayList<>();
List<Object> deletedEdges = new ArrayList<>();
List<EdgeDefinition> addedEdges = new ArrayList<>();
List<EdgeDefinition> deletedEdges = new ArrayList<>();
recordListChange(
"nodes",
(List<Object>) original.getNodes(),
(List<Object>) updated.getNodes(),
original.getEdges(),
updated.getEdges(),
addedEdges,
deletedEdges,
objectMatch);
EdgeDefinition::equals);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"description": "List of processes used on the workflow.",
"type": "array",
"items": {
"existingJavaType": "org.openmetadata.schema.governance.workflows.elements.WorkflowNodeDefinitionInterface",
"oneOf": [
{
"$ref": "../../governance/workflows/elements/nodes/automatedTask/checkEntityAttributesTask.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@
"description": "Workflow Trigger."
},
"nodes": {
"description": "List of nodes used on the workflow."
"description": "List of nodes used on the workflow.",
"type": "array",
"items": {
"type": "object",
"existingJavaType": "org.openmetadata.schema.governance.workflows.elements.WorkflowNodeDefinitionInterface"
}
},
"edges": {
"description": "List of edges that connect the workflow elements and guide its flow.",
Expand Down
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.
*/


/**
/**
* Defines a workflow, having all the different pieces and attributes.
*/
export interface WorkflowDefinition {
Expand Down Expand Up @@ -55,7 +53,7 @@ export interface WorkflowDefinition {
/**
* List of nodes used on the workflow.
*/
nodes?: any;
nodes?: { [key: string]: any }[];
/**
* Owners of this workflow definition.
*/
Expand Down

0 comments on commit e9771bd

Please sign in to comment.