Project

General

Profile

1
import { HttpClient, HttpHeaders } from '@angular/common/http';
2
import { Injectable } from '@angular/core';
3
import { Observable } from 'rxjs';
4
import { OverviewData } from '../domain/overview-data';
5
import { environment } from '../../environments/environment';
6
import { RawData } from '../domain/raw-data';
7

    
8
const headerOptions = {
9
  headers : new HttpHeaders().set('Content-Type', 'application/json')
10
    .set('Accept', 'application/json'),
11
};
12

    
13
@Injectable ()
14
export class DataService {
15

    
16
  private _jsonURl = 'http://esperos.di.uoa.gr/oss.json';
17

    
18
  private apiURL = environment.API_ENDPOINT + 'raw?json=';
19

    
20
  constructor(private httpClient: HttpClient) {
21
  }
22

    
23
  public getOverviewMapData(): Observable<RawData> {
24
    const mapDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
25
    return this.httpClient.get<RawData>(this.apiURL + mapDataQuery, headerOptions);
26
  }
27

    
28
  public getCountryOverviewData(countryCode: string): Observable<RawData> {
29
    const countryOverviewDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.affiliated.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.deposited.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.affiliated.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.deposited.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies.country%22%2C%20%22parameters%22%3A%5B%22' + countryCode + '%22%5D%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
30
    return this.httpClient.get<RawData>(this.apiURL + countryOverviewDataQuery, headerOptions);
31
  }
32

    
33
  public getEuropeOverviewData(): Observable<RawData> {
34
    const overviewRawDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.oa_percentage%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.oa_percentage%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies.europe%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
35
    return this.httpClient.get<RawData>(this.apiURL + overviewRawDataQuery, headerOptions);
36
  }
37

    
38
  public getOverviewTableAbsoluteData(content: string): Observable<RawData> {
39
    let overviewTableAbsoluteDataQuery = '';
40
    if (content === 'affiliated') {
41
      overviewTableAbsoluteDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.software.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.other.affiliated%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
42
    } else if (content === 'affiliated_peer_reviewed') {
43
      overviewTableAbsoluteDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.affiliated.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.affiliated.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.software.affiliated.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.other.affiliated.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
44
    } else if (content === 'deposited') {
45
      overviewTableAbsoluteDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.software.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.other.deposited%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
46
    } else if (content === 'deposited_peer_reviewed') {
47
      overviewTableAbsoluteDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.deposited.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.deposited.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.software.deposited.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.other.deposited.peer_reviewed%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
48
    }
49
    return this.httpClient.get<RawData>(this.apiURL + overviewTableAbsoluteDataQuery, headerOptions);
50
  }
51

    
52
  public getOverviewTablePercentageData(content: string): Observable<RawData> {
53
    let overviewTablePercentageDataQuery = '';
54
    if (content === 'affiliated') {
55
      overviewTablePercentageDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.bycountry%22%2C%22parameters%22%3A%5B%22publication%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.bycountry%22%2C%22parameters%22%3A%5B%22dataset%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.bycountry%22%2C%22parameters%22%3A%5B%22software%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.bycountry%22%2C%22parameters%22%3A%5B%22other%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated.bycountry%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated.bycountry%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
56
    } else if (content === 'affiliated_peer_reviewed') {
57
      overviewTablePercentageDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.affiliated.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22publication%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.affiliated.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22dataset%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.affiliated.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22software%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.affiliated.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22other%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated.bycountry%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated.bycountry%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
58
    } else if (content === 'deposited') {
59
      overviewTablePercentageDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.bycountry%22%2C%22parameters%22%3A%5B%22publication%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.bycountry%22%2C%22parameters%22%3A%5B%22dataset%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.bycountry%22%2C%22parameters%22%3A%5B%22software%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.bycountry%22%2C%22parameters%22%3A%5B%22other%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated.bycountry%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated.bycountry%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
60
    } else if (content === 'deposited_peer_reviewed') {
61
      overviewTablePercentageDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22publication%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22dataset%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22software%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.peer_reviewed.bycountry%22%2C%22parameters%22%3A%5B%22other%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated.bycountry%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated.bycountry%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
62
    }
63
    return this.httpClient.get<RawData>(this.apiURL + overviewTablePercentageDataQuery, headerOptions);
64
  }
65

    
66
  public getEuropeOAPercentages(): Observable<RawData> {
67
    const europeOAPercentagesQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.publications.oa_percentage%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.datasets.oa_percentage%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.software.oa_percentage%22%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.other.oa_percentage%22%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
68
    return this.httpClient.get<RawData>(this.apiURL + europeOAPercentagesQuery, headerOptions);
69
  }
70

    
71
  public getCountryPageOverviewData(countryCode: string): Observable<RawData> {
72
    const countryPageOverviewDataQuery = '%7B%22series%22%3A%5B%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.country%22%2C%20%22parameters%22%3A%5B%22publication%22%2C%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.country%22%2C%20%22parameters%22%3A%5B%22publication%22%2C%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.country%22%2C%20%22parameters%22%3A%5B%22dataset%22%2C%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.results.oa_percentage.deposited.country%22%2C%20%22parameters%22%3A%5B%22dataset%22%2C%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.repositories.doar_re3data.validated.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.journals.doaj.validated.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.oa_policies.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.funder.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.funding_organizations.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%2C%7B%22query%22%3A%7B%22name%22%3A%22new.oso.ec_funded_organizations.country%22%2C%20%22parameters%22%3A%5B%22DE%22%5D%7D%7D%5D%2C%22verbose%22%3Atrue%7D';
73
    return this.httpClient.get<RawData>(this.apiURL + countryPageOverviewDataQuery, headerOptions);
74
  }
75

    
76

    
77

    
78

    
79

    
80
  public getOverviewData(): Observable<OverviewData> {
81
    return this.httpClient.get<OverviewData>(this._jsonURl, headerOptions);
82
  }
83

    
84
  public getCountryData(countryName: string) {
85
    return this.httpClient.get<OverviewData>(this._jsonURl, headerOptions);
86
  }
87
}
(2-2/3)