mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4340]Add method for createProcessInstanceAndClaimFirstTask
* Add method for createProcessInstanceAndClaimFirstTask * Instantiate in constructor * Change data to be public * Fix lint
This commit is contained in:
@@ -267,6 +267,12 @@ export class ViewerPage {
|
|||||||
await BrowserVisibility.waitUntilElementHasText(this.fileName, filename);
|
await BrowserVisibility.waitUntilElementHasText(this.fileName, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async checkFileIsOpenedInViewerAndClose(filename: string): Promise<void> {
|
||||||
|
await this.checkFileThumbnailIsDisplayed();
|
||||||
|
await this.checkFileNameIsDisplayed(filename);
|
||||||
|
await this.clickCloseButton();
|
||||||
|
}
|
||||||
|
|
||||||
async checkPreviousPageButtonIsDisplayed() {
|
async checkPreviousPageButtonIsDisplayed() {
|
||||||
await BrowserVisibility.waitUntilElementIsVisible(this.previousPageButton);
|
await BrowserVisibility.waitUntilElementIsVisible(this.previousPageButton);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,70 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { ApiUtil } from '../../core/actions/api.util';
|
||||||
|
import { ProcessDefinitionsService } from './process-definitions.service';
|
||||||
|
import { ProcessInstancesService } from './process-instances.service';
|
||||||
|
import { QueryService } from '../../core/actions/identity/query.service';
|
||||||
|
import { TasksService } from './tasks.service';
|
||||||
|
import { StringUtil } from '../../core/utils/string.util';
|
||||||
|
import { Logger } from '../../core/utils/logger';
|
||||||
|
|
||||||
|
export class ProcessServices {
|
||||||
|
|
||||||
|
private api: ApiService;
|
||||||
|
public processInstancesService: ProcessInstancesService;
|
||||||
|
public processDefinitionsService: ProcessDefinitionsService;
|
||||||
|
public tasksService: TasksService;
|
||||||
|
public queryService: QueryService;
|
||||||
|
|
||||||
|
constructor(api: ApiService) {
|
||||||
|
this.api = api;
|
||||||
|
this.processInstancesService = new ProcessInstancesService(this.api);
|
||||||
|
this.processDefinitionsService = new ProcessDefinitionsService(this.api);
|
||||||
|
this.tasksService = new TasksService(this.api);
|
||||||
|
this.queryService = new QueryService(this.api);
|
||||||
|
}
|
||||||
|
|
||||||
|
async createProcessInstanceAndClaimFirstTask(processDefName, appName, taskIndex: number = 0, processInstanceName?: string) {
|
||||||
|
const processInstance = await this.createProcessInstance(processDefName, appName, processInstanceName);
|
||||||
|
const task = await this.queryService.getProcessInstanceTasks(processInstance.entry.id, appName);
|
||||||
|
await this.tasksService.claimTask(task.list.entries[taskIndex].entry.id, appName);
|
||||||
|
|
||||||
|
return processInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
async createProcessInstance(processDefName, appName, processInstanceName?: string) {
|
||||||
|
const processDefinition = await this.processDefinitionsService.getProcessDefinitionByName(processDefName, appName);
|
||||||
|
const processInstance = await this.processInstancesService.createProcessInstance(processDefinition.entry.key, appName, {
|
||||||
|
name: processInstanceName ? processInstanceName : StringUtil.generateRandomString(),
|
||||||
|
businessKey: StringUtil.generateRandomString()
|
||||||
|
});
|
||||||
|
|
||||||
|
return processInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitForStatus(processInstanceId: string, appName: string, expectedStatus: string): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
Logger.info(`Process instance ${processInstanceId} status found: ${result.entry.status}`);
|
||||||
|
return result.entry.status === expectedStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => this.queryService.getProcessInstance(processInstanceId, appName);
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate, 3, 500);
|
||||||
|
}
|
||||||
|
}
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
export * from './process-definitions.service';
|
export * from './process-definitions.service';
|
||||||
export * from './process-instances.service';
|
export * from './process-instances.service';
|
||||||
|
export * from './process.services';
|
||||||
export * from './message-events.service';
|
export * from './message-events.service';
|
||||||
export * from './form-cloud.service';
|
export * from './form-cloud.service';
|
||||||
export * from './tasks.service';
|
export * from './tasks.service';
|
||||||
|
@@ -176,7 +176,8 @@
|
|||||||
"uploadSingleMultiple": {
|
"uploadSingleMultiple": {
|
||||||
"name": "upload-single-multiple",
|
"name": "upload-single-multiple",
|
||||||
"widgets": {
|
"widgets": {
|
||||||
"contentMultipleAttachFileId": "UploadMultipleFileFromContentId"
|
"contentMultipleAttachFileId": "UploadMultipleFileFromContentId",
|
||||||
|
"contentSingleAttachFileId": "UploadSingleFileFromContentId"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"formWithJsonWidget": {
|
"formWithJsonWidget": {
|
||||||
|
Reference in New Issue
Block a user