mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
6389019561
commit
313e535b8d
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
48
lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts
Normal file
48
lib/testing/src/lib/form-cloud/actions/form-cloud.service.ts
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
18
lib/testing/src/lib/form-cloud/actions/public-api.ts
Normal file
18
lib/testing/src/lib/form-cloud/actions/public-api.ts
Normal 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';
|
18
lib/testing/src/lib/form-cloud/public-api.ts
Normal file
18
lib/testing/src/lib/form-cloud/public-api.ts
Normal 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';
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -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';
|
||||
|
@@ -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';
|
||||
|
Reference in New Issue
Block a user