rajalakshmys-27 commented on code in PR #3557:
URL:
https://github.com/apache/incubator-kie-tools/pull/3557#discussion_r3199450458
##########
packages/bpmn-editor-envelope/src/customTasks/MilestoneTask.tsx:
##########
@@ -86,13 +94,83 @@ export function getMilestoneTask(i18n:
BpmnEditorEnvelopeI18n): CustomTask {
iconSvgElement: MILESTONE_TASK_ICON,
propertiesPanelComponent: MilestoneTaskProperties,
matches: (task) => task["@_drools:taskName"] === "Milestone",
- produce: () => ({
- __$$element: "task",
- "@_id": generateUuid(),
- "@_drools:taskName": "Milestone",
- "@_name": i18n.milestone,
- }),
- dataInputReservedNames: [],
+ produce: () => {
+ const conditionInputId = generateUuid();
+ const taskNameInputId = generateUuid();
+ return {
+ __$$element: "task",
+ "@_id": generateUuid(),
+ "@_drools:taskName": "Milestone",
+ "@_name": i18n.milestone,
+ ioSpecification: {
+ "@_id": generateUuid(),
+ dataInput: [
+ {
+ "@_id": conditionInputId,
+ "@_name":
MILESTONE_TASK_IO_SPECIFICATION_DATA_INPUTS_CONSTANTS.CONDITION,
+ "@_drools:dtype": "String",
+ },
+ {
+ "@_id": taskNameInputId,
+ "@_name":
MILESTONE_TASK_IO_SPECIFICATION_DATA_INPUTS_CONSTANTS.TASK_NAME,
+ "@_drools:dtype": "Object",
+ },
+ ],
+ inputSet: [
+ {
+ "@_id": generateUuid(),
+ dataInputRefs: [{ __$$text: conditionInputId }, { __$$text:
taskNameInputId }],
+ },
+ ],
+ dataOutput: [],
+ outputSet: [
+ {
+ "@_id": generateUuid(),
+ dataOutputRefs: [],
+ },
+ ],
+ },
+ dataInputAssociation: [
+ {
+ "@_id": generateUuid(),
+ targetRef: { __$$text: taskNameInputId },
+ sourceRef: [],
+ assignment: [
+ {
+ "@_id": generateUuid(),
+ from: {
+ "@_id": generateUuid(),
+ "@_xsi:type": "tFormalExpression",
+ __$$text: MILESTONE_TASK_VALUES.TASK_NAME_VALUE,
+ } as any,
+ to: { "@_id": generateUuid(), __$$text: taskNameInputId },
+ },
+ ],
+ },
+ ],
+ dataOutputAssociation: [],
+ };
+ },
+ onAdded: (state, task) => {
+ const { itemDefinition: stringItemDefinition } =
addOrGetItemDefinitions({
+ definitions: state.bpmn.model.definitions,
+ dataType: DEFAULT_DATA_TYPES.STRING,
+ });
+
+ const { itemDefinition: objectItemDefinition } =
addOrGetItemDefinitions({
+ definitions: state.bpmn.model.definitions,
+ dataType: DEFAULT_DATA_TYPES.OBJECT,
+ });
+
+ if (task.ioSpecification?.dataInput?.[0]) {
+ task.ioSpecification.dataInput[0]["@_itemSubjectRef"] =
stringItemDefinition["@_id"];
+ }
+
+ if (task.ioSpecification?.dataInput?.[1]) {
+ task.ioSpecification.dataInput[1]["@_itemSubjectRef"] =
objectItemDefinition["@_id"];
+ }
Review Comment:
Refactored to use `setInputAndOutputDataMapping` in `onAdded()`, simplified
`produce()` to just create the basic task structure, moved I/O logic to
`onAdded()`, and replaced hardcoded strings with `DEFAULT_DATA_TYPES` and
`MILESTONE_TASK_VALUES` constants. Much cleaner and handles morphing correctly.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]