Dan 8c673c4fb6 BPMN.io -- Just show the message names not the ids - to assure we are only exposing the names.
SpiffWorkflow -
    - start_messages function should return message names, not ids.
    - don't catch external thrown messages within the same workflow process
    - add an expected value to the Correlation Property Model so we can use this well defined class as an external communication tool (rather than building an arbitrary dictionary)
    - Added a "get_awaiting_correlations" to an event, so we can get a list of the correlation properties related to the workflows currently defined correlation values.
    - workflows.waiting_events() function now returns the above awaiting correlations as the value on returned message events
 Backend
    - Dropping MessageModel and MessageCorrelationProperties - at least for now.  We don't need them to send / receive messages though we may eventually want to track the messages and correlations defined across the system - these things (which are ever changing) should not be directly connected to the Messages which may be in flux - and the cross relationships between the tables could cause unexpected and unceissary errors.  Commented out the caching logic so we can turn this back on later.
    - Slight improvement to API Errors
    - MessageInstances are no longer in a many-to-many relationship with Correlations - Each message instance has a unique set of message correlations specific to the instance.
    - Message Instances have users, and can be linked through a "counterpart_id" so you can see what send is connected to what recieve.
    - Message Correlations are connected to  recieving message instances.  It is not to a process instance, and not to a message model.  They now include the expected value and retrieval expression required to validate an incoming message.
    - A process instance is not connected to message correlations.
    - Message Instances are not always tied to a process instance (for example, a Send Message from an API)
    - API calls to create a message use the same logic as all other message catching code.
    - Make use of the new waiting_events() method to check for any new recieve messages in the workflow (much easier than
    churning through all of the tasks)
    - One giant mother of a migration.
2023-02-23 13:53:03 -05:00

164 lines
4.2 KiB
JavaScript

import { useService } from 'bpmn-js-properties-panel';
import { TextFieldEntry } from '@bpmn-io/properties-panel';
import { getRoot, findMessageModdleElements } from '../MessageHelpers';
import { removeFirstInstanceOfItemFromArrayInPlace } from '../../helpers';
/**
* Provides a list of data objects, and allows you to add / remove data objects, and change their ids.
* @param props
* @constructor
*/
export function MessageArray(props) {
const { element, moddle, commandStack, translate } = props;
const messageElements = findMessageModdleElements(element.businessObject);
const items = messageElements.map((messageElement, index) => {
const id = `messageElement-${index}`;
return {
id,
label: messageElement.name,
entries: messageGroup({
idPrefix: id,
element,
messageElement,
commandStack,
translate,
}),
autoFocusEntry: id,
remove: removeFactory({
element,
messageElement,
commandStack,
moddle,
}),
};
});
function add(event) {
event.stopPropagation();
if (element.type === 'bpmn:Collaboration') {
const newMessageElement = moddle.create('bpmn:Message');
const messageId = moddle.ids.nextPrefixed('Message_');
newMessageElement.id = messageId;
newMessageElement.name = messageId;
const rootElement = getRoot(element.businessObject);
const { rootElements } = rootElement;
rootElements.push(newMessageElement);
commandStack.execute('element.updateProperties', {
element,
properties: {},
});
}
}
return { items, add };
}
function removeMessageRefs(messageElement, moddleElement) {
if (
moddleElement.messageRef &&
moddleElement.messageRef.id === messageElement.id
) {
moddleElement.messageRef = null;
} else if (moddleElement.correlationPropertyRetrievalExpression) {
moddleElement.correlationPropertyRetrievalExpression.forEach((cpre) => {
removeMessageRefs(messageElement, cpre);
});
} else if (moddleElement.flowElements) {
moddleElement.flowElements.forEach((fe) => {
removeMessageRefs(messageElement, fe);
});
} else if (moddleElement.eventDefinitions) {
moddleElement.eventDefinitions.forEach((ed) => {
removeMessageRefs(messageElement, ed);
});
}
}
function removeFactory(props) {
const { element, messageElement, commandStack } = props;
return function (event) {
event.stopPropagation();
const rootElement = getRoot(element.businessObject);
const { rootElements } = rootElement;
removeFirstInstanceOfItemFromArrayInPlace(rootElements, messageElement);
rootElements.forEach((moddleElement) => {
removeMessageRefs(messageElement, moddleElement);
});
commandStack.execute('element.updateProperties', {
element,
properties: {},
});
};
}
function messageGroup(props) {
const { messageElement, commandStack, translate, idPrefix } = props;
return [
{
id: `${idPrefix}-name`,
component: MessageNameTextField,
messageElement,
commandStack,
translate,
},
];
}
function MessageIdTextField(props) {
const { id, element, messageElement, commandStack, translate } = props;
const debounce = useService('debounceInput');
const setValue = (value) => {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: messageElement,
properties: {
id: value,
},
});
};
const getValue = () => {
return messageElement.id;
};
return TextFieldEntry({
element,
id: `${id}-id-textField`,
label: translate('ID'),
getValue,
setValue,
debounce,
});
}
function MessageNameTextField(props) {
const { id, element, messageElement, commandStack, translate } = props;
const debounce = useService('debounceInput');
const setValue = (value) => {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: messageElement,
properties: {
name: value,
},
});
};
const getValue = () => {
return messageElement.name;
};
return TextFieldEntry({
element,
id: `${id}-name-textField`,
label: translate('Name'),
getValue,
setValue,
debounce,
});
}