mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[AAE-1260] Add changes detection for ProcessHeaderCloud when a process gets cancelled (#5341)
* [AAE-1260] Add changes detection for ProcessHeaderCloud when a process is cancelled * [AAE-1260] Add service documentation * [AAE-1260] fix typo * [AAE-1260] Fix unit tests * [AAE-1260] delete process header cloud service
This commit is contained in:
committed by
Eugenio Romano
parent
af51977db4
commit
f97cf0f446
@@ -17,7 +17,9 @@
|
||||
|
||||
import { AlfrescoApiService, LogService, AppConfigService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { throwError } from 'rxjs';
|
||||
import { Observable, Subject, throwError } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model';
|
||||
import { BaseCloudService } from '../../services/base-cloud.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -25,6 +27,8 @@ import { BaseCloudService } from '../../services/base-cloud.service';
|
||||
})
|
||||
export class ProcessCloudService extends BaseCloudService {
|
||||
|
||||
dataChangesDetected = new Subject<ProcessInstanceCloud>();
|
||||
|
||||
constructor(apiService: AlfrescoApiService,
|
||||
appConfigService: AppConfigService,
|
||||
private logService: LogService) {
|
||||
@@ -33,15 +37,42 @@ export class ProcessCloudService extends BaseCloudService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a process.
|
||||
* Gets details of a process instance.
|
||||
* @param appName Name of the app
|
||||
* @param processId Id of the process to delete
|
||||
* @param processInstanceId ID of the process instance whose details you want
|
||||
* @returns Process instance details
|
||||
*/
|
||||
getProcessInstanceById(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud> {
|
||||
if (appName && processInstanceId) {
|
||||
const url = `${this.getBasePath(appName)}/query/v1/process-instances/${processInstanceId}`;
|
||||
|
||||
return this.get(url).pipe(
|
||||
map((res: any) => {
|
||||
this.dataChangesDetected.next(res.entry);
|
||||
return new ProcessInstanceCloud(res.entry);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
this.logService.error('AppName and ProcessInstanceId are mandatory for querying a process');
|
||||
return throwError('AppName/ProcessInstanceId not configured');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a process.
|
||||
* @param appName Name of the app
|
||||
* @param processInstanceId Id of the process to cancel
|
||||
* @returns Operation Information
|
||||
*/
|
||||
deleteProcess(appName: string, processId: string) {
|
||||
if (appName && processId) {
|
||||
const queryUrl = `${this.getBasePath(appName)}/rb/v1/process-instances/${processId}`;
|
||||
return this.delete(queryUrl);
|
||||
cancelProcess(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud> {
|
||||
if (appName && processInstanceId) {
|
||||
const queryUrl = `${this.getBasePath(appName)}/rb/v1/process-instances/${processInstanceId}`;
|
||||
return this.delete(queryUrl).pipe(
|
||||
map((res: any) => {
|
||||
this.dataChangesDetected.next(res.entry);
|
||||
return new ProcessInstanceCloud(res.entry);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
this.logService.error('App name and Process id are mandatory for deleting a process');
|
||||
return throwError('App name and process id not configured');
|
||||
|
Reference in New Issue
Block a user