Skip to content

Latest commit

 

History

History
536 lines (378 loc) · 13 KB

bpm-example.md

File metadata and controls

536 lines (378 loc) · 13 KB

BPM

A complete list of all the BPM methods is available herActiviti API. Below you can find some common examples.

Task Api

Below you can find some example relative to the Activiti process api for all the possible method go to Task Api documentation

List Task

listTasks(requestNode)

return a list of task based on the requestNode query

Example

import {  TasksApi } from '@alfresco/js-api';

let requestTasks = new ResultListDataRepresentationTaskRepresentation();
let taskApi = TasksApi(this.alfrescoApi);
taskApi.listTasks(requestTasks).then( 
    (data) => {
        console.log('listTasks ' + data);
}, 
    (error) => {
 console.log('Error' + error);
});

Get Task

getTask(taskId)

return the TaskRepresentation of single task by id

Parameters

Name Type Description
taskId String taskId

Example

let taskId = '10'; // String | taskId

let taskApi = TasksApi(this.alfrescoApi);
taskApi.getTask(taskId).then(function (data) {
    console.log('Task representation ' + data);
}, function (error) {
    console.log('Error' + error);
});

Filter Task

filterTasks(requestTasks)

return the ResultListDataRepresentation that is a list of all the task filered

Parameters

Name Type Description
requestTasks TaskFilterRequestRepresentation requestTasks

Example

let requestTasks = new TaskFilterRequestRepresentation();
requestTasks.appDefinitionId = 1;

let taskApi = TasksApi(this.alfrescoApi);
taskApi.filterTasks(requestTasks).then(function (data) {
    console.log('Task filter list ' + data);
}, function (error) {
    console.log('Error' + error);
});

Complete Task

completeTask(taskId)

To complete a task (standalone or without a task form) :

Parameters

Name Type Description
taskId String taskId

Example

let taskId = '10'; // String | taskId

let taskApi = TasksApi(this.alfrescoApi);
taskApi.taskApi.completeTask(taskId).then(() => {
    console.log('Task completed');
}, function (error) {
    console.log('Error' + error);
});

Get Task Form

getTaskForm(taskId)

Retrieve the Task Form representation. FormDefinitionRepresentation

Parameters

Name Type Description
taskId String taskId

Example

let taskId = '10'; // String | taskId

let taskApi = TasksApi(this.alfrescoApi);
taskApi.getTaskForm(taskId).then(function (data) {
   console.log('Task form representation' + data);
}, function (error) {
   console.log('Error' + error);
});

Complete Task Form

completeTaskForm(taskId, completeTaskFormRepresentation)

Complete a Task Form

Parameters

Name Type Description
taskId String taskId
completeTaskFormRepresentation CompleteFormRepresentation completeTaskFormRepresentation

Example

let taskId = '10'; // String | taskId
let taskApi = TasksApi(this.alfrescoApi);
taskApi..completeTaskForm(taskId, completeTaskFormRepresentation).then(() => {
    console.log('Task completed');
}, function (error) {
    console.log('Error' + error);
});

Process Api

Below you can find some example relative to the Activiti process api for all the possible method go to Process Api documentation

Get Process Instances

getProcessInstances(requestNode)

Retrieve a list of process instances ResultListDataRepresentation

Parameters

Name Type Description
requestNode ProcessFilterRequestRepresentation requestNode

Example

let requestNode = new ProcessInstanceQueryRepresentation();

let processApi = ProcessApi(this.alfrescoApi);
processApi.getProcessInstances(requestNode).then(function (data) {
    console.log('All processes' + data);
}, function (error) {
    console.log('Error' + error);
});

Filtered process:

let requestNode = new ProcessInstanceQueryRepresentation();

page = 0;
requestNode.sort = 'created-desc';
requestNode.state = 'completed';

let processApi = ProcessApi(this.alfrescoApi);
processApi.getProcessInstances(requestNode).then(function (data) {
   console.log('All processes completed' + data);
}, function (error) {
   console.log('Error' + error);
});

Models Api

Below you can find some example relative to the Activiti process api for all the possible method go to Task Api documentation

Get Model

getModel(modelId, opts)

To retrieve details about a particular model (process, form, decision rule or app) return a ModelRepresentation

Parameters

