Project

General

Profile

« Previous | Next » 

Revision 61321

[Branch angular-11 | Library]:
1. dataProviderInfo.ts: Added field "fundedContent" and updated "aggregationStatus: {"fulltexts": string};".
2. searchResearchResults.service.ts: Added method "countCollectedResultsWithFundingInfo()" to get number of research outcomes related to any project and collected from specific datasoure.
3. dataProvider.service.ts: Updated methods "getDataproviderAggregationStatus()" and "parseDataproviderAggregationStatus()" to parse "fulltexts" (new GET API call used).
4. dataProvider.component.ts: Added method "countResultsWithFundingInfo()" and updated method "hasAggregationStatusInfo()".
5. dataProvider.component.html: Deleted info "Latest data aggregation" and show "dataProviderInfo.fundedContent" instead of "dataProviderInfo.aggregationStatus.fundedContent".

View differences:

modules/uoa-services-library/branches/angular-11/ng-openaire-library/src/app/services/searchResearchResults.service.ts
538 538
      return entityType;
539 539
    }
540 540
  }
541

  
542
  public countCollectedResultsWithFundingInfo(datasourceId: string) {
543
    let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("(oaftype=result and collectedfromdatasourceid exact \""+datasourceId+"\" and relprojectid=*)") + "&page=0&size=0&format=json";
544
    return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
545
      .pipe(map(res => res['meta']['total']));
546
  }
541 547
}
modules/uoa-services-library/branches/angular-11/ng-openaire-library/src/app/landingPages/dataProvider/dataProvider.component.html
121 121
                    <showPublisher [journal]="dataProviderInfo.journal" [properties]="properties"></showPublisher>
122 122
                  </ul>
123 123

  
124
                  <div *ngIf="hasAggregationStatusInfo"
124
                  <div *ngIf="hasAggregationStatusInfo || dataProviderInfo.fundedContent"
125 125
                       class="uk-margin-medium-bottom uk-animation-fade uk-animation-fast">
126
                      <span *ngIf="dataProviderInfo.aggregationStatus.fulltexts && dataProviderInfo.aggregationStatus.fulltexts != -1"
126
                      <span *ngIf="dataProviderInfo.aggregationStatus?.fulltexts && dataProviderInfo.aggregationStatus?.fulltexts != -1"
127 127
                            class="uk-margin-right">
128 128
                        <span class="uk-text-muted">Collected full-texts: </span>
129 129
                        {{dataProviderInfo.aggregationStatus.fulltexts | number}}
130 130
                      </span>
131
                    <span *ngIf="dataProviderInfo.aggregationStatus.fundedContent && dataProviderInfo.aggregationStatus.fundedContent != -1"
131
                    <span *ngIf="dataProviderInfo.fundedContent && dataProviderInfo.fundedContent > 0"
132 132
                          class="uk-display-inline-block">
133 133
                        <span class="uk-text-muted">Results with funding information: </span>
134
                      {{dataProviderInfo.aggregationStatus.fundedContent | number}}
134
                      {{dataProviderInfo.fundedContent | number}}
135 135
                      </span>
136
                    <span *ngIf="dataProviderInfo.aggregationStatus.lastUpdateDate"
137
                          class="uk-display-inline-block">
138
                        <span class="uk-text-muted">Latest data aggregation: </span>
139
                      {{dataProviderInfo.aggregationStatus.lastUpdateDate | date}}
140
                      </span>
136
<!--                    <span *ngIf="dataProviderInfo.aggregationStatus.lastUpdateDate"-->
137
<!--                          class="uk-display-inline-block">-->
138
<!--                        <span class="uk-text-muted">Latest data aggregation: </span>-->
139
<!--                      {{dataProviderInfo.aggregationStatus.lastUpdateDate | date}}-->
140
<!--                      </span>-->
141 141
                  </div>
142
                  <div *ngIf="!aggregationStatusIsInitialized"
