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

kie-issues#237: Implement DMN 1.4 Boxed iterator expression #2243

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

danielzhe
Copy link
Contributor

Closes: apache/incubator-kie-issues#237
Closes: apache/incubator-kie-issues#238

Both tickets were made together because the iterator expression covers both as it is in the spec. See 10.2.1.10 Boxed iterator

kie-issues#238: Implement DMN 1.4 every/some -> in -> satisfies boxed expression

Co-authored-by: Tiago Bento <[email protected]>
Copy link
Contributor

@tiagobento tiagobento left a comment

Choose a reason for hiding this comment

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

@danielzhe Thanks for the PR! I left some comments inline.

return ret;
} else if (args.rowIndex === 2) {
if (prev.__$$element === "for") {
const ret: BoxedFor = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment "// Do not inline this variable for type safety. See microsoft/TypeScript#241"

Comment on lines 280 to 287
} else {
// Do not inline this variable for type safety. See https://github.com/microsoft/TypeScript/issues/241
const iterator: BoxedIterator = {
...prev,
satisfies: { expression: undefined! }, // SPEC DISCREPANCY
};
return iterator;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Defaulting to "every" and "some", while I think we should actively check for those types and throw an Error if anything else is found.

return iterator;
}
} else {
throw new Error("ConditionalExpression shouldn't have more than 3 rows.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong error message.

Comment on lines 332 to 357
else if (expression.__$$element === "for") {
const nestedExpressions = [expression.in.expression, expression.return.expression];
return (
resizingWidth ??
CONDITIONAL_EXPRESSION_LABEL_COLUMN_WIDTH +
Math.max(
CONDITIONAL_EXPRESSION_CLAUSE_COLUMN_MIN_WIDTH,
...nestedExpressions.map((e) => getExpressionResizingWidth(e, resizingWidths, widthsById))
) +
CONDITIONAL_EXPRESSION_EXTRA_WIDTH
);
}

// Every and Some
else if (expression.__$$element === "every" || expression.__$$element === "some") {
const nestedExpressions = [expression.in.expression, expression.satisfies.expression];
return (
resizingWidth ??
CONDITIONAL_EXPRESSION_LABEL_COLUMN_WIDTH +
Math.max(
CONDITIONAL_EXPRESSION_CLAUSE_COLUMN_MIN_WIDTH,
...nestedExpressions.map((e) => getExpressionResizingWidth(e, resizingWidths, widthsById))
) +
CONDITIONAL_EXPRESSION_EXTRA_WIDTH
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not using the ITERATOR_EXPRESSION constants.

Comment on lines 206 to 214
} else {
return (
<IteratorExpressionCell
iteratorClause={props.data[props.rowIndex]}
{...props}
parentElementId={parentElementId}
/>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Defaulting to this, while I think we should explicitly check for rowIndex being 1 and 2, as iterator expressions shouldn't have more than 3 rows.

} else {
if (expression.__$$element === "for") {
return "return";
} else return "satisfies";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Defaulting to "satisfies", while we should check for explicit cases we support and throw an error for all other unexpected cases.

const getIterableRowLabel = useCallback(
(rowNumber: number) => {
if (rowNumber === 0) {
return expression.__$$element;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using __$$element here is not ideal, as it is a coincidence that those two things have the same value. Please explicitly return the name of the expression based on what type of iterator it is.


const currentExpression = useMemo(() => {
if (typeof iteratorClause.child !== "string") {
return iteratorClause.child?.expression as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "as any"?

Comment on lines 44 to 51
expression: getNewExpression(),
},
};
} else {
return {
...prev,
satisfies: {
expression: getNewExpression(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not pass prev here, like you're doing at the in part?

Comment on lines 194 to 197
return {
...prev,
"@_iteratorVariable": updatedValue,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the same strategy of extracting the return value to a variable, explicitly typing it and adding the comment saying why this is necessary.

@tiagobento tiagobento removed the pr: waiting-for-review Waiting for peer reviews label Apr 16, 2024
Copy link
Contributor

@ljmotta ljmotta left a comment

Choose a reason for hiding this comment

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

@danielzhe Amazing new features. The code is looking good.

@tiagobento tiagobento merged commit 236931c into apache:main Apr 17, 2024
8 checks passed
@jaimeizuz
Copy link

Hi @ljmotta @tiagobento @danielzhe

I've just tested this new functionality and I'm getting the following exception:

{ "name": "Error", "message": "IteratorExpression can't have more than 3 rows.", "stack": "Error: IteratorExpression can't have more than 3 rows. at child (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4951260) at aa (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4331465) at Gs (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4383558) at Dl (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4370837) at Sl (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4370765) at kl (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4370628) at _l (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4367615) at https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4317387 at t.unstable_runWithPriority (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4533910) at Yr (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4317164) at Kr (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4317332) at $r (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4317267) at Ie (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4388077) at Qt (https://business-modeller-app.eu.ngrok.io/new-dmn-editor-envelope.js:2:4295958)" }

KIE.Sandbox.__.Untitled.dmn.-.Google.Chrome.2024-04-18.15-27-22.mp4

Build Version:
0.0.0 (daily-dev) @ 236931c (2024-04-18 08:31:17)
Kogito Runtimes Version:
999-20240414-SNAPSHOT
Quarkus Version:
3.2.10.Final
Dev deployments Base image URL:
quay.io/kie-tools/dev-deployment-base-image:daily-dev
Dev deployments Kogito Quarkus Blank App image URL:
quay.io/kie-tools/dev-deployment-kogito-quarkus-blank-app-image:daily-dev
Dev deployments DMN Form webapp image URL:
quay.io/kie-tools/dev-deployment-dmn-form-webapp-image:daily-dev
Extended Services version:
0.0.0
Commit SHA:
236931c

Google Chrome Version 123.0.6312.123 (Official Build) (64-bit) in Windows 10

@danielzhe
Copy link
Contributor Author

@jaimeizuz Ty for your report. It got broken in the code review, I'm already fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement DMN 1.4 every/some -> in -> satisfies boxed expression Implement DMN 1.4 Boxed iterator expression
4 participants