diff --git a/claims/claim-utils/claimResultSearchForm.component.ts b/claims/claim-utils/claimResultSearchForm.component.ts index 6153999e..5f7a0273 100644 --- a/claims/claim-utils/claimResultSearchForm.component.ts +++ b/claims/claim-utils/claimResultSearchForm.component.ts @@ -180,14 +180,14 @@ export class ClaimResultSearchFormComponent { this.crossrefStatus = this.errorCodes.LOADING; // this.crossrefResultsNum = null; if (this.DOIs.length > 0) { - this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties.searchCrossrefAPIURL, true).subscribe( + this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; this.crossrefPage = page; this.crossrefResultsNum = data[0]; if (this.crossrefResultsNum == 0) { - this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe( + this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; @@ -217,7 +217,7 @@ export class ClaimResultSearchFormComponent { err => { ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + JSON.stringify(this.DOIs), err); - this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe( + this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.crossrefResults = data[1]; this.crossrefPage = page; @@ -237,7 +237,7 @@ export class ClaimResultSearchFormComponent { } else { - this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe( + this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; @@ -374,7 +374,7 @@ export class ClaimResultSearchFormComponent { private getOrcidAuthor(term: string, addId) { this.orcidResultsNum = null; //passing structures in order to fill them in service - this._searchOrcidService.searchOrcidAuthor(term.replace(/\s/g, ""), this.authorIds, + this._searchOrcidService.searchOrcidAuthor(StringUtils.URIEncode(term.replace(/\s/g, "")), this.authorIds, this.authors, this.properties, addId).subscribe( data => { if (data != null && data == true && addId) { @@ -404,7 +404,7 @@ export class ClaimResultSearchFormComponent { this.selectAuthorId = "0"; this.orcidStatus = this.errorCodes.LOADING; //passing structures in order to fill them in service - this._searchOrcidService.searchOrcidAuthors(term, this.properties).subscribe( + this._searchOrcidService.searchOrcidAuthors(StringUtils.URIEncode(term), this.properties).subscribe( data => { this.authorIds = data; if (data != null) { @@ -490,7 +490,7 @@ export class ClaimResultSearchFormComponent { private enhanceInfoFromDOI(entity: ClaimEntity) { if (entity.result.DOI != null) { - this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties.searchCrossrefAPIURL, true).subscribe( + this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties, true).subscribe( data => { if (data != null && data[0] > 0 && data[1]) { let crossrefResult: ClaimEntity = data[1][0]; @@ -661,7 +661,7 @@ export class ClaimResultSearchFormComponent { this.dataciteResultsNum = this.dataciteResults.length; this.dataciteStatus = this.errorCodes.DONE; if (this.dataciteResultsNum == 0) { - this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe( + this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.dataciteResults = data[1]; this.datacitePage = page; @@ -686,7 +686,7 @@ export class ClaimResultSearchFormComponent { } else { - this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe( + this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.dataciteResults = data[1]; this.datacitePage = page; diff --git a/claims/claim-utils/service/searchCrossref.service.ts b/claims/claim-utils/service/searchCrossref.service.ts index 84dacdf2..740cdf51 100644 --- a/claims/claim-utils/service/searchCrossref.service.ts +++ b/claims/claim-utils/service/searchCrossref.service.ts @@ -4,41 +4,42 @@ import {Response} from '@angular/http'; import {HttpClient} from '@angular/common/http'; import {ClaimEntity, ClaimResult} from '../claimHelper.class'; import {map} from "rxjs/operators"; +import {EnvProperties} from "../../../utils/properties/env-properties"; @Injectable() export class SearchCrossrefService { constructor( private http: HttpClient ) {} - searchCrossrefResults(term: string, size: number, page: number, apiUrl: string, parse: boolean = false): any { - let url = apiUrl + '?query=' + term + '&rows=' + size + '&offset=' + (size * (page - 1)); + searchCrossrefResults(term: string, size: number, page: number, properties: EnvProperties, parse: boolean = false): any { + let url = properties.searchCrossrefAPIURL + '?query=' + term + '&rows=' + size + '&offset=' + (size * (page - 1)); - return this.http.get(url) + return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) .pipe(map(request => request['message'])) .pipe(map(request => [request["total-results"], parse ? this.parse(request.items) : request])) //.catch(this.handleError); } - searchCrossrefByDOIs(DOIs: string[], apiUrl: string, parse: boolean = false): any { + searchCrossrefByDOIs(DOIs: string[], properties: EnvProperties, parse: boolean = false): any { var doisParams = ""; for (var i = 0; i < DOIs.length; i++) { doisParams += (doisParams.length > 0 ? "," : "") + 'doi:' + DOIs[i]; } - let url = apiUrl + '?filter=' + doisParams; + let url = properties.searchCrossrefAPIURL + '?filter=' + doisParams; return this.http.get(url) //.map(request => request.json().message) .pipe(map(request => request['message'])) .pipe(map(request => [request["total-results"], parse ? this.parse(request['items']) : request])) //.catch(this.handleError); } - searchCrossrefByMultipleDOIs(dois: string[], apiUrl: string, parse: boolean = false): any { - let url = apiUrl + '?filter=doi:'; + searchCrossrefByMultipleDOIs(dois: string[], properties: EnvProperties, parse: boolean = false): any { + let url = properties.searchCrossrefAPIURL + '?filter=doi:'; for (var i = 0; i < dois.length; i++) { url = url + (url.length == 0 ? '' : ',') + 'doi:' + dois[i]; } - url = apiUrl + '?filter=' + url; + url = properties.searchCrossrefAPIURL + '?filter=' + url; return this.http.get(url) //.map(request => request.json().message) .pipe(map(request => request['message'])) diff --git a/searchPages/find/searchAll.component.ts b/searchPages/find/searchAll.component.ts index 07927e5b..4f77edae 100644 --- a/searchPages/find/searchAll.component.ts +++ b/searchPages/find/searchAll.component.ts @@ -213,7 +213,7 @@ export class SearchAllComponent { this.sub = this.route.queryParams.subscribe(params => { this.parameters = Object.assign({}, params); this.keyword = (params['keyword']) ? params['keyword'] : (params["q"] ? params["q"] : (params["f0"] && params["f0"] == "q" && params["fv0"]?params["fv0"]:"")); - this.selectedFields[0].value = this.keyword; + this.selectedFields[0].value = StringUtils.URIDecode(this.keyword); this.quickFilter.selected = ((params['qf']== undefined || params["qf"] == "true") == true); if (params["type"] && params["type"].length > 0) { this.resultTypes['publication'] = (params["type"].split(",").indexOf("publications") != -1); diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 005a2b7d..dfaea455 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -680,7 +680,7 @@ export class NewSearchPageComponent { } else { params += this.createQuotedKeywordQuery(this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId,countParams,true); }*/ - params = NewSearchPageComponent.createKeywordQuery(this.entityType,this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId, countParams); + params += NewSearchPageComponent.createKeywordQuery(this.entityType,this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId, countParams); //TODO deposit case // console.log(this.usedBy) // console.log(this.keywordFields) @@ -797,7 +797,7 @@ export class NewSearchPageComponent { } private static getNoQuotedQueryPart(fieldId:string, value:string, isSearchAll:boolean){ if(isSearchAll){ - return value ; + return StringUtils.URIEncode(value); }else{ return fieldId+"="+ StringUtils.URIEncode(value); } diff --git a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts index 48edef86..970ff7c9 100644 --- a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts +++ b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts @@ -5,6 +5,7 @@ import {Observable, Subject} from 'rxjs'; import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; import {EntitiesSearchService} from './entitySearch.service'; import{EnvProperties} from '../properties/env-properties'; +import {StringUtils} from "../string-utils.class"; //Usage example @@ -129,7 +130,7 @@ export class EntitiesAutocompleteComponent { debounceTime(300), distinctUntilChanged(), switchMap((term: string) => { - var results = this._search.searchByType(term, this.entityType, this.properties); + var results = this._search.searchByType(StringUtils.URIEncode(term), this.entityType, this.properties); this.showLoading = false; this.results = results.length; return results; diff --git a/utils/staticAutoComplete/ISVocabularies.service.ts b/utils/staticAutoComplete/ISVocabularies.service.ts index 3c244739..6a631577 100644 --- a/utils/staticAutoComplete/ISVocabularies.service.ts +++ b/utils/staticAutoComplete/ISVocabularies.service.ts @@ -36,7 +36,7 @@ export class ISVocabulariesService { } else if (field == "type" && (entity == "software" || entity == "other")) { return of([]); - } else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other")) { + } else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other" || entity == "result")) { // file= "accessMode.json"; // return this.getVocabularyFromFile(file); vocabulary = "dnet:access_modes.json";