142
                  <div *ngIf="!aggregationStatusIsInitialized || !dataProviderInfo.fundedContent"
143 143
                       class="uk-animation-fade uk-margin-top  uk-width-1-1" role="alert">
144 144
                    <span class="loading-gif  uk-align-center"></span>
145 145
                  </div>
modules/uoa-services-library/branches/angular-11/ng-openaire-library/src/app/landingPages/dataProvider/dataProvider.service.ts
36 36
        //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
37 37
        //let options = new RequestOptions({headers: headers});
38 38

  
39
      const options = {
40
        headers: new HttpHeaders({
41
          'Content-Type': 'application/json',
42
          'accept': 'application/json'})
43
      };
39
      // const options = {
40
      //   headers: new HttpHeaders({
41
      //     'Content-Type': 'application/json',
42
      //     'accept': 'application/json'})
43
      // };
44
      //
45
      // let page: number = 0;
46
      //   let size: number = 1;
47
      //   return this.http.post(properties.datasourcesAPI+page+"/"+size+"?requestSortBy=id&order=ASCENDING", JSON.stringify({ "id": original_id }), options)
48
      //       //.map(res => <any> res.json())
49
      //       .pipe(map(res => res['datasourceInfo']))
50
      //       .pipe(map(res => this.parseDataproviderAggregationStatus(res)));
44 51

  
45
      let page: number = 0;
46
        let size: number = 1;
47
        return this.http.post(properties.datasourcesAPI+page+"/"+size+"?requestSortBy=id&order=ASCENDING", JSON.stringify({ "id": original_id }), options)
48
            //.map(res => <any> res.json())
49
            .pipe(map(res => res['datasourceInfo']))
50
            .pipe(map(res => this.parseDataproviderAggregationStatus(res)));
52
      return this.http.get(properties.datasourcesAPI+original_id)
53
        .pipe(map(res => res['api']))
54
        .pipe(map(res => this.parseDataproviderAggregationStatus(res)));
51 55
    }
52 56

  
53 57
    private handleError (error: HttpErrorResponse) {
......
57 61
        return throwError(error  || 'Server error');
58 62
    }
59 63

  
60
    parseDataproviderAggregationStatus(data: any): any {
61
        var aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string} = null;
62
        if(data != null && data[0] != null) {
63
          aggregationStatus = {"fundedContent": "-1", "indexRecords": "-1", "fulltexts": "-1", "lastUpdateDate": null};
64
          aggregationStatus.fundedContent = data[0].fundedContent;
65
          aggregationStatus.indexRecords = data[0].indexRecords;
66
          aggregationStatus.fulltexts = data[0].fulltexts;
64
    parseDataproviderAggregationStatus(apis: any): any {
65
        // var aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string} = null;
66
        // if(data != null && data[0] != null) {
67
        //   aggregationStatus = {"fundedContent": "-1", "indexRecords": "-1", "fulltexts": "-1", "lastUpdateDate": null};
68
        //   aggregationStatus.fundedContent = data[0].fundedContent;
69
        //   aggregationStatus.indexRecords = data[0].indexRecords;
70
        //   aggregationStatus.fulltexts = data[0].fulltexts;
71
        //
72
        //   if(data[0].hasOwnProperty("aggregationHistory")) {
73
        //     let length = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"].length : 1;
74
        //
75
        //     for(let i=0; i<length; i++) {
76
        //       var aggregationHistory = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"][i] : data[0]["aggregationHistory"];
77
        //       if(aggregationHistory && aggregationHistory.indexedVersion == true) {
78
        //         aggregationStatus.lastUpdateDate = aggregationHistory.date;
79
        //         break;
80
        //       }
81
        //     }
82
        //   }
83
        // }
67 84

  
68
          if(data[0].hasOwnProperty("aggregationHistory")) {
69
            let length = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"].length : 1;
85
      var aggregationStatus: {"fulltexts": string} = null;
86
      if(apis != null) {
87
        aggregationStatus = {"fulltexts": "-1"};
70 88

  
71
            for(let i=0; i<length; i++) {
72
              var aggregationHistory = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"][i] : data[0]["aggregationHistory"];
73
              if(aggregationHistory && aggregationHistory.indexedVersion == true) {
74
                aggregationStatus.lastUpdateDate = aggregationHistory.date;
75
                break;
76
              }
77
            }
89
        let mostRecentDate = null;
90
        let length = Array.isArray(apis) ? apis.length : 1;
91

  
92
        for (let i = 0; i < length; i++) {
93
          let api = Array.isArray(apis) ? apis[i] : apis;
94
          if(api.compatibility == "files" && (mostRecentDate == null || mostRecentDate < api.lastDownloadDate)) {
95
            aggregationStatus.fulltexts = api.lastDownloadTotal;
96
            mostRecentDate = api.lastDownloadDate;
78 97
          }
79 98
        }
80
        return aggregationStatus;
99
      }
100

  
101
      return aggregationStatus;
81 102
    }
82 103

  
83 104
    parseDataProviderInfo (data: any):any {
modules/uoa-services-library/branches/angular-11/ng-openaire-library/src/app/landingPages/dataProvider/dataProvider.component.ts
229 229
          this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink +  this._router.url);
230 230
          if (typeof document !== 'undefined') {
231 231
            this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId);
232
            this.countResultsWithFundingInfo();
232 233
          } else {
233 234
            this.aggregationStatusIsInitialized = true;
234 235
          }
......
280 281
      }
