mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Remove processDefinitionKey from Process Model (#2459)
This commit is contained in:
parent
a4c427e9ee
commit
2fff4d038e
@ -76,3 +76,86 @@ export let exampleProcessNoName = new ProcessInstance({
|
|||||||
},
|
},
|
||||||
processDefinitionName: 'My Process'
|
processDefinitionName: 'My Process'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export let fakeProcessInstances = {
|
||||||
|
size: 2,
|
||||||
|
total: 2,
|
||||||
|
start: 0,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: '340124',
|
||||||
|
name: 'James Franklin EMEA Onboarding',
|
||||||
|
businessKey: null,
|
||||||
|
processDefinitionId: 'HROnboarding:60:338704',
|
||||||
|
tenantId: 'tenant_1',
|
||||||
|
started: '2017-10-09T12:19:44.560+0000',
|
||||||
|
ended: null,
|
||||||
|
startedBy: {
|
||||||
|
id: 4004,
|
||||||
|
firstName: 'Integration',
|
||||||
|
lastName: 'Test',
|
||||||
|
email: 'srintegrationtest@test.com'
|
||||||
|
},
|
||||||
|
processDefinitionName: 'HROnboarding',
|
||||||
|
processDefinitionDescription: 'HR Onboarding Workflow',
|
||||||
|
processDefinitionKey: 'fakeProcessDefinitionKey1',
|
||||||
|
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
||||||
|
processDefinitionVersion: 60,
|
||||||
|
processDefinitionDeploymentId: '338695',
|
||||||
|
graphicalNotationDefined: true,
|
||||||
|
startFormDefined: false,
|
||||||
|
suspended: false,
|
||||||
|
variables: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '340063',
|
||||||
|
name: 'Mary Franklin AMERICAS Onboarding',
|
||||||
|
businessKey: null,
|
||||||
|
processDefinitionId: 'HROnboarding:60:338704',
|
||||||
|
tenantId: 'tenant_1',
|
||||||
|
started: '2017-10-09T12:18:07.484+0000',
|
||||||
|
ended: null,
|
||||||
|
startedBy: {
|
||||||
|
id: 4004,
|
||||||
|
firstName: 'Integration',
|
||||||
|
lastName: 'Test',
|
||||||
|
email: 'srintegrationtest@test.com'
|
||||||
|
},
|
||||||
|
processDefinitionName: 'HROnboarding',
|
||||||
|
processDefinitionDescription: 'HR Onboarding Workflow',
|
||||||
|
processDefinitionKey: 'HROnboarding',
|
||||||
|
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
||||||
|
processDefinitionVersion: 60,
|
||||||
|
processDefinitionDeploymentId: '338695',
|
||||||
|
graphicalNotationDefined: true,
|
||||||
|
startFormDefined: false,
|
||||||
|
suspended: false,
|
||||||
|
variables: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '337604',
|
||||||
|
name: 'John Jacobs AMERICAS Onboarding',
|
||||||
|
businessKey: null,
|
||||||
|
processDefinitionId: 'HROnboarding:49:303243',
|
||||||
|
tenantId: 'tenant_1',
|
||||||
|
started: '2017-09-25T10:02:23.522+0000',
|
||||||
|
ended: null,
|
||||||
|
startedBy: {
|
||||||
|
id: 4004,
|
||||||
|
firstName: 'Integration',
|
||||||
|
lastName: 'Test',
|
||||||
|
email: 'srintegrationtest@test.com'
|
||||||
|
},
|
||||||
|
processDefinitionName: 'HROnboarding',
|
||||||
|
processDefinitionDescription: 'HR Onboarding Workflow',
|
||||||
|
processDefinitionKey: 'fakeProcessDefinitionKey2',
|
||||||
|
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
||||||
|
processDefinitionVersion: 49,
|
||||||
|
processDefinitionDeploymentId: '303234',
|
||||||
|
graphicalNotationDefined: true,
|
||||||
|
startFormDefined: false,
|
||||||
|
suspended: false,
|
||||||
|
variables: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel } from 'ng2-activiti-tasklist';
|
import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel } from 'ng2-activiti-tasklist';
|
||||||
|
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
||||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
||||||
import { LightUserRepresentation } from 'ng2-alfresco-core';
|
|
||||||
|
|
||||||
export let fakeFilters = {
|
export let fakeFilters = {
|
||||||
size: 1, total: 1, start: 0,
|
size: 1, total: 1, start: 0,
|
||||||
|
@ -187,22 +187,6 @@ describe('ProcessInstanceListComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the process instances list filtered by processDefinitionKey', (done) => {
|
|
||||||
let key = 'fakeprocess';
|
|
||||||
component.appId = '1';
|
|
||||||
component.state = 'open';
|
|
||||||
component.processDefinitionKey = key;
|
|
||||||
component.onSuccess.subscribe((res) => {
|
|
||||||
let lastCall = getProcessInstancesSpy.calls.mostRecent();
|
|
||||||
expect(lastCall).toBeDefined();
|
|
||||||
let lastCallArgs = lastCall.args;
|
|
||||||
expect(lastCallArgs[0]).toBeDefined();
|
|
||||||
expect(lastCallArgs[0].processDefinitionKey).toEqual(key);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return a default name if no name is specified on the process', (done) => {
|
it('should return a default name if no name is specified on the process', (done) => {
|
||||||
getProcessInstancesSpy = getProcessInstancesSpy.and.returnValue(Observable.of(fakeProcessInstancesWithNoName));
|
getProcessInstancesSpy = getProcessInstancesSpy.and.returnValue(Observable.of(fakeProcessInstancesWithNoName));
|
||||||
component.appId = '1';
|
component.appId = '1';
|
||||||
|
@ -138,7 +138,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
|
|
||||||
private load(requestNode: ProcessFilterRequestRepresentation) {
|
private load(requestNode: ProcessFilterRequestRepresentation) {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.processService.getProcessInstances(requestNode)
|
this.processService.getProcessInstances(requestNode, this.processDefinitionKey)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
let instancesRow = this.createDataRow(response);
|
let instancesRow = this.createDataRow(response);
|
||||||
@ -281,7 +281,6 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
private createRequestNode() {
|
private createRequestNode() {
|
||||||
let requestNode = {
|
let requestNode = {
|
||||||
appDefinitionId: this.appId,
|
appDefinitionId: this.appId,
|
||||||
processDefinitionKey: this.processDefinitionKey,
|
|
||||||
state: this.state,
|
state: this.state,
|
||||||
sort: this.sort
|
sort: this.sort
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
export class ProcessFilterRequestRepresentation {
|
export class ProcessFilterRequestRepresentation {
|
||||||
processDefinitionId: string;
|
processDefinitionId: string;
|
||||||
processDefinitionKey: string;
|
|
||||||
appDefinitionId: string;
|
appDefinitionId: string;
|
||||||
state: string;
|
state: string;
|
||||||
sort: string;
|
sort: string;
|
||||||
@ -26,7 +25,6 @@ export class ProcessFilterRequestRepresentation {
|
|||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
||||||
this.processDefinitionKey = obj && obj.processDefinitionKey || null;
|
|
||||||
this.appDefinitionId = obj && obj.appDefinitionId || null;
|
this.appDefinitionId = obj && obj.appDefinitionId || null;
|
||||||
this.state = obj && obj.state || null;
|
this.state = obj && obj.state || null;
|
||||||
this.sort = obj && obj.sort || null;
|
this.sort = obj && obj.sort || null;
|
||||||
|
@ -19,7 +19,7 @@ import { TestBed } from '@angular/core/testing';
|
|||||||
import { async } from '@angular/core/testing';
|
import { async } from '@angular/core/testing';
|
||||||
import { AlfrescoApi } from 'alfresco-js-api';
|
import { AlfrescoApi } from 'alfresco-js-api';
|
||||||
import { AlfrescoApiService, CoreModule } from 'ng2-alfresco-core';
|
import { AlfrescoApiService, CoreModule } from 'ng2-alfresco-core';
|
||||||
import { exampleProcess } from '../assets/process.model.mock';
|
import { exampleProcess, fakeProcessInstances } from '../assets/process.model.mock';
|
||||||
import {
|
import {
|
||||||
fakeApp1,
|
fakeApp1,
|
||||||
fakeApp2,
|
fakeApp2,
|
||||||
@ -87,6 +87,18 @@ describe('ProcessService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should filter by processDefinitionKey', async(() => {
|
||||||
|
getProcessInstances = getProcessInstances.and.returnValue(Promise.resolve(fakeProcessInstances));
|
||||||
|
|
||||||
|
service.getProcessInstances(filter, 'fakeProcessDefinitionKey1').subscribe((instances) => {
|
||||||
|
expect(instances.length).toBe(1);
|
||||||
|
let instance = instances[0];
|
||||||
|
expect(instance.id).toBe('340124');
|
||||||
|
expect(instance.name).toBe('James Franklin EMEA Onboarding');
|
||||||
|
expect(instance.started).toBe('2017-10-09T12:19:44.560+0000');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should call service to fetch process instances', () => {
|
it('should call service to fetch process instances', () => {
|
||||||
service.getProcessInstances(filter);
|
service.getProcessInstances(filter);
|
||||||
expect(getProcessInstances).toHaveBeenCalled();
|
expect(getProcessInstances).toHaveBeenCalled();
|
||||||
|
@ -39,11 +39,11 @@ export class ProcessService extends TaskListService {
|
|||||||
super(alfrescoApiService, processLogService);
|
super(alfrescoApiService, processLogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getProcessInstances(requestNode: ProcessFilterRequestRepresentation): Observable<ProcessInstance[]> {
|
getProcessInstances(requestNode: ProcessFilterRequestRepresentation, processDefinitionKey?: string): Observable<ProcessInstance[]> {
|
||||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
||||||
.map((res: any) => {
|
.map((res: any) => {
|
||||||
if (requestNode.processDefinitionKey) {
|
if (processDefinitionKey) {
|
||||||
return res.data.filter(process => process.processDefinitionKey === requestNode.processDefinitionKey);
|
return res.data.filter(process => process.processDefinitionKey === processDefinitionKey);
|
||||||
} else {
|
} else {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user