Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#2379): Move pipeline rest calls to pipeline service #2381

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
Message,
Pipeline,
PipelineCategory,
PipelineElementRecommendationMessage,
PipelineModificationMessage,
PipelineOperationStatus,
PipelineStatusMessage,
} from '../model/gen/streampipes-model';
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 7 additions & 21 deletions ui/src/app/editor/services/editor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
PipelineElementRecommendationMessage,
PipelineModificationMessage,
PipelinePreviewModel,
PipelineService,
PlatformServicesCommons,
SpDataStream,
} from '@streampipes/platform-services';
Expand Down Expand Up @@ -53,6 +54,7 @@ export class EditorService {
private http: HttpClient,
private platformServicesCommons: PlatformServicesCommons,
private dialogService: DialogService,
private pipelineService: PipelineService,
) {}

get apiBasePath() {
Expand All @@ -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[]> {
Expand Down Expand Up @@ -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);
}
Expand Down
Loading