UNPKG

@5minds/processcube_engine

Version:

The ProcessCube Engine. Stores and executes BPMNs.

74 lines 4.44 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StartMessageEventHandler = void 0; const inversify_1 = require("inversify"); const processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk"); const index_1 = require("../../../Contracts/index"); const DatabaseAdaptersSequelize_1 = require("../../../Tools/DatabaseAdaptersSequelize/"); const EventMiddlewareHandler_1 = require("../../../Tools/EventMiddlewareHandler"); const ProcessInstance_1 = require("../../ProcessInstance"); const FlowNodeHandlerFactory_1 = require("../FlowNodeHandlerFactory"); const StartEventHandler_1 = require("./StartEventHandler"); let StartMessageEventHandler = class StartMessageEventHandler extends StartEventHandler_1.StartEventHandler { constructor(eventMiddlewareHandler, flowNodeHandlerFactory, flowNodeInstanceDatabaseAdapter, startEventModel, processInstance) { super(eventMiddlewareHandler, flowNodeHandlerFactory, flowNodeInstanceDatabaseAdapter, startEventModel, processInstance, 'message_start_event_handler'); } get messageStartEvent() { return this.flowNode; } async persistOnTerminate() { await super.persistOnTerminate({ type: index_1.FlowNodeInstanceDataTypes.catchEvent, eventName: this.messageStartEvent.messageEventDefinition.name, triggerValue: this.messageStartEvent.triggerValueInToken, triggeredByFlowNodeInstanceId: this.triggeredByFlowNodeInstanceId, }); } async persistOnError(error) { await super.persistOnError(error, { type: index_1.FlowNodeInstanceDataTypes.catchEvent, eventName: this.messageStartEvent.messageEventDefinition ? this.messageStartEvent.messageEventDefinition.name : undefined, triggerValue: this.messageStartEvent.triggerValueInToken, triggeredByFlowNodeInstanceId: this.triggeredByFlowNodeInstanceId, }); } async persistOnExit() { if (!this.messageStartEvent.messageEventDefinition) { const errorToThrow = new processcube_engine_sdk_1.BadRequestError('Message Start Event does not have a message assigned.', 'process'); errorToThrow.additionalInformation = { flowNodeInstanceId: this.flowNodeInstanceId, flowNodeId: this.messageStartEvent.id, eventName: this.messageStartEvent.name, processInstanceId: this.processInstance.getProcessInstanceId(), processModelId: this.processInstance.getProcessModelId(), embeddedProcessModelId: this.processInstance.getEmbeddedProcessModelId(), correlationId: this.processInstance.getCorrelationId(), }; this.logger.error(errorToThrow.message); throw errorToThrow; } await super.persistOnExit({ type: index_1.FlowNodeInstanceDataTypes.catchEvent, eventName: this.messageStartEvent.messageEventDefinition.name, triggerValue: this.messageStartEvent.triggerValueInToken, triggeredByFlowNodeInstanceId: this.triggeredByFlowNodeInstanceId, }); } }; exports.StartMessageEventHandler = StartMessageEventHandler; exports.StartMessageEventHandler = StartMessageEventHandler = __decorate([ (0, inversify_1.injectable)(), __metadata("design:paramtypes", [EventMiddlewareHandler_1.EventMiddlewareHandler, FlowNodeHandlerFactory_1.FlowNodeHandlerFactory, DatabaseAdaptersSequelize_1.FlowNodeInstanceDatabaseAdapter, Object, ProcessInstance_1.ProcessInstance]) ], StartMessageEventHandler); //# sourceMappingURL=StartMessageEventHandler.js.map