[DW-1521] added message-events api methods (#5146)

* added message events api

* added export

* added the getProcessInstance method in the queryservice

* added form-cloud.service with method to submit the form.

* added form-cloud.service with method to submit the form.

* returning the error instead of throwing, which can be used in expected negative api assertions in the test.

* added getTaskByNAme method to filter a task by unique task-name within a process-instance

* linting fix

* made correlation key as optional parameter

* removed the unnecessary tslint disable statements

* removed the unnecessary tslint disable statements and reverted the throw error statement

* logging response is not needed

* added return type

* added return type
This commit is contained in:
Geeta Mandakini Ayyalasomayajula
2019-10-16 21:18:07 +01:00
committed by Eugenio Romano
parent 6389019561
commit 313e535b8d
7 changed files with 185 additions and 0 deletions

View File

@@ -39,6 +39,19 @@ export class QueryService {
}
}
async getProcessInstance(processInstanceId, appName): Promise<any> {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId;
const method = 'GET';
const queryParams = {}, postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('get process-instance Service error');
}
}
async getProcessInstanceSubProcesses(processInstanceId, appName): Promise<any> {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/subprocesses';
@@ -52,4 +65,22 @@ export class QueryService {
}
}
async getTaskByName(taskName, processInstanceId, appName): Promise<any> {
try {
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
const method = 'GET';
const queryParams = {}, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
for (let i = 0; i < data.list.entries.length; i++) {
if (data.list.entries[i].entry.name === taskName) {
return data.list.entries[i];
}
}
} catch (error) {
Logger.error('Get Task By Name - Service error');
}
}
}

View File

@@ -0,0 +1,48 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from '../../core/actions/api.service';
import { Logger } from '../../core/utils/logger';
export class FormCloudService {
api: ApiService;
constructor(api: ApiService) {
this.api = api;
}
async submitForm(formId, appName, taskId, processInstanceId, values): Promise<any> {
try {
const path = '/' + appName + '/form/v1/forms/' + formId + '/submit';
const method = 'POST';
const queryParams = {}, postBody = {
'values': values,
'taskId': taskId,
'processInstanceId': processInstanceId
};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Form Submit Service not working', error.message);
}
}
}

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './form-cloud.service';

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './actions/public-api';

View File

@@ -0,0 +1,68 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from '../../core/actions/api.service';
import { Logger } from '../../core/utils/logger';
export class MessageEventsService {
api: ApiService;
constructor(api: ApiService) {
this.api = api;
}
async startMessageEvent(startMessage, appName, options?: any): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/process-instances/message';
const method = 'POST';
const queryParams = {}, postBody = {
'name': startMessage,
'variables': {},
'payloadType': 'StartMessagePayload',
...options
};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Start Message Event Service not working', error.message);
}
}
async receiveMessageEvent(receiveMessage, appName, options?: any): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/process-instances/message';
const method = 'PUT';
const queryParams = {}, postBody = {
'name': receiveMessage,
'variables': {},
'payloadType': 'ReceiveMessagePayload',
...options
};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Receive Message Event Service not working', error.message);
}
}
}

View File

@@ -19,3 +19,4 @@ export * from './testing-alfresco-api.service';
export * from './testing-app-config.service';
export * from './process-definitions.service';
export * from './process-instances.service';
export * from './message-events.service';

View File

@@ -16,6 +16,7 @@
*/
export * from './lib/core/public-api';
export * from './lib/form-cloud/public-api';
export * from './lib/material/public-api';
export * from './lib/content-services/public-api';
export * from './lib/material/public-api';