[ACA-4057] Edit getProcessInstanceByName method to search the process instance directly by its name (#6303)

* Add size value to getProcessInstanceByName

* edit getProcessInstanceByName method to search the process instance directly by its name

* add more options for filtering the list
This commit is contained in:
Iulia Burcă
2020-11-04 20:15:11 +02:00
committed by GitHub
parent 5f76a7c340
commit fff574c216

View File

@@ -92,15 +92,11 @@ export class ProcessUtil {
} }
} }
async getProcessInstanceByName(processInstanceName: string): Promise<any> { async getProcessInstanceByName(processInstanceName: string, processInstanceStatus?: string, maxNumberOfResults?: number): Promise<any> {
try { try {
const processInstanceList = await this.api.apiService.activiti.processApi.getProcessInstances({state: 'all'}); return await this.api.apiService.activiti.processApi.filterProcessInstances({filter: {name: processInstanceName, state: processInstanceStatus}, size: maxNumberOfResults});
const chosenProcessInstance = processInstanceList.data.find( (processInstanace) => {
return processInstanace.name === processInstanceName;
});
return chosenProcessInstance;
} catch (error) { } catch (error) {
Logger.error('Get Process Instance by Name - Service error, Response: ', JSON.parse(JSON.stringify(error))); Logger.error('List process instances using a filter - Service error, Response: ', JSON.parse(JSON.stringify(error)));
} }
} }