This is an automated email from the ASF dual-hosted git repository.
thiagoelg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new df77cd2d75b kie-issues#3615: BPMN Editor: Message type once assigned
cannot be cleared (#3616)
df77cd2d75b is described below
commit df77cd2d75bb308fdeb66c8bda6fdd0592d2c9f3
Author: Kbowers <[email protected]>
AuthorDate: Wed Jun 3 22:43:57 2026 +0200
kie-issues#3615: BPMN Editor: Message type once assigned cannot be cleared
(#3616)
---
.../src/mutations/addOrGetCorrelations.ts | 172 ++++++++++
.../src/mutations/addOrGetItemDefinitions.ts | 4 +-
.../bpmn-editor/src/mutations/addOrGetMessages.ts | 39 ++-
.../src/mutations/deleteCorrelations.ts | 146 +++++++++
.../src/mutations/renameCorrelations.ts | 153 +++++++++
.../src/mutations/renameGlobalProperties.ts | 42 +++
.../bpmn-editor/src/mutations/renameMessage.ts | 63 ++++
.../src/propertiesPanel/GlobalProperties.tsx | 17 +-
.../propertiesPanel/correlations/Correlations.tsx | 364 +++++++--------------
.../ItemDefinitionRefSelector.css | 6 +
.../ItemDefinitionRefSelector.tsx | 10 +-
.../propertiesManager/PropertiesManager.tsx | 71 +---
.../changeStartEventProperties.spec.ts | 33 ++
13 files changed, 770 insertions(+), 350 deletions(-)
diff --git a/packages/bpmn-editor/src/mutations/addOrGetCorrelations.ts
b/packages/bpmn-editor/src/mutations/addOrGetCorrelations.ts
new file mode 100644
index 00000000000..26b8748da06
--- /dev/null
+++ b/packages/bpmn-editor/src/mutations/addOrGetCorrelations.ts
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { BPMN20__tDefinitions } from
"@kie-tools/bpmn-marshaller/dist/schemas/bpmn-2_0/ts-gen/types";
+import { generateUuid } from
"@kie-tools/xyflow-react-kie-diagram/dist/uuid/uuid";
+import { Normalized } from "../normalization/normalize";
+import { addOrGetProcessAndDiagramElements } from
"./addOrGetProcessAndDiagramElements";
+
+export function addCorrelationProperty({
+ definitions,
+ propertyId,
+ propertyName,
+ propertyType,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ propertyName: string;
+ propertyType?: string;
+}): void {
+ definitions.rootElement ??= [];
+ definitions.rootElement.push({
+ __$$element: "correlationProperty",
+ "@_id": propertyId,
+ "@_name": propertyName,
+ "@_type": propertyType,
+ correlationPropertyRetrievalExpression: [],
+ });
+}
+
+export function addCorrelationKey({
+ definitions,
+ keyId,
+ keyName,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+ keyName: string;
+}): void {
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+
+ definitions.rootElement ??= [];
+ let collaboration = definitions.rootElement.find((e) => e.__$$element ===
"collaboration");
+ if (!collaboration) {
+ collaboration = {
+ "@_id": generateUuid(),
+ __$$element: "collaboration",
+ participant: [
+ {
+ "@_id": generateUuid(),
+ "@_name": "Pool Participant",
+ "@_processRef": process["@_id"],
+ },
+ ],
+ };
+ definitions.rootElement.push(collaboration);
+ }
+
+ collaboration.correlationKey ??= [];
+ collaboration.correlationKey.push({
+ "@_id": keyId,
+ "@_name": keyName,
+ });
+}
+
+export function addMessageBindingToProperty({
+ definitions,
+ propertyId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((e) => e.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+
+ if (property) {
+ property.correlationPropertyRetrievalExpression ??= [];
+ property.correlationPropertyRetrievalExpression.push({
+ "@_id": generateUuid(),
+ "@_messageRef": undefined as any,
+ messagePath: {
+ "@_id": generateUuid(),
+ "@_evaluatesToTypeRef": property["@_type"],
+ __$$text: "",
+ },
+ });
+ }
+}
+
+export function addPropertyToCorrelationKey({
+ definitions,
+ keyId,
+ propertyId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+ propertyId: string;
+}): void {
+ const key = definitions.rootElement
+ ?.find((e) => e.__$$element === "collaboration")
+ ?.correlationKey?.find((k) => k["@_id"] === keyId);
+
+ if (key) {
+ key.correlationPropertyRef ??= [];
+ key.correlationPropertyRef.push({ __$$text: propertyId });
+
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ for (const subs of process.correlationSubscription ?? []) {
+ if (subs["@_correlationKeyRef"] === keyId) {
+ subs.correlationPropertyBinding ??= [];
+ subs.correlationPropertyBinding?.push({
+ "@_id": generateUuid(),
+ "@_correlationPropertyRef": propertyId,
+ dataPath: {
+ "@_id": generateUuid(),
+ __$$text: "",
+ },
+ });
+ }
+ }
+ }
+}
+
+export function addSubscription({
+ definitions,
+ keyId,
+ selectedKey,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+ selectedKey: any;
+}): void {
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ process.correlationSubscription ??= [];
+ const propertiesById = new Map(
+ (definitions.rootElement ?? []).filter((e) => e.__$$element ===
"correlationProperty").map((p) => [p["@_id"], p])
+ );
+ process.correlationSubscription?.push({
+ "@_id": generateUuid(),
+ "@_correlationKeyRef": keyId,
+ correlationPropertyBinding: (selectedKey!.correlationPropertyRef ??
[]).map((propRef: any) => {
+ const property = propertiesById.get(propRef.__$$text);
+ const propertyType = property && property.__$$element ===
"correlationProperty" ? property["@_type"] : undefined;
+ return {
+ "@_id": generateUuid(),
+ "@_correlationPropertyRef": propRef.__$$text,
+ dataPath: {
+ "@_id": generateUuid(),
+ "@_language": "java",
+ "@_evaluatesToTypeRef": propertyType,
+ __$$text: "",
+ },
+ };
+ }),
+ });
+}
diff --git a/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
b/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
index bf9d96a8f45..80225d6e7ff 100644
--- a/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
+++ b/packages/bpmn-editor/src/mutations/addOrGetItemDefinitions.ts
@@ -35,11 +35,9 @@ export const DEFAULT_DATA_TYPES = {
export function addOrGetItemDefinitions({
definitions,
dataType,
- id,
}: {
definitions: Normalized<BPMN20__tDefinitions>;
dataType: string;
- id?: string;
}): {
itemDefinition:
ElementFilter<Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>,
"itemDefinition">;
} {
@@ -58,7 +56,7 @@ export function addOrGetItemDefinitions({
"itemDefinition"
> = {
__$$element: "itemDefinition",
- "@_id": id ?? generateUuid(),
+ "@_id": generateUuid(),
"@_structureRef": dataType,
};
diff --git a/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
b/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
index 490cc4da7e7..196c6c7f004 100644
--- a/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
+++ b/packages/bpmn-editor/src/mutations/addOrGetMessages.ts
@@ -27,6 +27,28 @@ import { addOrGetItemDefinitions, DEFAULT_DATA_TYPES } from
"./addOrGetItemDefin
// Reserved ID for the shared ItemDefinition used by all messages and linked
by the message @_itemRef.
export const RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES =
"__messageItemDefinition";
+export function createReservedItemDefinitionForMessages({
+ definitions,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+}): void {
+ definitions.rootElement ??= [];
+ const itemDefinitions = definitions.rootElement.filter((s) => s.__$$element
=== "itemDefinition");
+ const reservedExists = itemDefinitions.some((e) => e["@_id"] ===
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES);
+
+ if (!reservedExists) {
+ const newItemDefinition: ElementFilter<
+ Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>,
+ "itemDefinition"
+ > = {
+ __$$element: "itemDefinition",
+ "@_id": RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES,
+ "@_structureRef": "",
+ };
+ definitions.rootElement.push(newItemDefinition);
+ }
+}
+
export function addOrGetMessages({
definitions,
messageName,
@@ -50,22 +72,7 @@ export function addOrGetMessages({
});
itemDefinitionId = itemDefinition["@_id"];
} else {
- const itemDefinitions = definitions.rootElement.filter((s) =>
s.__$$element === "itemDefinition");
- const itemDefinitionForMessages = itemDefinitions.find(
- (s) => s["@_id"] === RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
- );
-
- if (!itemDefinitionForMessages) {
- const newItemDefinition: ElementFilter<
- Unpacked<Normalized<BPMN20__tDefinitions["rootElement"]>>,
- "itemDefinition"
- > = {
- __$$element: "itemDefinition",
- "@_id": RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES,
- "@_structureRef": "",
- };
- definitions.rootElement.push(newItemDefinition);
- }
+ createReservedItemDefinitionForMessages({ definitions });
itemDefinitionId = RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES;
}
diff --git a/packages/bpmn-editor/src/mutations/deleteCorrelations.ts
b/packages/bpmn-editor/src/mutations/deleteCorrelations.ts
new file mode 100644
index 00000000000..a1e0b0095be
--- /dev/null
+++ b/packages/bpmn-editor/src/mutations/deleteCorrelations.ts
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { BPMN20__tDefinitions } from
"@kie-tools/bpmn-marshaller/dist/schemas/bpmn-2_0/ts-gen/types";
+import { Normalized } from "../normalization/normalize";
+import { addOrGetProcessAndDiagramElements } from
"./addOrGetProcessAndDiagramElements";
+import { deleteOrphanedCorrelationSubscriptions } from
"./deleteOrphanedCorrelationSubscriptions";
+import { deleteUnusedItemDefinitions } from "./deleteItemDefinition";
+
+export function deleteCorrelationProperty({
+ definitions,
+ propertyId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+}): void {
+ definitions.rootElement ??= [];
+ definitions.rootElement = definitions.rootElement?.filter((e) => e["@_id"]
!== propertyId);
+
+ definitions.rootElement
+ ?.filter((e) => e.__$$element === "collaboration")
+ .forEach((collaboration) => {
+ if (collaboration.__$$element === "collaboration") {
+ collaboration.correlationKey?.forEach((key) => {
+ if (key.correlationPropertyRef) {
+ key.correlationPropertyRef = key.correlationPropertyRef.filter(
+ (propRef) => propRef.__$$text !== propertyId
+ );
+ }
+ });
+ collaboration.correlationKey = collaboration.correlationKey?.filter(
+ (key) => key.correlationPropertyRef &&
key.correlationPropertyRef.length > 0
+ );
+ }
+ });
+
+ definitions.rootElement = definitions.rootElement?.filter((e) => {
+ if (e.__$$element === "collaboration") {
+ return e.correlationKey && e.correlationKey.length > 0;
+ }
+ return true;
+ });
+
+ deleteOrphanedCorrelationSubscriptions({ definitions });
+ deleteUnusedItemDefinitions({ definitions });
+}
+
+export function deleteCorrelationKey({
+ definitions,
+ keyId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+}): void {
+ const collaboration = definitions.rootElement?.find((e) => e.__$$element ===
"collaboration");
+ if (collaboration) {
+ collaboration.correlationKey = collaboration.correlationKey?.filter((k) =>
k["@_id"] !== keyId);
+ }
+
+ definitions.rootElement = definitions.rootElement?.filter((e) => {
+ if (e.__$$element === "collaboration") {
+ return e.correlationKey && e.correlationKey.length > 0;
+ }
+ return true;
+ });
+
+ deleteOrphanedCorrelationSubscriptions({ definitions });
+}
+
+export function deletePropertyBinding({
+ definitions,
+ propertyId,
+ bindingIndex,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ bindingIndex: number;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((p) => p.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+
+ if (property) {
+ property.correlationPropertyRetrievalExpression.splice(bindingIndex, 1);
+ deleteUnusedItemDefinitions({ definitions });
+ }
+}
+
+export function deletePropertyFromKey({
+ definitions,
+ keyId,
+ propertyIndex,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+ propertyIndex: number;
+}): void {
+ const collaboration = definitions.rootElement?.find((e) => e.__$$element ===
"collaboration");
+ const key =
+ collaboration && collaboration.__$$element === "collaboration"
+ ? collaboration.correlationKey?.find((k) => k["@_id"] === keyId)
+ : undefined;
+
+ if (key) {
+ key.correlationPropertyRef ??= [];
+ const removedCorrelationPropertyRef =
key.correlationPropertyRef[propertyIndex];
+ key.correlationPropertyRef.splice(propertyIndex, 1);
+
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ process.correlationSubscription
+ ?.filter((subs) => subs["@_correlationKeyRef"] === keyId)
+ .forEach((subs) => {
+ subs.correlationPropertyBinding =
subs.correlationPropertyBinding?.filter(
+ (b) => b["@_correlationPropertyRef"] !==
removedCorrelationPropertyRef.__$$text
+ );
+ });
+ }
+}
+
+export function deleteSubscription({
+ definitions,
+ subscriptionId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ subscriptionId: string;
+}): void {
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ process.correlationSubscription ??= [];
+ process.correlationSubscription =
process.correlationSubscription.filter((subs) => subs["@_id"] !==
subscriptionId);
+}
diff --git a/packages/bpmn-editor/src/mutations/renameCorrelations.ts
b/packages/bpmn-editor/src/mutations/renameCorrelations.ts
new file mode 100644
index 00000000000..97ef51502b4
--- /dev/null
+++ b/packages/bpmn-editor/src/mutations/renameCorrelations.ts
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { BPMN20__tDefinitions } from
"@kie-tools/bpmn-marshaller/dist/schemas/bpmn-2_0/ts-gen/types";
+import { Normalized } from "../normalization/normalize";
+import { addOrGetProcessAndDiagramElements } from
"./addOrGetProcessAndDiagramElements";
+import { deleteUnusedItemDefinitions } from "./deleteItemDefinition";
+
+export function updateCorrelationPropertyName({
+ definitions,
+ propertyId,
+ newName,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ newName: string;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((e) => e.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+
+ if (property) {
+ property["@_name"] = newName;
+ }
+}
+
+export function updateCorrelationPropertyType({
+ definitions,
+ propertyId,
+ newItemDefinitionRef,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ newItemDefinitionRef: string | undefined;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((e) => e.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+
+ if (property) {
+ property["@_type"] = newItemDefinitionRef;
+ property.correlationPropertyRetrievalExpression.forEach((cpre) => {
+ if (cpre.messagePath) {
+ cpre.messagePath["@_evaluatesToTypeRef"] = newItemDefinitionRef;
+ }
+ });
+
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ process.correlationSubscription?.forEach((subscription) => {
+ subscription.correlationPropertyBinding
+ ?.filter((binding) => binding["@_correlationPropertyRef"] ===
propertyId)
+ .forEach((binding) => {
+ if (binding.dataPath) {
+ binding.dataPath["@_evaluatesToTypeRef"] = newItemDefinitionRef;
+ }
+ });
+ });
+
+ deleteUnusedItemDefinitions({ definitions });
+ }
+}
+
+export function updateCorrelationKeyName({
+ definitions,
+ keyId,
+ newName,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ keyId: string;
+ newName: string;
+}): void {
+ const key = definitions.rootElement
+ ?.find((e) => e.__$$element === "collaboration")
+ ?.correlationKey?.find((k) => k["@_id"] === keyId);
+
+ if (key) {
+ key["@_name"] = newName;
+ }
+}
+
+export function updateMessageBindingExpression({
+ definitions,
+ propertyId,
+ bindingIndex,
+ newExpression,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ bindingIndex: number;
+ newExpression: string;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((p) => p.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+
+ if (property) {
+ property.correlationPropertyRetrievalExpression ??= [];
+
property.correlationPropertyRetrievalExpression[bindingIndex].messagePath.__$$text
= newExpression;
+ }
+}
+
+export function updateMessageBindingMessage({
+ definitions,
+ propertyId,
+ bindingIndex,
+ newMessageRef,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ propertyId: string;
+ bindingIndex: number;
+ newMessageRef: string;
+}): void {
+ const property = definitions.rootElement
+ ?.filter((p) => p.__$$element === "correlationProperty")
+ .find((p) => p["@_id"] === propertyId);
+ if (property) {
+
property.correlationPropertyRetrievalExpression[bindingIndex]["@_messageRef"] =
newMessageRef || "";
+ }
+}
+
+export function updateSubscriptionValue({
+ definitions,
+ subscriptionId,
+ propertyBindingIndex,
+ newValue,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ subscriptionId: string;
+ propertyBindingIndex: number;
+ newValue: string;
+}): void {
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ process.correlationSubscription ??= [];
+ process.correlationSubscription.find((subs) => subs["@_id"] ===
subscriptionId)!.correlationPropertyBinding![
+ propertyBindingIndex
+ ].dataPath.__$$text = newValue;
+}
diff --git a/packages/bpmn-editor/src/mutations/renameGlobalProperties.ts
b/packages/bpmn-editor/src/mutations/renameGlobalProperties.ts
new file mode 100644
index 00000000000..c61ad9990d7
--- /dev/null
+++ b/packages/bpmn-editor/src/mutations/renameGlobalProperties.ts
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { BPMN20__tDefinitions } from
"@kie-tools/bpmn-marshaller/dist/schemas/bpmn-2_0/ts-gen/types";
+import { Normalized } from "../normalization/normalize";
+import { addOrGetProcessAndDiagramElements } from
"./addOrGetProcessAndDiagramElements";
+
+export function updateProcessId({
+ definitions,
+ newId,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ newId: string;
+}): void {
+ const { process } = addOrGetProcessAndDiagramElements({ definitions });
+ const oldProcessId = process["@_id"];
+ process["@_id"] = newId;
+
+ const collaboration = definitions.rootElement?.find((e) => e.__$$element ===
"collaboration");
+ if (collaboration && collaboration.__$$element === "collaboration") {
+ const participant = collaboration.participant?.find((p) =>
p["@_processRef"] === oldProcessId);
+ if (participant) {
+ participant["@_processRef"] = newId;
+ }
+ }
+}
diff --git a/packages/bpmn-editor/src/mutations/renameMessage.ts
b/packages/bpmn-editor/src/mutations/renameMessage.ts
index 138cf1ddc8e..7884bb43fbc 100644
--- a/packages/bpmn-editor/src/mutations/renameMessage.ts
+++ b/packages/bpmn-editor/src/mutations/renameMessage.ts
@@ -23,6 +23,7 @@ import { Unpacked } from
"@kie-tools/xyflow-react-kie-diagram/dist/tsExt/tsExt";
import { Normalized } from "../normalization/normalize";
import { visitFlowElementsAndArtifacts } from "./_elementVisitor";
import { addOrGetProcessAndDiagramElements } from
"./addOrGetProcessAndDiagramElements";
+import { createReservedItemDefinitionForMessages,
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from "./addOrGetMessages";
export function renameMessage({
definitions,
@@ -80,3 +81,65 @@ export function renameMessage({
return { message };
}
+
+export function updateMessageItemDefinition({
+ definitions,
+ messageId,
+ newItemDefinitionRef,
+}: {
+ definitions: Normalized<BPMN20__tDefinitions>;
+ messageId: string;
+ newItemDefinitionRef: string | undefined;
+}) {
+ const message = definitions.rootElement?.find((e) => e.__$$element ===
"message" && e["@_id"] === messageId);
+
+ if (!message || message.__$$element !== "message") {
+ return;
+ }
+
+ if (!newItemDefinitionRef) {
+ createReservedItemDefinitionForMessages({ definitions });
+ }
+
+ message["@_itemRef"] = newItemDefinitionRef ||
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES;
+
+ const newItemDef = newItemDefinitionRef
+ ? definitions.rootElement?.find((e) => e.__$$element === "itemDefinition"
&& e["@_id"] === newItemDefinitionRef)
+ : undefined;
+ const newDataType =
+ newItemDef && newItemDef.__$$element === "itemDefinition" ?
newItemDef["@_structureRef"] || "" : "";
+
+ const process = definitions.rootElement?.find((e) => e.__$$element ===
"process");
+ if (process && process.__$$element === "process") {
+ process.flowElement?.forEach((flowElement) => {
+ if ("eventDefinition" in flowElement) {
+ const messageEventDef = flowElement.eventDefinition?.find(
+ (ed) => ed.__$$element === "messageEventDefinition" &&
ed["@_messageRef"] === messageId
+ );
+
+ if (messageEventDef) {
+ if ("dataInput" in flowElement && flowElement.dataInput) {
+ flowElement.dataInput.forEach((dataInput: any) => {
+ dataInput["@_drools:dtype"] = newDataType;
+ });
+ }
+
+ if ("dataOutput" in flowElement && flowElement.dataOutput) {
+ flowElement.dataOutput.forEach((dataOutput: any) => {
+ dataOutput["@_drools:dtype"] = newDataType;
+ });
+ }
+ }
+ }
+ });
+ }
+
+ const hasMessagesUsingReservedItemDef = definitions.rootElement?.some(
+ (e) => e.__$$element === "message" && e["@_itemRef"] ===
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
+ );
+ if (!hasMessagesUsingReservedItemDef) {
+ definitions.rootElement = definitions.rootElement?.filter(
+ (e) => !(e.__$$element === "itemDefinition" && e["@_id"] ===
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES)
+ );
+ }
+}
diff --git a/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
b/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
index 38cbc78478e..7c5b273d50a 100644
--- a/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
+++ b/packages/bpmn-editor/src/propertiesPanel/GlobalProperties.tsx
@@ -46,6 +46,7 @@ import * as React from "react";
import { useState } from "react";
import { addOrGetProcessAndDiagramElements } from
"../mutations/addOrGetProcessAndDiagramElements";
import { regenerateTargetNamespace, setTargetNamespace } from
"../mutations/setTargetNamespace";
+import { updateProcessId } from "../mutations/renameGlobalProperties";
import { useBpmnEditorStore, useBpmnEditorStoreApi } from
"../store/StoreContext";
import { isProcessIdValid, getProcessIdErrorMessage } from
"../validation/processIdValidation";
import { Imports } from "./imports/Imports";
@@ -256,22 +257,10 @@ export function GlobalProperties() {
validated={!isProcessIdValid(process?.["@_id"]) ? "error"
: "default"}
onChange={(e, newId) => {
bpmnEditorStoreApi.setState((state) => {
- const { process } = addOrGetProcessAndDiagramElements({
+ updateProcessId({
definitions: state.bpmn.model.definitions,
+ newId,
});
- const oldProcessId = process["@_id"];
- process["@_id"] = newId;
- const collaboration =
state.bpmn.model.definitions.rootElement?.find(
- (e) => e.__$$element === "collaboration"
- );
- if (collaboration && collaboration.__$$element ===
"collaboration") {
- const participant = collaboration.participant?.find(
- (p) => p["@_processRef"] === oldProcessId
- );
- if (participant) {
- participant["@_processRef"] = newId;
- }
- }
});
}}
aria-describedby="process-id-helper"
diff --git
a/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
b/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
index fc5aabc0160..ed65774ab46 100644
--- a/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
+++ b/packages/bpmn-editor/src/propertiesPanel/correlations/Correlations.tsx
@@ -52,7 +52,6 @@ import { PeopleCarryIcon } from
"@patternfly/react-icons/dist/js/icons/people-ca
import { PlusCircleIcon } from
"@patternfly/react-icons/dist/js/icons/plus-circle-icon";
import { useCallback, useEffect, useMemo, useState } from "react";
import { MessageEventSymbolSvg } from "../../diagram/nodes/NodeSvgs";
-import { addOrGetProcessAndDiagramElements } from
"../../mutations/addOrGetProcessAndDiagramElements";
import { useBpmnEditorStore, useBpmnEditorStoreApi } from
"../../store/StoreContext";
import {
ItemDefinitionRefSelector,
@@ -60,10 +59,30 @@ import {
} from "../itemDefinitionRefSelector/ItemDefinitionRefSelector";
import { MessageSelector } from "../messageSelector/MessageSelector";
import TimesIcon from "@patternfly/react-icons/dist/js/icons/times-icon";
-import { deleteUnusedItemDefinitions } from
"../../mutations/deleteItemDefinition";
-import { deleteOrphanedCorrelationSubscriptions } from
"../../mutations/deleteOrphanedCorrelationSubscriptions";
import "./Correlations.css";
import { useBpmnEditorI18n } from "../../i18n";
+import {
+ addCorrelationProperty,
+ addCorrelationKey,
+ addMessageBindingToProperty,
+ addPropertyToCorrelationKey,
+ addSubscription,
+} from "../../mutations/addOrGetCorrelations";
+import {
+ updateCorrelationPropertyName,
+ updateCorrelationPropertyType,
+ updateCorrelationKeyName,
+ updateMessageBindingExpression,
+ updateMessageBindingMessage,
+ updateSubscriptionValue,
+} from "../../mutations/renameCorrelations";
+import {
+ deleteCorrelationProperty,
+ deleteCorrelationKey,
+ deletePropertyBinding,
+ deletePropertyFromKey,
+ deleteSubscription,
+} from "../../mutations/deleteCorrelations";
export function Correlations() {
const { i18n } = useBpmnEditorI18n();
@@ -76,13 +95,11 @@ export function Correlations() {
bpmnEditorStoreApi.setState((s) => {
s.focus.consumableId = newPropertyId;
- s.bpmn.model.definitions.rootElement ??= [];
- s.bpmn.model.definitions.rootElement.push({
- __$$element: "correlationProperty",
- "@_id": newPropertyId,
- "@_name": "New Property",
- "@_type": undefined,
- correlationPropertyRetrievalExpression: [],
+ addCorrelationProperty({
+ definitions: s.bpmn.model.definitions,
+ propertyId: newPropertyId,
+ propertyName: "New Property",
+ propertyType: undefined,
});
});
@@ -93,30 +110,10 @@ export function Correlations() {
const newKeyId = generateUuid();
bpmnEditorStoreApi.setState((s) => {
s.focus.consumableId = newKeyId;
-
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
-
- s.bpmn.model.definitions.rootElement ??= [];
- let collaboration = s.bpmn.model.definitions.rootElement.find((e) =>
e.__$$element === "collaboration");
- if (!collaboration) {
- collaboration = {
- "@_id": generateUuid(),
- __$$element: "collaboration",
- participant: [
- {
- "@_id": generateUuid(),
- "@_name": "Pool Participant",
- "@_processRef": process["@_id"],
- },
- ],
- };
- s.bpmn.model.definitions.rootElement.push(collaboration);
- }
-
- collaboration.correlationKey ??= [];
- collaboration.correlationKey.push({
- "@_id": newKeyId,
- "@_name": "New Key",
+ addCorrelationKey({
+ definitions: s.bpmn.model.definitions,
+ keyId: newKeyId,
+ keyName: "New Key",
});
});
@@ -179,45 +176,24 @@ export function Correlations() {
const changeSelectedPropertyType =
useCallback<OnChangeItemDefinitionRefSelector>(
(newItemDefinitionRef) => {
bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((e) => e.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === selectedPropertyId);
-
- if (property) {
- property["@_type"] = newItemDefinitionRef;
- property.correlationPropertyRetrievalExpression.forEach((cpre) => {
- if (cpre.messagePath) {
- cpre.messagePath["@_evaluatesToTypeRef"] = newItemDefinitionRef;
- }
- });
-
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
- process.correlationSubscription?.forEach((subscription) => {
- subscription.correlationPropertyBinding
- ?.filter((binding) => binding["@_correlationPropertyRef"] ===
selectedPropertyId)
- .forEach((binding) => {
- if (binding.dataPath) {
- binding.dataPath["@_evaluatesToTypeRef"] =
newItemDefinitionRef;
- }
- });
- });
-
- deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions
});
- }
+ updateCorrelationPropertyType({
+ definitions: s.bpmn.model.definitions,
+ propertyId: selectedPropertyId!,
+ newItemDefinitionRef,
+ });
});
},
[bpmnEditorStoreApi, selectedPropertyId]
);
const changePropertyName = useCallback(
- (propetyId: string) => (newName: string) => {
+ (propetyId: string) => (newName: string | undefined) => {
+ if (newName === undefined) return;
bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((e) => e.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === propetyId);
-
- if (property) {
- property["@_name"] = newName;
- }
+ updateCorrelationPropertyName({
+ definitions: s.bpmn.model.definitions,
+ propertyId: propetyId,
+ newName,
+ });
});
},
[bpmnEditorStoreApi]
@@ -226,66 +202,24 @@ export function Correlations() {
const onRemoveProperty = useCallback(
(propertyId: string) => {
bpmnEditorStoreApi.setState((s) => {
- s.bpmn.model.definitions.rootElement ??= [];
- s.bpmn.model.definitions.rootElement =
s.bpmn.model.definitions.rootElement?.filter(
- (e) => e["@_id"] !== propertyId
- );
-
- s.bpmn.model.definitions.rootElement
- ?.filter((e) => e.__$$element === "collaboration")
- .forEach((collaboration) => {
- if (collaboration.__$$element === "collaboration") {
- collaboration.correlationKey?.forEach((key) => {
- if (key.correlationPropertyRef) {
- key.correlationPropertyRef =
key.correlationPropertyRef.filter(
- (propRef) => propRef.__$$text !== propertyId
- );
- }
- });
- collaboration.correlationKey =
collaboration.correlationKey?.filter(
- (key) => key.correlationPropertyRef &&
key.correlationPropertyRef.length > 0
- );
- }
- });
- deleteOrphanedCorrelationSubscriptions({ definitions:
s.bpmn.model.definitions });
- deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions });
+ deleteCorrelationProperty({
+ definitions: s.bpmn.model.definitions,
+ propertyId,
+ });
});
},
[bpmnEditorStoreApi]
);
- const addMessageBindingToProperty = useCallback(() => {
- bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((e) => e.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === selectedPropertyId);
-
- if (property) {
- property.correlationPropertyRetrievalExpression ??= [];
- property.correlationPropertyRetrievalExpression.push({
- "@_id": generateUuid(),
- "@_messageRef": undefined as any, // SPEC DISCREPANCY!,
- messagePath: {
- "@_id": generateUuid(),
- "@_evaluatesToTypeRef": property["@_type"],
- __$$text: "",
- },
- });
- }
- });
- }, [bpmnEditorStoreApi, selectedPropertyId]);
-
const onChangeMessageBindingExpression = useCallback(
(i: number) => (e: React.FormEvent, newExpression: string) => {
bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((p) => p.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === selectedPropertyId);
-
- if (property) {
- property.correlationPropertyRetrievalExpression ??= [];
-
property.correlationPropertyRetrievalExpression[i].messagePath.__$$text =
newExpression;
- }
+ updateMessageBindingExpression({
+ definitions: s.bpmn.model.definitions,
+ propertyId: selectedPropertyId!,
+ bindingIndex: i,
+ newExpression,
+ });
});
},
[bpmnEditorStoreApi, selectedPropertyId]
@@ -294,12 +228,12 @@ export function Correlations() {
const onChangeMessageBindingMessage = useCallback(
(i: number) => (newMessageRef: string) => {
bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((p) => p.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === selectedPropertyId);
- if (property) {
- property.correlationPropertyRetrievalExpression[i]["@_messageRef"] =
newMessageRef || "";
- }
+ updateMessageBindingMessage({
+ definitions: s.bpmn.model.definitions,
+ propertyId: selectedPropertyId!,
+ bindingIndex: i,
+ newMessageRef,
+ });
});
},
[bpmnEditorStoreApi, selectedPropertyId]
@@ -308,29 +242,25 @@ export function Correlations() {
const removePropertyBinding = useCallback(
(i: number) => (e: React.FormEvent) => {
bpmnEditorStoreApi.setState((s) => {
- const property = s.bpmn.model.definitions.rootElement
- ?.filter((p) => p.__$$element === "correlationProperty")
- .find((p) => p["@_id"] === selectedPropertyId);
-
- if (property) {
- property.correlationPropertyRetrievalExpression.splice(i, 1);
- deleteUnusedItemDefinitions({ definitions: s.bpmn.model.definitions
});
- }
+ deletePropertyBinding({
+ definitions: s.bpmn.model.definitions,
+ propertyId: selectedPropertyId!,
+ bindingIndex: i,
+ });
});
},
[bpmnEditorStoreApi, selectedPropertyId]
);
const changeKeyName = useCallback(
- (keyId: string) => (newName: string) => {
+ (keyId: string) => (newName: string | undefined) => {
+ if (newName === undefined) return;
bpmnEditorStoreApi.setState((s) => {
- const key = s.bpmn.model.definitions.rootElement
- ?.find((e) => e.__$$element === "collaboration")
- ?.correlationKey?.find((k) => k["@_id"] === keyId);
-
- if (key) {
- key["@_name"] = newName;
- }
+ updateCorrelationKeyName({
+ definitions: s.bpmn.model.definitions,
+ keyId,
+ newName,
+ });
});
},
[bpmnEditorStoreApi]
@@ -339,47 +269,15 @@ export function Correlations() {
const onRemoveKey = useCallback(
(keyId: string) => {
bpmnEditorStoreApi.setState((s) => {
- const collaboration = s.bpmn.model.definitions.rootElement?.find((e)
=> e.__$$element === "collaboration");
- if (collaboration) {
- collaboration.correlationKey =
collaboration.correlationKey?.filter((k) => k["@_id"] !== keyId);
- }
- deleteOrphanedCorrelationSubscriptions({ definitions:
s.bpmn.model.definitions });
+ deleteCorrelationKey({
+ definitions: s.bpmn.model.definitions,
+ keyId,
+ });
});
},
[bpmnEditorStoreApi]
);
- const addPropertyToCorrelationKey = useCallback(
- (e: React.FormEvent, propertyId: string) => {
- bpmnEditorStoreApi.setState((s) => {
- const key = s.bpmn.model.definitions.rootElement
- ?.find((e) => e.__$$element === "collaboration")
- ?.correlationKey?.find((k) => k["@_id"] === selectedKeyId);
-
- if (key) {
- key.correlationPropertyRef ??= [];
- key.correlationPropertyRef.push({ __$$text: propertyId });
-
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
- for (const subs of process.correlationSubscription ?? []) {
- if (subs["@_correlationKeyRef"] === selectedKeyId) {
- subs.correlationPropertyBinding ??= [];
- subs.correlationPropertyBinding?.push({
- "@_id": generateUuid(),
- "@_correlationPropertyRef": propertyId,
- dataPath: {
- "@_id": generateUuid(),
- __$$text: "",
- },
- });
- }
- }
- }
- });
- },
- [bpmnEditorStoreApi, selectedKeyId]
- );
-
const subscriptions = useBpmnEditorStore(
(s) =>
s.bpmn.model.definitions.rootElement
@@ -387,45 +285,15 @@ export function Correlations() {
?.correlationSubscription?.filter((s) => s["@_correlationKeyRef"] ===
selectedKeyId) ?? []
);
- const addSubscription = useCallback(() => {
- bpmnEditorStoreApi.setState((s) => {
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
- process.correlationSubscription ??= [];
- const propertiesById = new Map(
- (s.bpmn.model.definitions.rootElement ?? [])
- .filter((e) => e.__$$element === "correlationProperty")
- .map((p) => [p["@_id"], p])
- );
- process.correlationSubscription?.push({
- "@_id": generateUuid(),
- "@_correlationKeyRef": selectedKeyId,
- correlationPropertyBinding: (selectedKey!.correlationPropertyRef ??
[]).map((propRef) => {
- const property = propertiesById.get(propRef.__$$text);
- const propertyType =
- property && property.__$$element === "correlationProperty" ?
property["@_type"] : undefined;
- return {
- "@_id": generateUuid(),
- "@_correlationPropertyRef": propRef.__$$text,
- dataPath: {
- "@_id": generateUuid(),
- "@_language": "java",
- "@_evaluatesToTypeRef": propertyType,
- __$$text: "",
- },
- };
- }),
- });
- });
- }, [bpmnEditorStoreApi, selectedKey, selectedKeyId]);
-
const changeValueOfSubscription = useCallback(
(subscriptionId: string, propertyBindingIndex: number) => (e:
React.FormEvent, newValue: string) => {
bpmnEditorStoreApi.setState((s) => {
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
- process.correlationSubscription ??= [];
- process.correlationSubscription.find((subs) => subs["@_id"] ===
subscriptionId)!.correlationPropertyBinding![
- propertyBindingIndex
- ].dataPath.__$$text = newValue;
+ updateSubscriptionValue({
+ definitions: s.bpmn.model.definitions,
+ subscriptionId,
+ propertyBindingIndex,
+ newValue,
+ });
});
},
[bpmnEditorStoreApi]
@@ -435,33 +303,11 @@ export function Correlations() {
(propertyIndex: number) => {
return (e: React.FormEvent) => {
bpmnEditorStoreApi.setState((s) => {
- const collaboration = s.bpmn.model.definitions.rootElement?.find((e)
=> e.__$$element === "collaboration");
- const key =
- collaboration && collaboration.__$$element === "collaboration"
- ? collaboration.correlationKey?.find((k) => k["@_id"] ===
selectedKeyId)
- : undefined;
-
- if (key) {
- key.correlationPropertyRef ??= [];
- const removedCorrelationPropertyRef =
key.correlationPropertyRef[propertyIndex];
- key.correlationPropertyRef.splice(propertyIndex, 1);
-
- const { process } = addOrGetProcessAndDiagramElements({
definitions: s.bpmn.model.definitions });
- process.correlationSubscription
- ?.filter((subs) => subs["@_correlationKeyRef"] === selectedKeyId)
- .forEach((subs) => {
- subs.correlationPropertyBinding =
subs.correlationPropertyBinding?.filter(
- (b) => b["@_correlationPropertyRef"] !==
removedCorrelationPropertyRef.__$$text
- );
- });
- if (
- key.correlationPropertyRef.length === 0 &&
- collaboration &&
- collaboration.__$$element === "collaboration"
- ) {
- collaboration.correlationKey =
collaboration.correlationKey?.filter((k) => k["@_id"] !== selectedKeyId);
- }
- }
+ deletePropertyFromKey({
+ definitions: s.bpmn.model.definitions,
+ keyId: selectedKeyId!,
+ propertyIndex,
+ });
});
};
},
@@ -471,11 +317,10 @@ export function Correlations() {
const removeSubscription = useCallback(
(subscriptionId: string) => (e: React.FormEvent) => {
bpmnEditorStoreApi.setState((s) => {
- const { process } = addOrGetProcessAndDiagramElements({ definitions:
s.bpmn.model.definitions });
- process.correlationSubscription ??= [];
- process.correlationSubscription =
process.correlationSubscription.filter(
- (subs) => subs["@_id"] !== subscriptionId
- );
+ deleteSubscription({
+ definitions: s.bpmn.model.definitions,
+ subscriptionId,
+ });
});
},
[bpmnEditorStoreApi]
@@ -623,7 +468,14 @@ export function Correlations() {
}
size={"lg"}
style={{ width: "100%", lineHeight: "1" }}
- onClick={addMessageBindingToProperty}
+ onClick={() => {
+ bpmnEditorStoreApi.setState((s) => {
+ addMessageBindingToProperty({
+ definitions: s.bpmn.model.definitions,
+ propertyId: selectedPropertyId!,
+ });
+ });
+ }}
>
<svg width={30} height={30}>
<MessageEventSymbolSvg
@@ -727,7 +579,15 @@ export function Correlations() {
<FormSelect
id={`correlation-key-properties-selector-${generateUuid()}`}
className={!hasAtLeastOneKeyWithProperties
? "primary" : ""}
- onChange={addPropertyToCorrelationKey}
+ onChange={(e, propertyId) => {
+ bpmnEditorStoreApi.setState((s) => {
+ addPropertyToCorrelationKey({
+ definitions:
s.bpmn.model.definitions,
+ keyId: selectedKeyId!,
+ propertyId,
+ });
+ });
+ }}
isDisabled={availablePropertiesToAddToKey.length <= 0}
>
<FormSelectOption
@@ -811,7 +671,15 @@ export function Correlations() {
icon={<PlusCircleIcon />}
size={"lg"}
style={{ width: "100%" }}
- onClick={addSubscription}
+ onClick={() => {
+ bpmnEditorStoreApi.setState((s) => {
+ addSubscription({
+ definitions:
s.bpmn.model.definitions,
+ keyId: selectedKeyId!,
+ selectedKey: selectedKey!,
+ });
+ });
+ }}
>
<br />
Add Subscription
diff --git
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.css
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.css
index 80b586513ce..f80c52277b9 100644
---
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.css
+++
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.css
@@ -16,3 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+.kie-bpmn-editor--item-definition-ref-selector[data-disabled="true"] {
+ background-color: var(--pf-global--disabled-color--300);
+ border-radius: 3px;
+ opacity: 0.6;
+}
diff --git
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
index 10f2fafb1d7..53fa8c6a24a 100644
---
a/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
+++
b/packages/bpmn-editor/src/propertiesPanel/itemDefinitionRefSelector/ItemDefinitionRefSelector.tsx
@@ -134,15 +134,7 @@ export function ItemDefinitionRefSelector({
const v = selectedDataType ?
itemDefinitionsByDataType.get(selectedDataType)?.itemDefinitionRef : undefined;
return (
- <div
- style={{
- ...(isDisabled && {
- backgroundColor: "var(--pf-global--disabled-color--300)",
- borderRadius: "3px",
- opacity: 0.6,
- }),
- }}
- >
+ <div className="kie-bpmn-editor--item-definition-ref-selector"
data-disabled={isDisabled}>
<TypeaheadSelect
isMultiple={false}
isDisabled={isDisabled ?? isReadOnly}
diff --git
a/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
b/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
index d77bb0e84af..36f15a9a53c 100644
---
a/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
+++
b/packages/bpmn-editor/src/propertiesPanel/propertiesManager/PropertiesManager.tsx
@@ -50,8 +50,12 @@ import { addOrGetItemDefinitions, DEFAULT_DATA_TYPES } from
"../../mutations/add
import { deleteItemDefinition } from "../../mutations/deleteItemDefinition";
import { renameItemDefinition } from "../../mutations/renameItemDefinition";
import { deduplicateItemDefinitions } from "../../normalization/normalize";
-import { addOrGetMessages, RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES } from
"../../mutations/addOrGetMessages";
-import { renameMessage } from "../../mutations/renameMessage";
+import {
+ addOrGetMessages,
+ createReservedItemDefinitionForMessages,
+ RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES,
+} from "../../mutations/addOrGetMessages";
+import { renameMessage, updateMessageItemDefinition } from
"../../mutations/renameMessage";
import { deleteMessage } from "../../mutations/deleteMessage";
import { ItemDefinitionRefSelector } from
"../itemDefinitionRefSelector/ItemDefinitionRefSelector";
import { addOrGetSignals } from "../../mutations/addOrGetSignals";
@@ -316,64 +320,11 @@ export function PropertiesManager({ p }: { p: undefined |
WithVariables }) {
value={entry["@_itemRef"]}
onChange={(newItemDefinitionRef) => {
bpmnEditorStoreApi.setState((s) => {
- const message =
s.bpmn.model.definitions.rootElement?.find(
- (e) => e.__$$element === "message" && e["@_id"]
=== entry["@_id"]
- );
-
- if (message && message.__$$element === "message"
&& newItemDefinitionRef) {
- message["@_itemRef"] = newItemDefinitionRef;
-
- const newItemDef =
s.bpmn.model.definitions.rootElement?.find(
- (e) => e.__$$element === "itemDefinition" &&
e["@_id"] === newItemDefinitionRef
- );
- const newDataType =
- newItemDef && newItemDef.__$$element ===
"itemDefinition"
- ? newItemDef["@_structureRef"] || ""
- : "";
-
- const process =
s.bpmn.model.definitions.rootElement?.find(
- (e) => e.__$$element === "process"
- );
- if (process && process.__$$element ===
"process") {
- process.flowElement?.forEach((flowElement) => {
- if ("eventDefinition" in flowElement) {
- const messageEventDef =
flowElement.eventDefinition?.find(
- (ed) =>
- ed.__$$element ===
"messageEventDefinition" &&
- ed["@_messageRef"] === entry["@_id"]
- );
-
- if (messageEventDef) {
- if ("dataInput" in flowElement &&
flowElement.dataInput) {
-
flowElement.dataInput.forEach((dataInput: any) => {
- dataInput["@_drools:dtype"] =
newDataType;
- });
- }
-
- if ("dataOutput" in flowElement &&
flowElement.dataOutput) {
-
flowElement.dataOutput.forEach((dataOutput: any) => {
- dataOutput["@_drools:dtype"] =
newDataType;
- });
- }
- }
- }
- });
- }
- const hasMessagesUsingReservedItemDef =
s.bpmn.model.definitions.rootElement?.some(
- (e) =>
- e.__$$element === "message" &&
- e["@_itemRef"] ===
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
- );
- if (!hasMessagesUsingReservedItemDef) {
- s.bpmn.model.definitions.rootElement =
s.bpmn.model.definitions.rootElement?.filter(
- (e) =>
- !(
- e.__$$element === "itemDefinition" &&
- e["@_id"] ===
RESERVED_ITEM_DEFINITION_ID_FOR_MESSAGES
- )
- );
- }
- }
+ updateMessageItemDefinition({
+ definitions: s.bpmn.model.definitions,
+ messageId: entry["@_id"],
+ newItemDefinitionRef,
+ });
});
}}
/>
diff --git
a/packages/bpmn-editor/tests-e2e/propertiesPanel/changeStartEventProperties.spec.ts
b/packages/bpmn-editor/tests-e2e/propertiesPanel/changeStartEventProperties.spec.ts
index 28ab14b45e8..a178cfb3504 100644
---
a/packages/bpmn-editor/tests-e2e/propertiesPanel/changeStartEventProperties.spec.ts
+++
b/packages/bpmn-editor/tests-e2e/propertiesPanel/changeStartEventProperties.spec.ts
@@ -231,4 +231,37 @@ test.describe("Change Properties - Error/Escalation Start
Events in Event Sub-Pr
expect(await
startEventPropertiesPanel.getEscalationName()).toBe("StartEscalation");
});
+
+ test.describe("Message Event - ItemDefinition Validation", () => {
+ test("should create itemDefinition when message start event is
configured", async ({
+ palette,
+ nodes,
+ startEventPropertiesPanel,
+ jsonModel,
+ }) => {
+ await palette.dragNewNode({ type: NodeType.START_EVENT, targetPosition:
{ x: 100, y: 100 } });
+ await expect(nodes.getByType(NodeType.START_EVENT)).toBeVisible();
+
+ await startEventPropertiesPanel.setMessageDefinition({
+ messageName: "TestMessage",
+ startEventLocator: nodes.getByType(NodeType.START_EVENT).first(),
+ });
+
+ const definitions = await jsonModel.getDefinitions();
+
+ expect(definitions?.rootElement).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ __$$element: "message",
+ "@_name": "TestMessage",
+ "@_itemRef": "__messageItemDefinition",
+ }),
+ expect.objectContaining({
+ __$$element: "itemDefinition",
+ "@_id": "__messageItemDefinition",
+ }),
+ ])
+ );
+ });
+ });
});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]