Project

General

Profile

« Previous | Next » 

Revision 58497

[Trunk | Library]:
1. entitiesAutoComplete.component.ts: [Bug fix] Add missing encoding in autocomplete term (problem when query uses cache).
2. newSearchPage.component.ts:
a. [Bug fix] Add missing keyword encoding for simple search form (problem when query uses cache).
b. [Bug fix] In advanced search, when "all fields" (field id="q") is added more than once in form, add both values (params "+=" and not "=" in "getSearchAPIQueryForAdvancedSearhField()" method).
3. searchAll.component.ts: Decode keyword parameter from url (to show it properly in search form).
4. searchAll.component.ts:
a. [Bug fix] Add missing encoding in search term, used by datacite, crossref and orcid search services (problem when query uses cache).
b. In methods of crossref service pass properties, instead of url - url will be built in service.
5. searchCrossref.service.ts:
a. In all methods, pass properties, instead of url.
b. Use cache when available.
6. ISVocabularies.service.ts: [Bug fix]: Return "accessMode.json" vocabulary when: entity == "result" (case added in if statement).

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/find/searchAll.component.ts
213 213
    this.sub = this.route.queryParams.subscribe(params => {
214 214
      this.parameters = Object.assign({}, params);
215 215
      this.keyword = (params['keyword']) ? params['keyword'] : (params["q"] ? params["q"] : (params["f0"] && params["f0"] == "q" && params["fv0"]?params["fv0"]:""));
216
      this.selectedFields[0].value = this.keyword;
216
      this.selectedFields[0].value = StringUtils.URIDecode(this.keyword);
217 217
      this.quickFilter.selected = ((params['qf']== undefined || params["qf"] == "true") == true);
218 218
      if (params["type"] && params["type"].length > 0) {
219 219
        this.resultTypes['publication'] = (params["type"].split(",").indexOf("publications") != -1);
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/newSearchPage.component.ts
680 680
            } else {
681 681
              params += this.createQuotedKeywordQuery(this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId,countParams,true);
682 682
            }*/
683
            params = NewSearchPageComponent.createKeywordQuery(this.entityType,this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId, countParams);
683
            params += NewSearchPageComponent.createKeywordQuery(this.entityType,this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId, countParams);
684 684
            //TODO deposit case
685 685
            // console.log(this.usedBy)
686 686
            // console.log(this.keywordFields)
......
797 797
  }
798 798
  private static getNoQuotedQueryPart(fieldId:string, value:string,  isSearchAll:boolean){
799 799
    if(isSearchAll){
800
      return  value ;
800
      return StringUtils.URIEncode(value);
801 801
    }else{
802 802
      return fieldId+"="+ StringUtils.URIEncode(value);
803 803
    }
modules/uoa-services-library/trunk/ng-openaire-library/src/app/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts
5 5
import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class';
6 6
import {EntitiesSearchService} from './entitySearch.service';
7 7
import{EnvProperties} from '../properties/env-properties';
8
import {StringUtils} from "../string-utils.class";
8 9

  
9 10

  
10 11
//Usage example
......
129 130
        debounceTime(300),
130 131
        distinctUntilChanged(),
131 132
        switchMap((term: string) => {
132
          var results = this._search.searchByType(term, this.entityType, this.properties);
133
          var results = this._search.searchByType(StringUtils.URIEncode(term), this.entityType, this.properties);
133 134
          this.showLoading = false;
134 135
          this.results = results.length;
135 136
          return   results;
modules/uoa-services-library/trunk/ng-openaire-library/src/app/utils/staticAutoComplete/ISVocabularies.service.ts
36 36
    } else if (field == "type" && (entity == "software" || entity == "other")) {
37 37
      return of([]);
38 38
      
39
    } else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other")) {
39
    } else if (field == "access" && (entity == "publication" || entity == "dataset" || entity == "software" || entity == "other" || entity == "result")) {
40 40
      // file= "accessMode.json";
41 41
      // return this.getVocabularyFromFile(file);
42 42
      vocabulary = "dnet:access_modes.json";
modules/uoa-services-library/trunk/ng-openaire-library/src/app/claims/claim-utils/claimResultSearchForm.component.ts
180 180
    this.crossrefStatus = this.errorCodes.LOADING;
181 181
    // this.crossrefResultsNum = null;
182 182
    if (this.DOIs.length > 0) {
183
      this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties.searchCrossrefAPIURL, true).subscribe(
183
      this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties, true).subscribe(
184 184
        data => {
185 185
          if (data != null) {
186 186
            this.crossrefResults = data[1];
187 187
            this.crossrefPage = page;
188 188
            this.crossrefResultsNum = data[0];
189 189
            if (this.crossrefResultsNum == 0) {
190
              this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe(
190
              this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
191 191
                data => {
192 192
                  if (data != null) {
193 193
                    this.crossrefResults = data[1];
......
217 217
        err => {
218 218
          ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + JSON.stringify(this.DOIs), err);
219 219

  
220
          this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe(
220
          this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
221 221
            data => {
222 222
              this.crossrefResults = data[1];
223 223
              this.crossrefPage = page;
......
237 237
    } else {
238 238

  
239 239

  
240
      this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL, true).subscribe(
240
      this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
241 241
        data => {
242 242
          if (data != null) {
243 243
            this.crossrefResults = data[1];
......
374 374
  private getOrcidAuthor(term: string, addId) {
375 375
    this.orcidResultsNum = null;
376 376
    //passing structures in order to fill them in service
377
    this._searchOrcidService.searchOrcidAuthor(term.replace(/\s/g, ""), this.authorIds,
377
    this._searchOrcidService.searchOrcidAuthor(StringUtils.URIEncode(term.replace(/\s/g, "")), this.authorIds,
378 378
      this.authors, this.properties, addId).subscribe(
379 379
      data => {
380 380
        if (data != null && data == true && addId) {
......
404 404
    this.selectAuthorId = "0";
405 405
    this.orcidStatus = this.errorCodes.LOADING;
406 406
    //passing structures in order to fill them in service
407
    this._searchOrcidService.searchOrcidAuthors(term, this.properties).subscribe(
407
    this._searchOrcidService.searchOrcidAuthors(StringUtils.URIEncode(term), this.properties).subscribe(
408 408
      data => {
409 409
        this.authorIds = data;
410 410
        if (data != null) {
......
490 490
  private enhanceInfoFromDOI(entity: ClaimEntity) {
491 491

  
492 492
    if (entity.result.DOI != null) {
493
      this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties.searchCrossrefAPIURL, true).subscribe(
493
      this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties, true).subscribe(
494 494
        data => {
495 495
          if (data != null && data[0] > 0 && data[1]) {
496 496
            let crossrefResult: ClaimEntity = data[1][0];
......
661 661
          this.dataciteResultsNum = this.dataciteResults.length;
662 662
          this.dataciteStatus = this.errorCodes.DONE;
663 663
          if (this.dataciteResultsNum == 0) {
664
            this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe(
664
            this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
665 665
              data => {
666 666
                this.dataciteResults = data[1];
667 667
                this.datacitePage = page;
......
686 686
    } else {
687 687

  
688 688

  
689
      this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe(
689
      this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
690 690
        data => {
691 691
          this.dataciteResults = data[1];
692 692
          this.datacitePage = page;
modules/uoa-services-library/trunk/ng-openaire-library/src/app/claims/claim-utils/service/searchCrossref.service.ts
4 4
import {HttpClient} from '@angular/common/http';
5 5
import {ClaimEntity, ClaimResult} from '../claimHelper.class';
6 6
import {map} from "rxjs/operators";
7
import {EnvProperties} from "../../../utils/properties/env-properties";
7 8

  
8 9
@Injectable()
9 10
export class SearchCrossrefService {
10 11
  constructor( private http: HttpClient ) {}
11 12

  
12 13

  
13
  searchCrossrefResults(term: string, size: number, page: number, apiUrl: string, parse: boolean = false): any {
14
    let url = apiUrl + '?query=' + term + '&rows=' + size + '&offset=' + (size * (page - 1));
14
  searchCrossrefResults(term: string, size: number, page: number, properties: EnvProperties, parse: boolean = false): any {
15
    let url = properties.searchCrossrefAPIURL + '?query=' + term + '&rows=' + size + '&offset=' + (size * (page - 1));
15 16

  
16
     return this.http.get(url)
17
     return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
17 18
                     .pipe(map(request => request['message']))
18 19
                     .pipe(map(request => [request["total-results"], parse ? this.parse(request.items) : request]))
19 20
                     //.catch(this.handleError);
20 21

  
21 22
  }
22 23

  
23
  searchCrossrefByDOIs(DOIs: string[], apiUrl: string, parse: boolean = false): any {
24
  searchCrossrefByDOIs(DOIs: string[], properties: EnvProperties, parse: boolean = false): any {
24 25

  
25 26
    var doisParams = "";
26 27
    for (var i = 0; i < DOIs.length; i++) {
27 28
      doisParams += (doisParams.length > 0 ? "," : "") + 'doi:' + DOIs[i];
28 29
    }
29
    let url = apiUrl + '?filter=' + doisParams;
30
    let url = properties.searchCrossrefAPIURL + '?filter=' + doisParams;
30 31
           return this.http.get(url)
31 32
                       //.map(request => <any> request.json().message)
32 33
                       .pipe(map(request => request['message']))
33 34
                       .pipe(map(request => [request["total-results"], parse ? this.parse(request['items']) : request]))
34 35
                       //.catch(this.handleError);
35 36
}
36
  searchCrossrefByMultipleDOIs(dois: string[], apiUrl: string, parse: boolean = false): any {
37
    let url = apiUrl + '?filter=doi:';
37
  searchCrossrefByMultipleDOIs(dois: string[], properties: EnvProperties, parse: boolean = false): any {
38
    let url = properties.searchCrossrefAPIURL + '?filter=doi:';
38 39
    for (var i = 0; i < dois.length; i++) {
39 40
      url = url + (url.length == 0 ? '' : ',') + 'doi:' + dois[i];
40 41
    }
41
    url = apiUrl + '?filter=' + url;
42
    url = properties.searchCrossrefAPIURL + '?filter=' + url;
42 43
         return this.http.get(url)
43 44
                         //.map(request => <any> request.json().message)
44 45
                         .pipe(map(request => request['message']))

Also available in: Unified diff