281 282
    ));
282 283
  }
284

  
285
  private countResultsWithFundingInfo() {
286
    this.subscriptions.push(this._searchResearchResultsService.countCollectedResultsWithFundingInfo(this.datasourceId).subscribe(
287
      fundedContent => {
288
        this.dataProviderInfo.fundedContent = fundedContent;
289
        console.log(this.dataProviderInfo.fundedContent);
290
      },
291
      err => {
292
        this.handleError("Error getting results with funding information for datasource id: " + this.datasourceId, err);
293
      }
294
    ))
295
  }
283 296
  
284 297
  private updateDescription(description: string) {
285 298
    this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
......
607 620
  }
608 621
  
609 622
  public get hasAggregationStatusInfo(): boolean {
623
    // return (!!this.dataProviderInfo.aggregationStatus &&
624
    //   ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)
625
    //     || (!!this.dataProviderInfo.aggregationStatus.fundedContent && parseInt(this.dataProviderInfo.aggregationStatus.fundedContent) != -1)
626
    //     || !!this.dataProviderInfo.aggregationStatus.lastUpdateDate));
627

  
610 628
    return (!!this.dataProviderInfo.aggregationStatus &&
611
      ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)
612
        || (!!this.dataProviderInfo.aggregationStatus.fundedContent && parseInt(this.dataProviderInfo.aggregationStatus.fundedContent) != -1)
613
        || !!this.dataProviderInfo.aggregationStatus.lastUpdateDate));
629
      ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)));
614 630
  }
615
  
631

  
616 632
  public get hasJournalInfo(): boolean {
617 633
    return (!!this.dataProviderInfo.journal && (
618 634
      !!this.dataProviderInfo.journal['journal'] || !!this.dataProviderInfo.journal['issn'] ||
modules/uoa-services-library/branches/angular-11/ng-openaire-library/src/app/utils/entities/dataProviderInfo.ts
13 13
    description: string;
14 14
    subjects: string[];
15 15

  
16
  fundedContent: string; // search query
17

  
16 18
  //collected from datasource api
17
  aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string};
19
  // aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string};
20
  aggregationStatus: {"fulltexts": string};
18 21

  
19 22
    tabs: {"name": string, "content": string}[];
20 23
    tabs2: string[] =[];

Also available in: Unified diff