This is an automated email from the ASF dual-hosted git repository. riemer pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 4f4a4ed47e2eb10c24370ca09e4aa49f28859154 Author: Dominik Riemer <[email protected]> AuthorDate: Thu May 20 10:56:10 2021 +0200 [hotfix] Fix bug causing exception when building pipelines with multiple elements of same type --- .../components/pipeline/pipeline.component.ts | 7 ++++++- ui/src/app/editor/services/jsplumb.service.ts | 24 +++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ui/src/app/editor/components/pipeline/pipeline.component.ts b/ui/src/app/editor/components/pipeline/pipeline.component.ts index e9b8bc7..de33c1e 100644 --- a/ui/src/app/editor/components/pipeline/pipeline.component.ts +++ b/ui/src/app/editor/components/pipeline/pipeline.component.ts @@ -210,7 +210,12 @@ export class PipelineComponent implements OnInit, OnDestroy { let pipelineElement: PipelineElementUnion = this.findPipelineElementByElementId(pipelineElementId); if (ui.draggable.hasClass('draggable-icon')) { this.EditorService.makePipelineAssemblyEmpty(false); - var pipelineElementConfig = this.JsplumbService.createNewPipelineElementConfig(pipelineElement, this.PipelineEditorService.getCoordinates(ui, this.currentZoomLevel), false, false); + let newElementId = pipelineElement.elementId + ":" + this.JsplumbService.makeId(5); + let pipelineElementConfig = this.JsplumbService.createNewPipelineElementConfig(pipelineElement, + this.PipelineEditorService.getCoordinates(ui, this.currentZoomLevel), + false, + false, + newElementId); if ((this.isStreamInPipeline() && pipelineElementConfig.type == 'set') || this.isSetInPipeline() && pipelineElementConfig.type == 'stream') { this.showMixedStreamAlert(); diff --git a/ui/src/app/editor/services/jsplumb.service.ts b/ui/src/app/editor/services/jsplumb.service.ts index 8bdcf2e..5114b18 100644 --- a/ui/src/app/editor/services/jsplumb.service.ts +++ b/ui/src/app/editor/services/jsplumb.service.ts @@ -137,13 +137,14 @@ export class JsplumbService { createNewPipelineElementConfig(pipelineElement: PipelineElementUnion, coordinates, isPreview: boolean, - isCompleted: boolean): PipelineElementConfig { + isCompleted: boolean, + newElementId?: string): PipelineElementConfig { let displaySettings = isPreview ? 'connectable-preview' : 'connectable-editor'; let connectable = "connectable"; let pipelineElementConfig = {} as PipelineElementConfig; pipelineElementConfig.type = PipelineElementTypeUtils .toCssShortHand(PipelineElementTypeUtils.fromType(pipelineElement)) - pipelineElementConfig.payload = this.clone(pipelineElement); + pipelineElementConfig.payload = this.clone(pipelineElement, newElementId); pipelineElementConfig.settings = {connectable: connectable, openCustomize: !(pipelineElement as any).configured, preview: isPreview, @@ -163,18 +164,31 @@ export class JsplumbService { return pipelineElementConfig; } - clone(pipelineElement: PipelineElementUnion) { + clone(pipelineElement: PipelineElementUnion, newElementId?: string) { if (pipelineElement instanceof SpDataSet) { return SpDataSet.fromData(pipelineElement, new SpDataSet()); } else if (pipelineElement instanceof SpDataStream) { return SpDataStream.fromData(pipelineElement, new SpDataStream()); } else if (pipelineElement instanceof DataProcessorInvocation) { - return DataProcessorInvocation.fromData(pipelineElement, new DataProcessorInvocation()); + let clonedPe = DataProcessorInvocation.fromData(pipelineElement, new DataProcessorInvocation()); + if (newElementId) { + this.updateElementIds(clonedPe, newElementId) + } + return clonedPe; } else { - return DataSinkInvocation.fromData(pipelineElement, new DataSinkInvocation()); + let clonedPe = DataSinkInvocation.fromData(pipelineElement, new DataSinkInvocation()); + if (newElementId) { + this.updateElementIds(clonedPe, newElementId); + } + return clonedPe; } } + updateElementIds(pipelineElement: PipelineElementUnion, newElementId: string) { + pipelineElement.elementId = newElementId; + pipelineElement.uri = newElementId; + } + makeId(count: number) { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
