From b84fdbd3c4e9c0348c7eab76f8e43f287dca336f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 30 Jul 2020 11:22:44 +0200 Subject: [PATCH 1/7] Remove json2typescript dependency, and refactor the code --- package-lock.json | 5 -- package.json | 1 - src/component/parser/json/BpmnJsonParser.ts | 19 ++++--- src/component/parser/json/Definitions.ts | 51 ------------------- .../json/converter/AbstractConverter.ts | 16 +----- .../json/converter/CollaborationConverter.ts | 7 +-- .../parser/json/converter/DiagramConverter.ts | 10 ++-- .../json/converter/JsonConvertConfig.ts | 42 --------------- .../parser/json/converter/ProcessConverter.ts | 7 +-- src/model/bpmn/Bounds.ts | 35 +------------ src/model/bpmn/edge/Waypoint.ts | 21 +------- 11 files changed, 27 insertions(+), 187 deletions(-) delete mode 100644 src/component/parser/json/Definitions.ts delete mode 100644 src/component/parser/json/converter/JsonConvertConfig.ts diff --git a/package-lock.json b/package-lock.json index c403dfe51f..22454417cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8688,11 +8688,6 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "json2typescript": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/json2typescript/-/json2typescript-1.2.5.tgz", - "integrity": "sha512-3AJigpzmHkqIQnCZXiqGF5rVIxYvzHcK1NqN4nQ35hTuJGb89WqIhEO7azs+9+R9yUB1WAVjL21SLF8fTypb+A==" - }, "json5": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz", diff --git a/package.json b/package.json index 794daac573..ba279be2bc 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "dependencies": { "entities": "^2.0.0", "fast-xml-parser": "^3.16.0", - "json2typescript": "^1.2.5", "mxgraph": "4.1.0" } } diff --git a/src/component/parser/json/BpmnJsonParser.ts b/src/component/parser/json/BpmnJsonParser.ts index ca3c33f54d..35a295e5c9 100644 --- a/src/component/parser/json/BpmnJsonParser.ts +++ b/src/component/parser/json/BpmnJsonParser.ts @@ -13,22 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Definitions } from './Definitions'; import BpmnModel from '../../../model/bpmn/BpmnModel'; -import JsonConvertConfig from './converter/JsonConvertConfig'; -import { JsonConvert } from 'json2typescript'; -import { BpmnJsonModel } from '../xml/bpmn-json-model/BPMN20'; +import { BpmnJsonModel, TDefinitions } from '../xml/bpmn-json-model/BPMN20'; +import CollaborationConverter from './converter/CollaborationConverter'; +import ProcessConverter from './converter/ProcessConverter'; +import DiagramConverter from './converter/DiagramConverter'; export default class BpmnJsonParser { - constructor(readonly jsonConvert: JsonConvert) {} + constructor(readonly collaborationConverter: CollaborationConverter, readonly processConverter: ProcessConverter, readonly diagramConverter: DiagramConverter) {} public parse(json: BpmnJsonModel): BpmnModel { - const definitions = this.jsonConvert.deserializeObject(json.definitions, Definitions); - return definitions.bpmnModel; + const definitions: TDefinitions = json.definitions; + + this.collaborationConverter.deserialize(definitions.collaboration); + this.processConverter.deserialize(definitions.process); + return this.diagramConverter.deserialize(definitions.BPMNDiagram); } } export function defaultBpmnJsonParser(): BpmnJsonParser { // TODO replace the function by dependency injection, see #110 - return new BpmnJsonParser(JsonConvertConfig.jsonConvert()); + return new BpmnJsonParser(new CollaborationConverter(), new ProcessConverter(), new DiagramConverter()); } diff --git a/src/component/parser/json/Definitions.ts b/src/component/parser/json/Definitions.ts deleted file mode 100644 index 0141d87154..0000000000 --- a/src/component/parser/json/Definitions.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2020 Bonitasoft S.A. - * - * Licensed 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 { JsonObject, JsonProperty } from 'json2typescript'; -import BpmnModel from '../../../model/bpmn/BpmnModel'; -import DiagramConverter from './converter/DiagramConverter'; -import ProcessConverter from './converter/ProcessConverter'; -import CollaborationConverter from './converter/CollaborationConverter'; - -@JsonObject('definitions') -export class Definitions { - @JsonProperty('collaboration', CollaborationConverter, true) - private readonly _collaboration: Collaboration; - - @JsonProperty('process', ProcessConverter) - private readonly _process: Process; - - @JsonProperty('BPMNDiagram', DiagramConverter) - private readonly _bpmnModel: BpmnModel; - - // bpmnModel must be the last argument as it requires data built by the other converter. - constructor(collaboration?: Collaboration, process?: Process, bpmnModel?: BpmnModel) { - this._collaboration = collaboration; - this._process = process; - this._bpmnModel = bpmnModel; - } - - public get bpmnModel(): BpmnModel { - return this._bpmnModel; - } -} - -// only define a type to fill data used to build the BpmnModel -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Process {} - -// only define a type to fill data used to build the BpmnModel -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Collaboration {} diff --git a/src/component/parser/json/converter/AbstractConverter.ts b/src/component/parser/json/converter/AbstractConverter.ts index e5e7d19420..8400465430 100644 --- a/src/component/parser/json/converter/AbstractConverter.ts +++ b/src/component/parser/json/converter/AbstractConverter.ts @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonConverter, JsonCustomConvert } from 'json2typescript'; -import JsonConvertConfig from './JsonConvertConfig'; - function convertEmptyStringAndObject(element: string | T, acceptEmptyString: boolean): T { if (element === '') { return acceptEmptyString ? ({} as T) : undefined; @@ -37,17 +34,8 @@ export function ensureIsArray(elements: (T | string)[] | T | string, acceptEm return returnedArray.filter(value => value); } -@JsonConverter -export abstract class AbstractConverter implements JsonCustomConvert { - // TODO find a way to inject JsonConvert, see #110 - protected readonly jsonConvert = JsonConvertConfig.jsonConvert(); - - // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any - serialize(data: T): any { - // TODO throw exception - console.error('Not implemented !!'); - } +export abstract class AbstractConverter { // eslint-disable-next-line @typescript-eslint/no-explicit-any - abstract deserialize(data: any): T; + public abstract deserialize(data: any): T; } diff --git a/src/component/parser/json/converter/CollaborationConverter.ts b/src/component/parser/json/converter/CollaborationConverter.ts index edb59b697e..24a26524ad 100644 --- a/src/component/parser/json/converter/CollaborationConverter.ts +++ b/src/component/parser/json/converter/CollaborationConverter.ts @@ -13,16 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonConverter } from 'json2typescript'; import { AbstractConverter, ensureIsArray } from './AbstractConverter'; import { Participant } from '../../../../model/bpmn/shape/ShapeBpmnElement'; -import { Collaboration } from '../Definitions'; import { MessageFlow } from '../../../../model/bpmn/edge/Flow'; import { FlowKind } from '../../../../model/bpmn/edge/FlowKind'; import { TCollaboration } from '../../xml/bpmn-json-model/baseElement/rootElement/collaboration'; import { TParticipant } from '../../xml/bpmn-json-model/baseElement/participant'; import { TMessageFlow } from '../../xml/bpmn-json-model/baseElement/baseElement'; +// only define a type to fill data used to build the BpmnModel +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface Collaboration {} + const convertedProcessRefParticipants: Participant[] = []; const convertedMessageFlows: MessageFlow[] = []; @@ -38,7 +40,6 @@ export function findMessageFlow(id: string): MessageFlow { return convertedMessageFlows.find(i => i.id === id); } -@JsonConverter export default class CollaborationConverter extends AbstractConverter { deserialize(collaborations: string | TCollaboration | (string | TCollaboration)[]): Collaboration { try { diff --git a/src/component/parser/json/converter/DiagramConverter.ts b/src/component/parser/json/converter/DiagramConverter.ts index ebe5300554..49758caad9 100644 --- a/src/component/parser/json/converter/DiagramConverter.ts +++ b/src/component/parser/json/converter/DiagramConverter.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonConverter } from 'json2typescript'; import { AbstractConverter, ensureIsArray } from './AbstractConverter'; import Shape from '../../../../model/bpmn/shape/Shape'; import Bounds from '../../../../model/bpmn/Bounds'; @@ -37,7 +36,6 @@ function findProcessElement(participantId: string): ShapeBpmnElement { } } -@JsonConverter export default class DiagramConverter extends AbstractConverter { private convertedFonts: Map = new Map(); @@ -134,7 +132,7 @@ export default class DiagramConverter extends AbstractConverter { private deserializeBounds(boundedElement: BPMNShape | BPMNLabel): Bounds { const bounds = boundedElement.Bounds; if (bounds) { - return this.jsonConvert.deserializeObject(bounds, Bounds); + return new Bounds(bounds.x, bounds.y, bounds.width, bounds.height); } } @@ -151,9 +149,9 @@ export default class DiagramConverter extends AbstractConverter { }); } - private deserializeWaypoints(waypoint: Point[]): Waypoint[] { - if (waypoint) { - return this.jsonConvert.deserializeArray(ensureIsArray(waypoint), Waypoint); + private deserializeWaypoints(waypoints: Point[]): Waypoint[] { + if (waypoints) { + return ensureIsArray(waypoints).map(waypoint => new Waypoint(waypoint.x, waypoint.y)); } } diff --git a/src/component/parser/json/converter/JsonConvertConfig.ts b/src/component/parser/json/converter/JsonConvertConfig.ts deleted file mode 100644 index be0ab2ef6d..0000000000 --- a/src/component/parser/json/converter/JsonConvertConfig.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Bonitasoft S.A. - * - * Licensed 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 { JsonConvert, OperationMode, ValueCheckingMode } from 'json2typescript'; - -/** - * Singleton to let you access to the JsonConvert unique instance. - */ -export default class JsonConvertConfig { - private static instance: JsonConvertConfig; - private readonly _jsonConvert: JsonConvert; - - private constructor() { - this._jsonConvert = new JsonConvert(); - this._jsonConvert.operationMode = OperationMode.ENABLE; - this._jsonConvert.ignorePrimitiveChecks = false; // don't allow assigning number to string etc. - this._jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL; // never allow null - } - - private static getInstance(): JsonConvertConfig { - if (!JsonConvertConfig.instance) { - JsonConvertConfig.instance = new JsonConvertConfig(); - } - return JsonConvertConfig.instance; - } - - public static jsonConvert(): JsonConvert { - return JsonConvertConfig.getInstance()._jsonConvert; - } -} diff --git a/src/component/parser/json/converter/ProcessConverter.ts b/src/component/parser/json/converter/ProcessConverter.ts index 5be203d2a9..29f175a41a 100644 --- a/src/component/parser/json/converter/ProcessConverter.ts +++ b/src/component/parser/json/converter/ProcessConverter.ts @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonConverter } from 'json2typescript'; import { AbstractConverter, ensureIsArray } from './AbstractConverter'; import ShapeBpmnElement, { ShapeBpmnBoundaryEvent, ShapeBpmnEvent, ShapeBpmnSubProcess } from '../../../../model/bpmn/shape/ShapeBpmnElement'; import { ShapeBpmnElementKind } from '../../../../model/bpmn/shape/ShapeBpmnElementKind'; -import { Process } from '../Definitions'; import { AssociationFlow, SequenceFlow } from '../../../../model/bpmn/edge/Flow'; import { ShapeBpmnEventKind, supportedBpmnEventKinds } from '../../../../model/bpmn/shape/ShapeBpmnEventKind'; import ShapeUtil, { BpmnEventKind } from '../../../../model/bpmn/shape/ShapeUtil'; @@ -32,6 +30,10 @@ import { TSequenceFlow } from '../../xml/bpmn-json-model/baseElement/flowElement import { TAssociation } from '../../xml/bpmn-json-model/baseElement/artifact'; import { AssociationDirectionKind } from '../../../../model/bpmn/edge/AssociationDirectionKind'; +// only define a type to fill data used to build the BpmnModel +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface Process {} + const convertedFlowNodeBpmnElements: ShapeBpmnElement[] = []; const convertedLaneBpmnElements: ShapeBpmnElement[] = []; const convertedProcessBpmnElements: ShapeBpmnElement[] = []; @@ -68,7 +70,6 @@ interface EventDefinition { counter: number; } -@JsonConverter export default class ProcessConverter extends AbstractConverter { // eslint-disable-next-line @typescript-eslint/no-explicit-any deserialize(processes: string | TProcess | (string | TProcess)[]): Process { diff --git a/src/model/bpmn/Bounds.ts b/src/model/bpmn/Bounds.ts index 762ad82f34..a861c16684 100644 --- a/src/model/bpmn/Bounds.ts +++ b/src/model/bpmn/Bounds.ts @@ -13,39 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonObject, JsonProperty } from 'json2typescript'; - -@JsonObject('Bounds') export default class Bounds { - @JsonProperty('x', Number) - private _x: number; - - @JsonProperty('y', Number) - private _y: number; - - @JsonProperty('width', Number) - private _width: number; - - @JsonProperty('height', Number) - private _height: number; - - public constructor(x?: number, y?: number, width?: number, height?: number) { - this._x = x; - this._y = y; - this._width = width; - this._height = height; - } - - get height(): number { - return this._height; - } - get width(): number { - return this._width; - } - get y(): number { - return this._y; - } - get x(): number { - return this._x; - } + public constructor(readonly x: number, readonly y: number, readonly width: number, readonly height: number) {} } diff --git a/src/model/bpmn/edge/Waypoint.ts b/src/model/bpmn/edge/Waypoint.ts index 4f26c1477c..c224143510 100644 --- a/src/model/bpmn/edge/Waypoint.ts +++ b/src/model/bpmn/edge/Waypoint.ts @@ -13,25 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { JsonProperty } from 'json2typescript'; - export default class Waypoint { - @JsonProperty('x', Number) - private readonly _x: number; - - @JsonProperty('y', Number) - private readonly _y: number; - - constructor(x?: number, y?: number) { - this._x = x; - this._y = y; - } - - public get y(): number { - return this._y; - } - - public get x(): number { - return this._x; - } + constructor(readonly x: number, readonly y: number) {} } From 080a1f57c478c83bff95218a932580a68b1469ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 30 Jul 2020 11:38:07 +0200 Subject: [PATCH 2/7] Change return type in some converters --- .../parser/json/converter/CollaborationConverter.ts | 10 ++-------- .../parser/json/converter/ProcessConverter.ts | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/component/parser/json/converter/CollaborationConverter.ts b/src/component/parser/json/converter/CollaborationConverter.ts index 24a26524ad..fd05b270c4 100644 --- a/src/component/parser/json/converter/CollaborationConverter.ts +++ b/src/component/parser/json/converter/CollaborationConverter.ts @@ -21,10 +21,6 @@ import { TCollaboration } from '../../xml/bpmn-json-model/baseElement/rootElemen import { TParticipant } from '../../xml/bpmn-json-model/baseElement/participant'; import { TMessageFlow } from '../../xml/bpmn-json-model/baseElement/baseElement'; -// only define a type to fill data used to build the BpmnModel -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Collaboration {} - const convertedProcessRefParticipants: Participant[] = []; const convertedMessageFlows: MessageFlow[] = []; @@ -40,16 +36,14 @@ export function findMessageFlow(id: string): MessageFlow { return convertedMessageFlows.find(i => i.id === id); } -export default class CollaborationConverter extends AbstractConverter { - deserialize(collaborations: string | TCollaboration | (string | TCollaboration)[]): Collaboration { +export default class CollaborationConverter extends AbstractConverter { + deserialize(collaborations: string | TCollaboration | (string | TCollaboration)[]): void { try { // Deletes everything in the array, which does hit other references. For better performance. convertedProcessRefParticipants.length = 0; convertedMessageFlows.length = 0; ensureIsArray(collaborations).forEach(collaboration => this.parseCollaboration(collaboration)); - - return {}; } catch (e) { // TODO error management console.error(e as Error); diff --git a/src/component/parser/json/converter/ProcessConverter.ts b/src/component/parser/json/converter/ProcessConverter.ts index 29f175a41a..02e6d95bc8 100644 --- a/src/component/parser/json/converter/ProcessConverter.ts +++ b/src/component/parser/json/converter/ProcessConverter.ts @@ -30,10 +30,6 @@ import { TSequenceFlow } from '../../xml/bpmn-json-model/baseElement/flowElement import { TAssociation } from '../../xml/bpmn-json-model/baseElement/artifact'; import { AssociationDirectionKind } from '../../../../model/bpmn/edge/AssociationDirectionKind'; -// only define a type to fill data used to build the BpmnModel -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface Process {} - const convertedFlowNodeBpmnElements: ShapeBpmnElement[] = []; const convertedLaneBpmnElements: ShapeBpmnElement[] = []; const convertedProcessBpmnElements: ShapeBpmnElement[] = []; @@ -70,9 +66,9 @@ interface EventDefinition { counter: number; } -export default class ProcessConverter extends AbstractConverter { +export default class ProcessConverter extends AbstractConverter { // eslint-disable-next-line @typescript-eslint/no-explicit-any - deserialize(processes: string | TProcess | (string | TProcess)[]): Process { + deserialize(processes: string | TProcess | (string | TProcess)[]): void { try { // Deletes everything in the array, which does hit other references. For better performance. convertedFlowNodeBpmnElements.length = 0; @@ -83,8 +79,6 @@ export default class ProcessConverter extends AbstractConverter { defaultSequenceFlowIds.length = 0; ensureIsArray(processes).forEach(process => this.parseProcess(process)); - - return {}; } catch (e) { // TODO error management console.error(e as Error); From a641b0c8c1a38587c9b716c9e5cfc7279e4ed77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 30 Jul 2020 14:26:36 +0200 Subject: [PATCH 3/7] Fix some types of BPMN Json model --- src/component/parser/xml/bpmn-json-model/BPMNDI.ts | 1 + test/unit/component/parser/json/BpmnJsonParser.event.test.ts | 2 +- test/unit/component/parser/json/JsonBuilder.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/component/parser/xml/bpmn-json-model/BPMNDI.ts b/src/component/parser/xml/bpmn-json-model/BPMNDI.ts index 282a490a1f..37954ecdcf 100644 --- a/src/component/parser/xml/bpmn-json-model/BPMNDI.ts +++ b/src/component/parser/xml/bpmn-json-model/BPMNDI.ts @@ -15,6 +15,7 @@ */ import { Diagram, Label, LabeledEdge, LabeledShape, Plane, Style } from './DI'; import { Font } from './DC'; +import {TCollaboration} from "./baseElement/rootElement/collaboration"; export interface BPMNDiagram extends Diagram { BPMNPlane: BPMNPlane; diff --git a/test/unit/component/parser/json/BpmnJsonParser.event.test.ts b/test/unit/component/parser/json/BpmnJsonParser.event.test.ts index cfe03218e6..5d07590c11 100644 --- a/test/unit/component/parser/json/BpmnJsonParser.event.test.ts +++ b/test/unit/component/parser/json/BpmnJsonParser.event.test.ts @@ -152,7 +152,7 @@ function executeEventCommonTests( }); it(`should NOT convert, when there are several '${eventDefinitionKind}EventDefinition' in the same element${specificTitle}, ${titleForEventDefinitionIsAttributeOf}`, () => { - const eventDefinition = [{}, {}]; + const eventDefinition = ['', {}]; const json = buildDefinitionsAndProcessWithTask(); addEvent(json, bpmnKind, { ...buildEventDefinitionParameter, eventDefinition }, specificBuildEventParameter); diff --git a/test/unit/component/parser/json/JsonBuilder.ts b/test/unit/component/parser/json/JsonBuilder.ts index a9e5388965..80832c5827 100644 --- a/test/unit/component/parser/json/JsonBuilder.ts +++ b/test/unit/component/parser/json/JsonBuilder.ts @@ -21,7 +21,7 @@ import { TFlowNode } from '../../../../../src/component/parser/xml/bpmn-json-mod import { BPMNPlane, BPMNShape } from '../../../../../src/component/parser/xml/bpmn-json-model/BPMNDI'; type BPMNTEvent = TCatchEvent | TThrowEvent | TBoundaryEvent; -type BPMNEventDefinition = string | TEventDefinition | TEventDefinition[]; +type BPMNEventDefinition = string | TEventDefinition | (string | TEventDefinition)[]; export enum EventDefinitionOn { NONE, @@ -140,7 +140,7 @@ export function addEventDefinitionsOnDefinition(jsonModel: BpmnJsonModel, buildP const eventDefinition = buildParameter.eventDefinition ? buildParameter.eventDefinition : { id: 'event_definition_id' }; addEventDefinitions(jsonModel.definitions, { ...buildParameter, eventDefinition }); if (Array.isArray(eventDefinition)) { - event.eventDefinitionRef = eventDefinition.map(eventDefinition => eventDefinition.id); + event.eventDefinitionRef = eventDefinition.map(eventDefinition => (typeof eventDefinition === 'string' ? eventDefinition : eventDefinition.id)); } else { event.eventDefinitionRef = (eventDefinition as TEventDefinition).id; } From b0baa073ef335b3a2cb57c3c3d32929098cb7b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Thu, 30 Jul 2020 14:29:48 +0200 Subject: [PATCH 4/7] Fix lint-check --- src/component/parser/json/converter/AbstractConverter.ts | 1 - src/component/parser/xml/bpmn-json-model/BPMNDI.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/component/parser/json/converter/AbstractConverter.ts b/src/component/parser/json/converter/AbstractConverter.ts index 8400465430..86a8ed36bb 100644 --- a/src/component/parser/json/converter/AbstractConverter.ts +++ b/src/component/parser/json/converter/AbstractConverter.ts @@ -34,7 +34,6 @@ export function ensureIsArray(elements: (T | string)[] | T | string, acceptEm return returnedArray.filter(value => value); } - export abstract class AbstractConverter { // eslint-disable-next-line @typescript-eslint/no-explicit-any public abstract deserialize(data: any): T; diff --git a/src/component/parser/xml/bpmn-json-model/BPMNDI.ts b/src/component/parser/xml/bpmn-json-model/BPMNDI.ts index 37954ecdcf..282a490a1f 100644 --- a/src/component/parser/xml/bpmn-json-model/BPMNDI.ts +++ b/src/component/parser/xml/bpmn-json-model/BPMNDI.ts @@ -15,7 +15,6 @@ */ import { Diagram, Label, LabeledEdge, LabeledShape, Plane, Style } from './DI'; import { Font } from './DC'; -import {TCollaboration} from "./baseElement/rootElement/collaboration"; export interface BPMNDiagram extends Diagram { BPMNPlane: BPMNPlane; From c552e366b0fec931bcaa8bf294525ce41b5c7d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Mon, 3 Aug 2020 17:17:51 +0200 Subject: [PATCH 5/7] Update doc --- docs/architecture/bpmn-parsing.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/bpmn-parsing.adoc b/docs/architecture/bpmn-parsing.adoc index 2dede39959..cb90c3f24a 100644 --- a/docs/architecture/bpmn-parsing.adoc +++ b/docs/architecture/bpmn-parsing.adoc @@ -8,7 +8,7 @@ You can see the implementation in *BpmnXmlParser.ts*. ==== Json Parser -To parse a JSON data, we use the library https://github.com/AppVision-GmbH/json2typescript[json2typescript]. +To parse a JSON data, we use a custom parser. You can see the implementation in *BpmnJsonParser.ts*. -We create our custom _converters_ (in the *converter* folder where the *BpmnJsonParser* file is) in order to match the BPMN model to our internal model. \ No newline at end of file +We have different _converters_ (in the *converter* folder where the *BpmnJsonParser* file is) in order to match the BPMN model to our internal model. From 1d31f6b5f979e67ce45ab9de8fc7ee9dd5d1313b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Mon, 3 Aug 2020 17:24:20 +0200 Subject: [PATCH 6/7] Remove unnecessary check --- src/component/parser/json/converter/DiagramConverter.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/component/parser/json/converter/DiagramConverter.ts b/src/component/parser/json/converter/DiagramConverter.ts index 49758caad9..95348110ed 100644 --- a/src/component/parser/json/converter/DiagramConverter.ts +++ b/src/component/parser/json/converter/DiagramConverter.ts @@ -150,9 +150,7 @@ export default class DiagramConverter extends AbstractConverter { } private deserializeWaypoints(waypoints: Point[]): Waypoint[] { - if (waypoints) { - return ensureIsArray(waypoints).map(waypoint => new Waypoint(waypoint.x, waypoint.y)); - } + return ensureIsArray(waypoints).map(waypoint => new Waypoint(waypoint.x, waypoint.y)); } private deserializeLabel(bpmnLabel: string | BPMNLabel, id: string): Label { From 6bbe134b1c94a056d0ae785651fd6d6ca71670c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20Souchet?= Date: Mon, 3 Aug 2020 18:23:48 +0200 Subject: [PATCH 7/7] Remove unnecessary 'public' declaration --- src/component/parser/json/converter/AbstractConverter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/component/parser/json/converter/AbstractConverter.ts b/src/component/parser/json/converter/AbstractConverter.ts index 86a8ed36bb..2697ce3909 100644 --- a/src/component/parser/json/converter/AbstractConverter.ts +++ b/src/component/parser/json/converter/AbstractConverter.ts @@ -36,5 +36,5 @@ export function ensureIsArray(elements: (T | string)[] | T | string, acceptEm export abstract class AbstractConverter { // eslint-disable-next-line @typescript-eslint/no-explicit-any - public abstract deserialize(data: any): T; + abstract deserialize(data: any): T; }