From 27f35dfe24def14348069966e1dd95aa52d6f989 Mon Sep 17 00:00:00 2001 From: Martin Bergljung Date: Thu, 23 Nov 2017 11:30:57 +0000 Subject: [PATCH] [ADF-1586] ProcessService & ProcessFilterService documentation update because of 2.0 reorg (#2703) --- docs/process-filter.service.md | 205 +++++++++++++++++++++++++++++++++ docs/process.service.md | 197 +------------------------------ 2 files changed, 209 insertions(+), 193 deletions(-) create mode 100644 docs/process-filter.service.md diff --git a/docs/process-filter.service.md b/docs/process-filter.service.md new file mode 100644 index 0000000000..9ef756cc13 --- /dev/null +++ b/docs/process-filter.service.md @@ -0,0 +1,205 @@ +# Process Filter Service +Manage Process Filters, which are pre-configured Process Instance queries. + +## Importing + +```ts +import { ProcessFilterService, FilterProcessRepresentationModel } from '@alfresco/adf-process-services'; + +export class SomePageComponent implements OnInit { + + constructor(private processFilterService: ProcessFilterService) { + } +``` + +## Methods + +#### createDefaultFilters(appId: number): Observable`` +Create and return the default filters for a Process App: + +```ts +const processAppId = 2; +this.processFilterService.createDefaultFilters(processAppId) + .subscribe( filters => { + console.log('filters: ', filters); +}, error => { + console.log('Error: ', error); +}); +``` + +The response is an array of `FilterProcessRepresentationModel` objects: + +``` +filters: + 0: { + appId: 2 + filter: + name: "" + sort: "created-desc" + state: "running" + icon: "glyphicon-random" + id: null + index: undefined + name: "Running" + recent: true + } + 1: {id: null, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} + 2: {id: null, appId: 2, name: "All", recent: true, icon: "glyphicon-th", …} +``` + +These filters can now be used to get matching process instances for Process App with ID 2, +such as 'Running', 'Completed', and 'All' . + +#### getProcessFilters(appId: number): Observable`` +Get all filters defined for a Process App: + +```ts +const processAppId = 2; +this.processFilterService.getProcessFilters(processAppId) + .subscribe( (filters: FilterProcessRepresentationModel[]) => { + console.log('filters: ', filters); +}, error => { + console.log('Error: ', error); +}); +``` + +The response is an array of `FilterProcessRepresentationModel` objects: + +``` +filters: + 0: {id: 15, appId: 2, name: "Running", recent: true, icon: "glyphicon-random", …} + 1: {id: 14, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} + 2: {id: 13, appId: 2, name: "All", recent: false, icon: "glyphicon-th", …} + 3: {id: 3003, appId: 2, name: "Running", recent: false, icon: "glyphicon-random", …} + 4: {id: 3004, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} + 5: {id: 3005, appId: 2, name: "All", recent: false, icon: "glyphicon-th", …} + +``` +In this example I had run the `createDefaultFilters` method ones and that created the duplicate of +the default filters. + +These filters can now be used to get matching process instances for Process App with ID 2, +such as 'Running', 'Completed', and 'All' . + +#### getProcessFilterById(filterId: number, appId?: number): Observable`` +Get a specific Process Filter based on its ID, optionally pass in Process App ID to improve performance +when searching for filter: + +```ts +const processAppId = 2; +const filterId = 3003; +this.processFilterService.getProcessFilterById(filterId, processAppId) + .subscribe( (filter: FilterProcessRepresentationModel) => { + console.log('filter: ', filter); +}, error => { + console.log('Error: ', error); +}); +``` + +The response is a `FilterProcessRepresentationModel` object: + +``` +appId: 2 +filter: {sort: "created-desc", name: "", state: "running"} +icon: "glyphicon-random" +id: 3003 +name: "Running" +recent: false +``` + +The filter can now be used to get 'Running' process instances for Process App with ID 2. + +#### getProcessFilterByName(filterName: string, appId?: number): Observable`` +Get a specific Process Filter based on its name, optionally pass in Process App ID to improve performance +when searching for filter: + +```ts +const processAppId = 2; +const filterName = 'Running'; +this.processFilterService.getProcessFilterByName(filterName, processAppId) + .subscribe( (filter: FilterProcessRepresentationModel) => { + console.log('filter: ', filter); +}, error => { + console.log('Error: ', error); +}); +``` + +The response is a `FilterProcessRepresentationModel` object: + +``` +appId: 2 +filter: {sort: "created-desc", name: "", state: "running"} +icon: "glyphicon-random" +id: 15 +name: "Running" +recent: true +``` +If there are several filters with the same name for the Process App, then you get back the +first one found matching the name. + +The filter can now be used to get 'Running' process instances for Process App with ID 2. + +#### addProcessFilter(filter: FilterProcessRepresentationModel): Observable`` +Add a new Process Instance filter: + +```ts +const processAppId = 2; +const filterName = 'RunningAsc'; +const filterRunningAsc = new FilterProcessRepresentationModel({ + 'name': filterName, + 'appId': processAppId, + 'recent': true, + 'icon': 'glyphicon-random', + 'filter': { 'sort': 'created-asc', 'name': 'runningasc', 'state': 'running' } +}); +this.processFilterService.addProcessFilter(filterRunningAsc) + .subscribe( (filterResponse: FilterProcessRepresentationModel) => { + console.log('filterResponse: ', filterResponse); +}, error => { + console.log('Error: ', error); +}); +``` + +The response is a `FilterProcessRepresentationModel` object: + +``` +appId: 2 +icon: "glyphicon-random" +id: 3008 +name: "RunningAsc" +recent: false +``` + +The filter can now be used to get 'Running' process instances for +Process App with ID 2 in created date ascending order. + +See also the `getRunningFilterInstance` method. + +#### getRunningFilterInstance(appId: number): FilterProcessRepresentationModel +Convenience method to create and return a filter that matches `running` process instances +for passed in Process App ID: + +```ts +const processAppId = 2; +const runningFilter: FilterProcessRepresentationModel = this.processFilterService.getRunningFilterInstance(processAppId); +console.log('Running filter', runningFilter); +``` + +The response is a `FilterProcessRepresentationModel` object: + +``` +appId: 2 +filter: {sort: "created-desc", name: "", state: "running"} +icon: "glyphicon-random" +id: null +index: undefined +name: "Running" +recent: true +``` + +The filter can now be used to get 'Running' process instances for +Process App with ID 2 in created date ascending order. + + + + \ No newline at end of file diff --git a/docs/process.service.md b/docs/process.service.md index 8ce9343d07..bdb6fc8700 100644 --- a/docs/process.service.md +++ b/docs/process.service.md @@ -1,14 +1,11 @@ # Process Service -Manage Process Instances, filters, variables, and audit log. +Manage Process Instances, Process Variables, and Process Audit Log. ## Importing ```ts import { ProcessService, ProcessInstance, ProcessInstanceVariable, - ProcessDefinitionRepresentation, FilterProcessRepresentationModel, - ProcessFilterParamRepresentationModel } from 'ng2-activiti-processlist'; - -import { TaskDetailsModel } from 'ng2-activiti-tasklist'; + ProcessDefinitionRepresentation, ProcessFilterParamRepresentationModel, TaskDetailsModel } from '@alfresco/adf-process-services'; export class SomePageComponent implements OnInit { @@ -146,7 +143,7 @@ this.processService.startProcess(processDefinitionId, name) }); ``` -#### cancelProcess(processInstanceId: string): Observable`` +#### cancelProcess(processInstanceId: string): Observable`` Cancel a process instance by passing in its process instance ID: ```ts @@ -282,192 +279,6 @@ this.processService.getProcessDefinitions() }); ``` -#### createDefaultFilters(appId: number): Observable`` -Create and return the default filters for a Process App: - -```ts -const processAppId = 2; -this.processService.createDefaultFilters(processAppId) - .subscribe( filters => { - console.log('filters: ', filters); -}, error => { - console.log('Error: ', error); -}); -``` - -The response is an array of `FilterProcessRepresentationModel` objects: - -``` -filters: - 0: { - appId: 2 - filter: - name: "" - sort: "created-desc" - state: "running" - icon: "glyphicon-random" - id: null - index: undefined - name: "Running" - recent: true - } - 1: {id: null, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} - 2: {id: null, appId: 2, name: "All", recent: true, icon: "glyphicon-th", …} -``` - -These filters can now be used to get matching process instances for Process App with ID 2, -such as 'Running', 'Completed', and 'All' . - -#### getProcessFilters(appId: number): Observable`` -Get all filters defined for a Process App: - -```ts -const processAppId = 2; -this.processService.getProcessFilters(processAppId) - .subscribe( (filters: FilterProcessRepresentationModel[]) => { - console.log('filters: ', filters); -}, error => { - console.log('Error: ', error); -}); -``` - -The response is an array of `FilterProcessRepresentationModel` objects: - -``` -filters: - 0: {id: 15, appId: 2, name: "Running", recent: true, icon: "glyphicon-random", …} - 1: {id: 14, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} - 2: {id: 13, appId: 2, name: "All", recent: false, icon: "glyphicon-th", …} - 3: {id: 3003, appId: 2, name: "Running", recent: false, icon: "glyphicon-random", …} - 4: {id: 3004, appId: 2, name: "Completed", recent: false, icon: "glyphicon-ok-sign", …} - 5: {id: 3005, appId: 2, name: "All", recent: false, icon: "glyphicon-th", …} - -``` -In this example I had run the `createDefaultFilters` method ones and that created the duplicate of -the default filters. - -These filters can now be used to get matching process instances for Process App with ID 2, -such as 'Running', 'Completed', and 'All' . - -#### getProcessFilterById(filterId: number, appId?: number): Observable`` -Get a specific Process Filter based on its ID, optionally pass in Process App ID to improve performance -when searching for filter: - -```ts -const processAppId = 2; -const filterId = 3003; -this.processService.getProcessFilterById(filterId, processAppId) - .subscribe( (filter: FilterProcessRepresentationModel) => { - console.log('filter: ', filter); -}, error => { - console.log('Error: ', error); -}); -``` - -The response is a `FilterProcessRepresentationModel` object: - -``` -appId: 2 -filter: {sort: "created-desc", name: "", state: "running"} -icon: "glyphicon-random" -id: 3003 -name: "Running" -recent: false -``` - -The filter can now be used to get 'Running' process instances for Process App with ID 2. - -#### getProcessFilterByName(filterName: string, appId?: number): Observable`` -Get a specific Process Filter based on its name, optionally pass in Process App ID to improve performance -when searching for filter: - -```ts -const processAppId = 2; -const filterName = 'Running'; -this.processService.getProcessFilterByName(filterName, processAppId) - .subscribe( (filter: FilterProcessRepresentationModel) => { - console.log('filter: ', filter); -}, error => { - console.log('Error: ', error); -}); -``` - -The response is a `FilterProcessRepresentationModel` object: - -``` -appId: 2 -filter: {sort: "created-desc", name: "", state: "running"} -icon: "glyphicon-random" -id: 15 -name: "Running" -recent: true -``` -If there are several filters with the same name for the Process App, then you get back the -first one found matching the name. - -The filter can now be used to get 'Running' process instances for Process App with ID 2. - -#### addProcessFilter(filter: FilterProcessRepresentationModel): Observable`` -Add a new Process Instance filter: - -```ts -const processAppId = 2; -const filterName = 'RunningAsc'; -const filterRunningAsc = new FilterProcessRepresentationModel({ - 'name': filterName, - 'appId': processAppId, - 'recent': true, - 'icon': 'glyphicon-random', - 'filter': { 'sort': 'created-asc', 'name': 'runningasc', 'state': 'running' } -}); -this.processService.addProcessFilter(filterRunningAsc) - .subscribe( (filterResponse: FilterProcessRepresentationModel) => { - console.log('filterResponse: ', filterResponse); -}, error => { - console.log('Error: ', error); -}); -``` - -The response is a `FilterProcessRepresentationModel` object: - -``` -appId: 2 -icon: "glyphicon-random" -id: 3008 -name: "RunningAsc" -recent: false -``` - -The filter can now be used to get 'Running' process instances for -Process App with ID 2 in created date ascending order. - -See also the `getRunningFilterInstance` method. - -#### getRunningFilterInstance(appId: number): FilterProcessRepresentationModel -Convenience method to create and return a filter that matches `running` process instances -for passed in Process App ID: - -```ts -const processAppId = 2; -const runningFilter: FilterProcessRepresentationModel = this.processService.getRunningFilterInstance(processAppId); -console.log('Running filter', runningFilter); -``` - -The response is a `FilterProcessRepresentationModel` object: - -``` -appId: 2 -filter: {sort: "created-desc", name: "", state: "running"} -icon: "glyphicon-random" -id: null -index: undefined -name: "Running" -recent: true -``` - -The filter can now be used to get 'Running' process instances for -Process App with ID 2 in created date ascending order. - #### getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable`` Get Process Instances for passed in filter and optionally Process Definition: @@ -523,7 +334,7 @@ The response is an array of `TaskDetailsModel` objects as in this example: "start":0, "data":[ {"id":"75010", - "name":"Approve Invoice - [UNKNOWN]", + "name":"Approve Invoice - [Invoice 123]", "description":null, "category":null, "assignee":{"id":1,"firstName":null,"lastName":"Administrator","email":"admin@app.activiti.com"},