Revision 45689
Added by Argiro Kokogiannaki over 7 years ago
fetchDatasets.class.ts | ||
---|---|---|
1 | 1 |
import {SearchDatasetsService} from '../../services/searchDatasets.service'; |
2 |
import {SearchResult} from '../../utils/entities/searchResult'; |
|
3 |
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; |
|
4 |
import {SearchFields} from '../../utils/properties/searchFields'; |
|
5 |
import {SearchPageComponent } from '../../searchPages/searchUtils/searchPage.component'; |
|
2 |
import { ErrorCodes} from '../../utils/properties/openaireProperties'; |
|
6 | 3 |
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; |
7 | 4 |
import {DOI} from '../../utils/string-utils.class'; |
8 | 5 |
|
... | ... | |
34 | 31 |
} |
35 | 32 |
|
36 | 33 |
|
34 |
public getResultsByKeyword(keyword:string, page: number, size: number){ |
|
35 |
var parameters = ""; |
|
36 |
if(keyword.length > 0){ |
|
37 |
var DOIs:string[] = DOI.getDOIsFromString(keyword); |
|
38 |
var doisParams = ""; |
|
39 |
|
|
40 |
for(var i =0 ;i < DOIs.length; i++){ |
|
41 |
doisParams+=(doisParams.length > 0?" or ":"")+'((pidclassid exact doi) and (pid exact "'+ DOIs[i]+'"))'; |
|
42 |
} |
|
43 |
if(doisParams.length > 0){ |
|
44 |
parameters += "q=("+doisParams+")" |
|
45 |
}else{ |
|
46 |
parameters = "q="+'"' + keyword + '"'; |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
51 |
this.searchUtils.status = errorCodes.LOADING; |
|
52 |
|
|
53 |
this.subResults = this._searchDatasetsService.searchDatasets(parameters,null, page, size, []).subscribe( |
|
54 |
data => { |
|
55 |
this.searchUtils.totalResults = data[0]; |
|
56 |
console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); |
|
57 |
this.results = data[1]; |
|
58 |
|
|
59 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
60 |
this.searchUtils.status = errorCodes.DONE; |
|
61 |
if(this.searchUtils.totalResults == 0 ){ |
|
62 |
this.searchUtils.status = errorCodes.NONE; |
|
63 |
} |
|
64 |
}, |
|
65 |
err => { |
|
66 |
console.log(err); |
|
67 |
//TODO check erros (service not available, bad request) |
|
68 |
// if( ){ |
|
69 |
// this.searchUtils.status = ErrorCodes.ERROR; |
|
70 |
// } |
|
71 |
var errorCodes:ErrorCodes = new ErrorCodes(); |
|
72 |
this.searchUtils.status = errorCodes.ERROR; |
|
73 |
} |
|
74 |
); |
|
75 |
} |
|
76 |
|
|
77 |
|
|
37 | 78 |
public getResultsForEntity(entity:string, id:string, page: number, size: number){ |
38 | 79 |
var parameters = ""; |
39 | 80 |
|
Also available in: Unified diff
More changes for main search and simple search of component