From 983e01f70c3fa8f14438f2c1df234479ea2b702c Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Thu, 19 Mar 2020 11:38:58 +0200 Subject: [PATCH] [ADF-5087] Document List - custom sources 'where' clause not passed (#5558) * pass document list where clause to custom sources * update docs --- .../services/custom-resources.service.md | 15 +++++--- .../services/custom-resources.service.ts | 34 ++++++++++++------- .../services/document-list.service.ts | 2 +- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/docs/content-services/services/custom-resources.service.md b/docs/content-services/services/custom-resources.service.md index 8d4a677d58..c51818df66 100644 --- a/docs/content-services/services/custom-resources.service.md +++ b/docs/content-services/services/custom-resources.service.md @@ -41,29 +41,34 @@ Manages Document List information that is specific to a user. Is the folder ID a "-my", "-root-", or "-shared-" alias? - _folderId:_ `string` - Folder ID name to check - **Returns** `boolean` - True if the ID is one of the supported sources, false otherwise -- **loadFavorites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>`
+- **loadFavorites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`, where? string): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>`
Gets favorite files for the current user. - _pagination:_ [`PaginationModel`](../../../lib/core/models/pagination.model.ts) - Specifies how to paginate the results - _includeFields:_ `string[]` - List of data field names to include in the results + - _where:_ (Optional) `string` - A string to restrict the returned objects by using a predicate - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>` - List of favorite files -- **loadFolderByNodeId**(nodeId: `string`, pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`): `any`
+- **loadFolderByNodeId**(nodeId: `string`, pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`, where?: string): `any`
Gets a folder's contents. - _nodeId:_ `string` - ID of the target folder node - _pagination:_ [`PaginationModel`](../../../lib/core/models/pagination.model.ts) - Specifies how to paginate the results - _includeFields:_ `string[]` - List of data field names to include in the results + - _where:_ (Optional) `string` - A string to restrict the returned objects by using a predicate - **Returns** `any` - List of items contained in the folder -- **loadMemberSites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SiteMemberPaging.md)`>`
+- **loadMemberSites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), where?: string): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SiteMemberPaging.md)`>`
Gets sites that the current user is a member of. - _pagination:_ [`PaginationModel`](../../../lib/core/models/pagination.model.ts) - Specifies how to paginate the results + - _where:_ (Optional) `string` - A string to restrict the returned objects by using a predicate - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SiteMemberPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SiteMemberPaging.md)`>` - List of sites -- **loadSharedLinks**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SharedLinkPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SharedLinkPaging.md)`>`
+- **loadSharedLinks**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`, where?: string): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SharedLinkPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SharedLinkPaging.md)`>`
Gets shared links for the current user. - _pagination:_ [`PaginationModel`](../../../lib/core/models/pagination.model.ts) - Specifies how to paginate the results - _includeFields:_ `string[]` - List of data field names to include in the results + - _where:_ (Optional)`string` - A string to restrict the returned objects by using a predicate - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SharedLinkPaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/SharedLinkPaging.md)`>` - List of shared links -- **loadSites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>`
+- **loadSites**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), where?: string): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>`
Gets all sites in the repository. - _pagination:_ [`PaginationModel`](../../../lib/core/models/pagination.model.ts) - Specifies how to paginate the results + - _where:_ (Optional)`string` - A string to restrict the returned objects by using a predicate - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/development/src/api/content-rest-api/docs/NodePaging.md)`>` - List of sites - **loadTrashcan**(pagination: [`PaginationModel`](../../../lib/core/models/pagination.model.ts), includeFields: `string[]` = `[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`DeletedNodesPaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/DeletedNodesPaging.md)`>`
Gets all items currently in the trash. diff --git a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts index ad9ae9c73e..95028836d6 100644 --- a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts +++ b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts @@ -132,15 +132,17 @@ export class CustomResourcesService { * Gets favorite files for the current user. * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results + * @param where A string to restrict the returned objects by using a predicate * @returns List of favorite files */ - loadFavorites(pagination: PaginationModel, includeFields: string[] = []): Observable { + loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable { const includeFieldsRequest = this.getIncludesFields(includeFields); + const defaultPredicate = '(EXISTS(target/file) OR EXISTS(target/folder))'; const options = { maxItems: pagination.maxItems, skipCount: pagination.skipCount, - where: '(EXISTS(target/file) OR EXISTS(target/folder))', + where: where ? `${where} AND ${defaultPredicate}` : defaultPredicate , include: includeFieldsRequest }; @@ -181,13 +183,15 @@ export class CustomResourcesService { /** * Gets sites that the current user is a member of. * @param pagination Specifies how to paginate the results + * @param where A string to restrict the returned objects by using a predicate * @returns List of sites */ - loadMemberSites(pagination: PaginationModel): Observable { + loadMemberSites(pagination: PaginationModel, where?: string): Observable { const options = { include: ['properties'], maxItems: pagination.maxItems, - skipCount: pagination.skipCount + skipCount: pagination.skipCount, + where }; return new Observable((observer) => { @@ -220,13 +224,15 @@ export class CustomResourcesService { /** * Gets all sites in the repository. * @param pagination Specifies how to paginate the results + * @param where A string to restrict the returned objects by using a predicate * @returns List of sites */ - loadSites(pagination: PaginationModel): Observable { + loadSites(pagination: PaginationModel, where?: string): Observable { const options = { include: ['properties', 'aspectNames'], maxItems: pagination.maxItems, - skipCount: pagination.skipCount + skipCount: pagination.skipCount, + where }; return new Observable((observer) => { @@ -272,15 +278,17 @@ export class CustomResourcesService { * Gets shared links for the current user. * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results + * @param where A string to restrict the returned objects by using a predicate * @returns List of shared links */ - loadSharedLinks(pagination: PaginationModel, includeFields: string[] = []): Observable { + loadSharedLinks(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable { const includeFieldsRequest = this.getIncludesFields(includeFields); const options = { include: includeFieldsRequest, maxItems: pagination.maxItems, - skipCount: pagination.skipCount + skipCount: pagination.skipCount, + where }; return from(this.apiService.sharedLinksApi.findSharedLinks(options)) @@ -326,17 +334,17 @@ export class CustomResourcesService { * @param includeFields List of data field names to include in the results * @returns List of items contained in the folder */ - loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[] = []): any { + loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[] = [], where?: string): any { if (nodeId === '-trashcan-') { return this.loadTrashcan(pagination, includeFields); } else if (nodeId === '-sharedlinks-') { - return this.loadSharedLinks(pagination, includeFields); + return this.loadSharedLinks(pagination, includeFields, where); } else if (nodeId === '-sites-') { - return this.loadSites(pagination); + return this.loadSites(pagination, where); } else if (nodeId === '-mysites-') { - return this.loadMemberSites(pagination); + return this.loadMemberSites(pagination, where); } else if (nodeId === '-favorites-') { - return this.loadFavorites(pagination, includeFields); + return this.loadFavorites(pagination, includeFields, where); } else if (nodeId === '-recent-') { return this.getRecentFiles('-me-', pagination); } diff --git a/lib/content-services/src/lib/document-list/services/document-list.service.ts b/lib/content-services/src/lib/document-list/services/document-list.service.ts index cc96ba0138..36d643ea73 100644 --- a/lib/content-services/src/lib/document-list/services/document-list.service.ts +++ b/lib/content-services/src/lib/document-list/services/document-list.service.ts @@ -171,7 +171,7 @@ export class DocumentListService implements DocumentListLoader { */ loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string): Observable { if (this.customResourcesService.isCustomSource(nodeId)) { - return this.customResourcesService.loadFolderByNodeId(nodeId, pagination, includeFields).pipe( + return this.customResourcesService.loadFolderByNodeId(nodeId, pagination, includeFields, where).pipe( map((result: any) => new DocumentLoaderNode(null, result)) ); } else {