This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new aa8e60570 feat(#2379): Move pipeline rest calls to pipeline service
(#2381)
aa8e60570 is described below
commit aa8e605704dc79177d75b082dedf01b0440bf3d8
Author: Philipp Zehnder <[email protected]>
AuthorDate: Fri Dec 29 16:36:25 2023 +0100
feat(#2379): Move pipeline rest calls to pipeline service (#2381)
* feat(#2379): Move pipeline rest calls to pipeline service
* feat(#2379): Fix route for pipelines endpoint
---
.../streampipes/rest/impl/PipelineResource.java | 2 +-
.../src/lib/apis/pipeline.service.ts | 32 ++++++++++++++++++++++
ui/src/app/editor/services/editor.service.ts | 28 +++++--------------
3 files changed, 40 insertions(+), 22 deletions(-)
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 36b9ae9c9..b82030c8b 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 class PipelineResource extends
AbstractAuthGuardedRestResource {
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 5a11c93a8..e0454b4c2 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<PipelineElementRecommendationMessage> {
+ 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<PipelineModificationMessage> {
+ 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 c7aac1b21..f14a81f93 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<PipelineElementRecommendationMessage> {
- 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<PipelineModificationMessage> {
- return this.http
- .post(this.pipelinesResourceUrl + '/update', pipeline)
- .pipe(
- map(data => {
- return PipelineModificationMessage.fromData(data as any);
- }),
- );
+ return this.pipelineService.validatePipeline(pipeline);
}
getCachedPipeline(): Observable<PipelineElementConfig[]> {
@@ -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);
}