From a0c79e6c647e8297ebae068e3784119a0470e35d Mon Sep 17 00:00:00 2001 From: MichalKinas <113341662+MichalKinas@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:05:19 +0200 Subject: [PATCH] [ACS-5601] Add getProcessesAndTasksOnContent to process content service (#8940) * [ACS-5601] Add getProcessesAndTasksOnContent to process content service * [ACS-5601] Add docs for new method * [ACS-5601] Fix import --- docs/core/services/process-content.service.md | 21 +++++++++++++++++++ .../form/services/process-content.service.ts | 15 ++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/core/services/process-content.service.md b/docs/core/services/process-content.service.md index b3e821ac62..81e0dacb45 100644 --- a/docs/core/services/process-content.service.md +++ b/docs/core/services/process-content.service.md @@ -62,6 +62,12 @@ Manipulates content related to a Process Instance or Task Instance in APS. - _taskId:_ `string` - ID of the target task - _opts:_ `any` - (Optional) Options supported by JS-API - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Metadata for the content +- **getProcessesAndTasksOnContent**(sourceId: `string`, source: `string`, size?: `number`, page?: `number`): [`Observable`](http://reactivex.io/documentation/observable.html)<[`ResultListDataRepresentationRelatedProcessTask`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/activiti-rest-api/docs/ResultListDataRepresentation%C2%ABRelatedContentRepresentation%C2%BB.md)>
+ Lists processes and tasks on workflow started with provided document + - _sourceId:_ `string` - id of the document that workflow or task has been started with + - _source:_ `string` - source of the document that workflow or task has been started with + - _size:_ `number` - size of the entries to get + - _page:_ `number` - page number - **handleError**(error: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)``
Reports an error message. - _error:_ `any` - Data object with optional `message` and `status` fields for the error @@ -377,6 +383,21 @@ this.contentService.getTaskRelatedContent(taskId).subscribe( The response format is the same as for the `getProcessRelatedContent` method, see its docs. +#### getProcessesAndTasksOnContent(sourceId: string, source: string, size?: number, page?: number): Observable`` + +Lists processes and tasks on workflow started with provided document. + +```ts +const sourceId = 'sourceId'; +const source = 'source'; +this.contentService.getProcessesAndTasksOnContent(sourceId, source).subscribe( + res => { + console.log('Response: ', res); + }, error => { + console.log('Error: ', error); + }); +``` + ## Details ## Importing diff --git a/lib/process-services/src/lib/form/services/process-content.service.ts b/lib/process-services/src/lib/form/services/process-content.service.ts index b2504d6c5f..10eb12c7a9 100644 --- a/lib/process-services/src/lib/form/services/process-content.service.ts +++ b/lib/process-services/src/lib/form/services/process-content.service.ts @@ -17,7 +17,7 @@ import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; -import { ActivitiContentApi, RelatedContentRepresentation } from '@alfresco/js-api'; +import { ActivitiContentApi, RelatedContentRepresentation, ResultListDataRepresentationRelatedProcessTask } from '@alfresco/js-api'; import { Observable, from, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; @@ -183,6 +183,19 @@ export class ProcessContentService { .pipe(catchError((err) => this.handleError(err))); } + /** + * Lists processes and tasks on workflow started with provided document + * + * @param sourceId - id of the document that workflow or task has been started with + * @param source - source of the document that workflow or task has been started with + * @param size - size of the entries to get + * @param page - page number + * @return Promise + */ + getProcessesAndTasksOnContent(sourceId: string, source: string, size?: number, page?: number): Observable { + return from(this.contentApi.getProcessesAndTasksOnContent(sourceId, source, size, page)).pipe(catchError((err) => this.handleError(err))); + } + /** * Creates a JSON representation of data. *