diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java index 36b9ae9c99..b82030c8b3 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java @@ -205,7 +205,7 @@ public PipelineElementRecommendationMessage recommend(@RequestBody Pipeline pipe produces = MediaType.APPLICATION_JSON_VALUE) @Hidden @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE) - public ResponseEntity update(@RequestBody Pipeline pipeline) { + public ResponseEntity validatePipeline(@RequestBody Pipeline pipeline) { try { return ok(Operations.validatePipeline(pipeline)); } catch (JsonSyntaxException e) { diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.ts index 5a11c93a86..e0454b4c2a 100644 --- a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.ts +++ b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.ts @@ -24,6 +24,8 @@ import { Message, Pipeline, PipelineCategory, + PipelineElementRecommendationMessage, + PipelineModificationMessage, PipelineOperationStatus, PipelineStatusMessage, } from '../model/gen/streampipes-model'; @@ -150,6 +152,36 @@ export class PipelineService { ); } + recommendPipelineElement( + pipeline: Pipeline, + currentDomId: string, + ): Observable { + return this.http + .post( + `${this.apiBasePath}/pipelines/recommend/${currentDomId}`, + pipeline, + ) + .pipe( + map(data => + PipelineElementRecommendationMessage.fromData(data as any), + ), + ); + } + + /** + * Validates the given pipeline and returns a pipeline modification message. + * The message describe how the pipeline should be modified. + */ + validatePipeline(pipeline): Observable { + return this.http + .post(`${this.apiBasePath}/pipelines/update`, pipeline) + .pipe( + map(data => { + return PipelineModificationMessage.fromData(data as any); + }), + ); + } + get apiBasePath() { return this.platformServicesCommons.apiBasePath; } diff --git a/ui/src/app/editor/services/editor.service.ts b/ui/src/app/editor/services/editor.service.ts index c7aac1b216..f14a81f938 100644 --- a/ui/src/app/editor/services/editor.service.ts +++ b/ui/src/app/editor/services/editor.service.ts @@ -26,6 +26,7 @@ import { PipelineElementRecommendationMessage, PipelineModificationMessage, PipelinePreviewModel, + PipelineService, PlatformServicesCommons, SpDataStream, } from '@streampipes/platform-services'; @@ -53,6 +54,7 @@ export class EditorService { private http: HttpClient, private platformServicesCommons: PlatformServicesCommons, private dialogService: DialogService, + private pipelineService: PipelineService, ) {} get apiBasePath() { @@ -63,26 +65,14 @@ export class EditorService { pipeline: Pipeline, currentDomId: string, ): Observable { - return this.http - .post( - this.pipelinesResourceUrl + '/recommend/' + currentDomId, - pipeline, - ) - .pipe( - map(data => - PipelineElementRecommendationMessage.fromData(data as any), - ), - ); + return this.pipelineService.recommendPipelineElement( + pipeline, + currentDomId, + ); } updatePartialPipeline(pipeline): Observable { - return this.http - .post(this.pipelinesResourceUrl + '/update', pipeline) - .pipe( - map(data => { - return PipelineModificationMessage.fromData(data as any); - }), - ); + return this.pipelineService.validatePipeline(pipeline); } getCachedPipeline(): Observable { @@ -166,10 +156,6 @@ export class EditorService { return this.http.delete(this.apiBasePath + '/pipeline-canvas-cache'); } - private get pipelinesResourceUrl() { - return this.platformServicesCommons.apiBasePath + '/pipelines'; - } - announceConfiguredElement(pipelineElementDomId: string) { this.pipelineElementConfigured.next(pipelineElementDomId); }