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

union node validation ensures upstream attributes match Union node name #135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions src/utils/validation/UnionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export default class UnionNode {
error: 'The Union upstream nodes require attributes aligned',
};
}
if (this.upstreamAttributeNameAligned()) {
return {
isValid: false,
error:
'The Union upstream nodes require attribute to be equal to Union name',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesusGuerrero could this error message be made more explicit/detailed? Something like:
`The Union upstream nodes require attribute to be equal to the Union name. Currently, upstream node X has attributes named A, B and C; upstream node Y has attributes Z and ...". All these nodes should have an attribute called "

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this actually introduces a problem because now it is not possible for a node to participate in two union nodes. It's OK for now, but we need to work on #70 to fully address the issue consistently.

};
}
return { isValid: true };
}

Expand Down Expand Up @@ -67,6 +74,22 @@ export default class UnionNode {
});
return isInvalidAttributes;
}
upstreamAttributeNameAligned() {
const pipelineLinks = this.canvasController.getLinks(this.pipelineId);
const upstreamNodes = getImmediateUpstreamNodes(
this.nodeProps.nodeId,
pipelineLinks,
);
let isInvalidAttribute = false;
const uNode = this.nodes.find((no) => no.nodeId === this.nodeProps.nodeId);
upstreamNodes.forEach((n, i) => {
const node = this.nodes.find((no) => no.nodeId === n);
if (uNode.label !== node.renamed) {
isInvalidAttribute = true;
}
});
return isInvalidAttribute;
}
checkCardinality(nodeId) {
const inputPorts = this.canvasController.getNodeInputPorts(
nodeId,
Expand Down