Name Type Description Notes
modelId Integer modelId
includePermissions Boolean includePermissions [optional]

Example

let opts = {
    'filter': 'myReusableForms',
    'modelType': 2
};

let modelsApi = ModelsApi(this.alfrescoApi);
modelsApi.getModels(opts).then(function (data) {
    console.log('All your reusable forms' + data);
 }, function (error) {
    console.log('Error' + error);
 });

Report Api

Below you can find some example relative to the Activiti report api for all the possible method go to Report Api documentation

Create default Reports

createDefaultReports()

Create the default reports

Parameters

No parameters required.

Example

let reportApi = ReportApi(this.alfrescoApi);
reportApi.createDefaultReports();

Get Reports

getReportList()

Retrieve the available report list

Parameters

No parameters required.

Example

let reportApi = ReportApi(this.alfrescoApi);
reportApi.getReportList();

Report Params

getReportParams(reportId)

Retrieve the parameters referring to the reportId.

Parameters

Name Type Description Notes
reportId String reportId

Example

let reportId = "1"; // String | reportId
let reportApi = ReportApi(this.alfrescoApi);
reportApi.getReportParams(reportId);

Report Process Definitions

getProcessDefinitions()

Retrieve the process definition list for all the apps.

Parameters

No parameters required.

Example

let reportApi = ReportApi(this.alfrescoApi);
reportApi.getProcessDefinitions();

Tasks of process definition

getTasksByProcessDefinitionId(reportId, processDefinitionId)

Retrieves all tasks that refer to the processDefinitionId

Parameters

Name Type Description Notes
reportId String reportId
processDefinitionId String process definition id

Example

let reportId = "1"; // String | reportId
let processDefinitionId = "1"; // String | processDefinitionId

let reportApi = ReportApi(this.alfrescoApi);
reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId);

Generate reports

getReportsByParams(reportId, paramsQuery)

Generate the reports based on the input parameters

Parameters

Name Type Description Notes
reportId String reportId
paramsQuery Object Query parameters

Example

let reportId = "1"; // String | reportId
let paramsQuery = {status: 'ALL'}; // Object | paramsQuery

let reportApi = ReportApi(this.alfrescoApi);
reportApi.getReportsByParams(reportId, paramsQuery);

Update report details

updateReport(reportId, name)

Update the report details

Parameters

Name Type Description Notes
reportId String reportId
name String The report name

Example

let reportId = "1"; // String | reportId
let name = "new Fake name"; // String | reportId

let reportApi = ReportApi(this.alfrescoApi);
reportApi.updateReport(reportId, name);

Export to csv

exportToCsv(reportId, queryParms)

Export a report as csv

Parameters

Name Type Description Notes
reportId String reportId
queryParms Object Query parameters

Example

let reportId = "1"; // String | reportId
let queryParms = {
            'processDefinitionId': 'TEST:99:999',
            'dateRange': {
                'startDate': '2017-01-01T00:00:00.000Z',
                'endDate': '2017-01-24T23:59:59.999Z',
                'rangeId': 'currentYear'
            },
            'slowProcessInstanceInteger': 10,
            'status': 'All',
            '__reportName': 'FAKE_REPORT_NAME'
        };

let reportApi = ReportApi(this.alfrescoApi);
reportApi.exportToCsv(reportId, queryParms);

Save Report

saveReport(reportId, queryParams)

Save a report

Parameters

Name Type Description Notes
reportId String reportId
queryParms Object Query parameters

Example

let reportId = "1"; // String | reportId
let queryParms = {
            'processDefinitionId': 'TEST:99:999',
            'dateRange': {
                'startDate': '2017-01-01T00:00:00.000Z',
                'endDate': '2017-01-24T23:59:59.999Z',
                'rangeId': 'currentYear'
            },
            'slowProcessInstanceInteger': 10,
            'status': 'All',
            '__reportName': 'FAKE_REPORT_NAME'
        };

let reportApi = ReportApi(this.alfrescoApi);
reportApi.saveReport(reportId, queryParms);

Delete report

deleteReport(reportId)

Delete a report

Parameters

Name Type Description Notes
reportId String reportId

Example

let reportId = "1"; // String | reportId

let reportApi = ReportApi(this.alfrescoApi);
reportApi.deleteReport(reportId);