Skip to content

Commit 3bcaeef

Browse files
authored
AAE-27327 New process search API (#10365)
* AAE-27327 New process search API * fix lint issue
1 parent f07636e commit 3bcaeef

15 files changed

+1541
-803
lines changed

docs/process-services-cloud/components/process-list-cloud.component.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ when the process list is empty:
8080
| stickyHeader | `boolean` | false | Toggles the sticky header mode. |
8181
| suspendedFrom | `string` | "" | Filter the processes. Display only process with suspendedFrom equal to the supplied date. |
8282
| suspendedTo | `string` | "" | Filter the processes. Display only process with suspendedTo equal to the supplied date. |
83+
| names | `string[]` | [] | Filter the processes. Display only processes with names matching any of the supplied strings. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. |
84+
initiators | `string[]` | [] | Filter the processes. Display only processes started by any of the users whose usernames are present in the array. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. |
85+
| appVersions | `string[]` | [] | Filter the processes. Display only processes present in any of the specified app versions. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. |
86+
| statuses | `string[]` | [] | Filter the processes. Display only processes with provided statuses. This input will be used only if `PROCESS_SEARCH_API_METHOD_TOKEN` is provided with `POST` value. |
8387

8488
### Events
8589

lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts

Lines changed: 474 additions & 290 deletions
Large diffs are not rendered by default.

lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { AppConfigService, TranslationService } from '@alfresco/adf-core';
2323
import { FilterParamsModel } from '../../../task/task-filters/models/filter-cloud.model';
2424
import { debounceTime, takeUntil, tap } from 'rxjs/operators';
2525
import { ProcessListCloudService } from '../../../process/process-list/services/process-list-cloud.service';
26+
import { PROCESS_SEARCH_API_METHOD_TOKEN } from '../../../services/cloud-token.service';
27+
import { ProcessFilterCloudAdapter } from '../../process-list/models/process-cloud-query-request.model';
2628

2729
@Component({
2830
selector: 'adf-cloud-process-filters',
@@ -77,6 +79,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
7779
private readonly translationService = inject(TranslationService);
7880
private readonly appConfigService = inject(AppConfigService);
7981
private readonly processListCloudService = inject(ProcessListCloudService);
82+
private readonly searchMethod = inject<'GET' | 'POST'>(PROCESS_SEARCH_API_METHOD_TOKEN, { optional: true });
8083

8184
ngOnInit() {
8285
this.enableNotifications = this.appConfigService.get('notifications', true);
@@ -272,8 +275,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
272275
* @param filter filter
273276
*/
274277
updateFilterCounter(filter: ProcessFilterCloudModel): void {
275-
this.processListCloudService
276-
.getProcessCounter(filter.appName, filter.status)
278+
this.fetchProcessFilterCounter(filter)
277279
.pipe(
278280
tap((filterCounter) => {
279281
this.checkIfFilterValuesHasBeenUpdated(filter.key, filterCounter);
@@ -312,4 +314,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
312314
this.updatedFiltersSet.delete(filterKey);
313315
});
314316
}
317+
318+
private fetchProcessFilterCounter(filter: ProcessFilterCloudModel): Observable<number> {
319+
return this.searchMethod === 'POST'
320+
? this.processListCloudService.getProcessListCounter(new ProcessFilterCloudAdapter(filter))
321+
: this.processListCloudService.getProcessCounter(filter.appName, filter.status)
322+
}
315323
}

lib/process-services-cloud/src/lib/process/process-filters/mock/process-filters-cloud.mock.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,23 @@ export const fakeProcessCloudFilters = [
5454

5555
export const mockProcessFilters: any[] = [
5656
{
57+
appName: 'mock-app-name',
5758
name: 'FakeAllProcesses',
5859
key: 'FakeAllProcesses',
5960
icon: 'adjust',
6061
id: '10',
6162
status: ''
6263
},
6364
{
65+
appName: 'mock-app-name',
6466
name: 'FakeRunningProcesses',
6567
key: 'FakeRunningProcesses',
6668
icon: 'inbox',
6769
id: '11',
6870
status: 'RUNNING'
6971
},
7072
{
73+
appName: 'mock-app-name',
7174
name: 'FakeCompletedProcesses',
7275
key: 'completed-processes',
7376
icon: 'done',

lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export class ProcessFilterCloudModel {
4848
completedDate: Date;
4949
environmentId?: string;
5050

51+
processDefinitionNames: string[] | null;
52+
initiators: string[] | null;
53+
appVersions: string[] | null;
54+
statuses: string[] | null;
55+
5156
private dateRangeFilterService = new DateRangeFilterService();
5257
private _completedFrom: string;
5358
private _completedTo: string;
@@ -94,6 +99,11 @@ export class ProcessFilterCloudModel {
9499
this.completedDate = obj.completedDate || null;
95100
this._suspendedFrom = obj._suspendedFrom || null;
96101
this._suspendedTo = obj._suspendedTo || null;
102+
103+
this.processDefinitionNames = obj.processDefinitionNames || null;
104+
this.initiators = obj.initiators || null;
105+
this.appVersions = obj.appVersions || null;
106+
this.statuses = obj.statuses || null;
97107
}
98108
}
99109

lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,19 @@ describe('ProcessFilterCloudService', () => {
8686
expect(res[0].id).toBe('1');
8787
expect(res[0].name).toBe('MOCK_PROCESS_NAME_1');
8888
expect(res[0].status).toBe('MOCK_ALL');
89+
expect(res[0].statuses).toContain('MOCK_ALL');
8990

9091
expect(res[1].appName).toBe('mock-appName');
9192
expect(res[1].id).toBe('2');
9293
expect(res[1].name).toBe('MOCK_PROCESS_NAME_2');
9394
expect(res[1].status).toBe('MOCK-RUNNING');
95+
expect(res[1].statuses).toContain('MOCK-RUNNING');
9496

9597
expect(res[2].appName).toBe('mock-appName');
9698
expect(res[2].id).toBe('3');
9799
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
98100
expect(res[2].status).toBe('MOCK-COMPLETED');
101+
expect(res[2].statuses).toContain('MOCK-COMPLETED');
99102

100103
expect(createPreferenceSpy).toHaveBeenCalled();
101104
done();
@@ -112,16 +115,19 @@ describe('ProcessFilterCloudService', () => {
112115
expect(res[0].id).toBe('1');
113116
expect(res[0].name).toBe('MOCK_PROCESS_NAME_1');
114117
expect(res[0].status).toBe('MOCK_ALL');
118+
expect(res[0].statuses).toContain('MOCK_ALL');
115119

116120
expect(res[1].appName).toBe('mock-appName');
117121
expect(res[1].id).toBe('2');
118122
expect(res[1].name).toBe('MOCK_PROCESS_NAME_2');
119123
expect(res[1].status).toBe('MOCK-RUNNING');
124+
expect(res[1].statuses).toContain('MOCK-RUNNING');
120125

121126
expect(res[2].appName).toBe('mock-appName');
122127
expect(res[2].id).toBe('3');
123128
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
124129
expect(res[2].status).toBe('MOCK-COMPLETED');
130+
expect(res[2].statuses).toContain('MOCK-COMPLETED');
125131

126132
expect(getPreferencesSpy).toHaveBeenCalled();
127133
done();
@@ -140,16 +146,19 @@ describe('ProcessFilterCloudService', () => {
140146
expect(res[0].id).toBe('1');
141147
expect(res[0].name).toBe('MOCK_PROCESS_NAME_1');
142148
expect(res[0].status).toBe('MOCK_ALL');
149+
expect(res[0].statuses).toContain('MOCK_ALL');
143150

144151
expect(res[1].appName).toBe('mock-appName');
145152
expect(res[1].id).toBe('2');
146153
expect(res[1].name).toBe('MOCK_PROCESS_NAME_2');
147154
expect(res[1].status).toBe('MOCK-RUNNING');
155+
expect(res[1].statuses).toContain('MOCK-RUNNING');
148156

149157
expect(res[2].appName).toBe('mock-appName');
150158
expect(res[2].id).toBe('3');
151159
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
152160
expect(res[2].status).toBe('MOCK-COMPLETED');
161+
expect(res[2].statuses).toContain('MOCK-COMPLETED');
153162

154163
expect(getPreferencesSpy).toHaveBeenCalled();
155164
expect(createPreferenceSpy).toHaveBeenCalled();

lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ export class ProcessFilterCloudService {
131131
} else {
132132
return of(this.findFiltersByKeyInPreferences(preferences, key));
133133
}
134-
})
134+
}),
135+
switchMap((filters) => this.handleCreateFilterBackwardsCompatibility(appName, key, filters))
135136
)
136137
.subscribe((filters) => {
137138
this.addFiltersToStream(filters);
@@ -414,4 +415,39 @@ export class ProcessFilterCloudService {
414415
refreshFilter(filterKey: string): void {
415416
this.filterKeyToBeRefreshedSource.next(filterKey);
416417
}
418+
419+
/**
420+
* This method is run after retrieving the filter array from preferences.
421+
* It handles the backwards compatibility with the new API by looking for the new properties and their counterparts in each passed filter.
422+
* If the new property is not found, it is created and assigned the value constructed from the old property.
423+
* The filters are then updated in the preferences and returned.
424+
* Old properties are left untouched for purposes like feature toggling.
425+
*
426+
* @param appName Name of the target app.
427+
* @param key Key of the process filters.
428+
* @param filters Array of process filters to be checked for backward compatibility.
429+
* @returns Observable of process filters with updated properties.
430+
*/
431+
private handleCreateFilterBackwardsCompatibility(
432+
appName: string,
433+
key: string,
434+
filters: ProcessFilterCloudModel[]
435+
): Observable<ProcessFilterCloudModel[]> {
436+
filters.forEach((filter) => {
437+
if (filter.processDefinitionName && !filter.processDefinitionNames) {
438+
filter.processDefinitionNames = [filter.processDefinitionName];
439+
}
440+
if (filter.initiator && !filter.initiators) {
441+
filter.initiators = [filter.initiator];
442+
}
443+
if (filter.appVersion && !filter.appVersions) {
444+
filter.appVersions = [filter.appVersion.toString()];
445+
}
446+
if (filter.status && !filter.statuses) {
447+
filter.statuses = [filter.status];
448+
}
449+
});
450+
451+
return this.updateProcessFilters(appName, key, filters);
452+
}
417453
}

0 commit comments

Comments
 (0)