[ADF-2150] improved queryBody mechanism (#2852)

* [ADF-2150] changed query body parameter to a function

* [ADF-2150] added an example page where to try change query body

* [ADF-2150] improved queryBody mechanism

* [ADF-2150] fixed content node test

* [ADF-2150] extended docs added another way to use the query node

* [ADF-2150] fixed test for search on content node

* [ADF-2150] added some improvements to service config

* [ADF-2150] changed the documentation accordingly

* [ADF-2150] added PR changes

* [ADF-2150] fixed jdoc

* [ADF-2150] added checkbox to switch from service approach to input object approach

* [ADF-2150] fixed build error on demo shell
This commit is contained in:
Vito
2018-01-23 11:12:52 +01:00
committed by Eugenio Romano
parent 8788eaeb80
commit a401ebd35d
22 changed files with 430 additions and 78 deletions

View File

@@ -21,15 +21,14 @@ import { Observable } from 'rxjs/Observable';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service';
import 'rxjs/add/observable/throw';
import { SearchConfigurationService } from './search-configuration.service';
/**
* Internal service used by Document List component.
*/
@Injectable()
export class SearchService {
constructor(public authService: AuthenticationService,
private apiService: AlfrescoApiService) {
private apiService: AlfrescoApiService,
private searchConfigurationService: SearchConfigurationService) {
}
getNodeQueryResults(term: string, options?: SearchOptions): Observable<NodePaging> {
@@ -38,8 +37,8 @@ export class SearchService {
.catch(err => this.handleError(err));
}
search(query: QueryBody): Observable<NodePaging> {
const searchQuery = Object.assign(query);
search(searchTerm: string, maxResults: string, skipCount: string): Observable<NodePaging> {
const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount));
const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);
return Observable
@@ -47,6 +46,14 @@ export class SearchService {
.catch(err => this.handleError(err));
}
searchByQueryBody(queryBody: QueryBody): Observable<NodePaging> {
const promise = this.apiService.getInstance().search.searchApi.search(queryBody);
return Observable
.fromPromise(promise)
.catch(err => this.handleError(err));
}
private handleError(error: any): Observable<any> {
return Observable.throw(error || 'Server error');
}