webin-xml-report.service.ts 2.09 KB
Newer Older
Rasko Leinonen's avatar
Rasko Leinonen committed
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright 2018 EMBL - European Bioinformatics Institute
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

12
import { Injectable } from '@angular/core';
13
import { HttpClient } from '@angular/common/http';
Rasko Leinonen's avatar
Rasko Leinonen committed
14
import { Observable } from 'rxjs';
15
import { environment } from '../environments/environment';
16
import { WebinXmlReportServiceInterface } from './webin-xml-report.service.interface';
17 18

@Injectable()
19
export class WebinXmlReportService implements WebinXmlReportServiceInterface {
20

Rajkumar-D's avatar
Rajkumar-D committed
21
  private _baseUrl = environment.webinRestUrl;
22 23 24

  constructor(private http: HttpClient) { }

25
  getStudyXml(id: string): Observable<string> {
26 27
    return this.getXml('studies', id);
  }
28
  getProjectXml(id: string): Observable<string> {
29 30
    return this.getXml('projects', id);
  }
31
  getSampleXml(id: string): Observable<string> {
32 33
    return this.getXml('samples', id);
  }
34
  getRunXml(id: string): Observable<string> {
35 36
    return this.getXml('runs', id);
  }
37
  getExperimentXml(id: string): Observable<string> {
38 39
    return this.getXml('experiments', id);
  }
40
  getAnalysisXml(id: string): Observable<string> {
41
    return this.getXml('analyses', id);
42
  }
43
  getDacXml(id: string): Observable<string> {
44 45
    return this.getXml('dacs', id);
  }
46
  getPolicyXml(id: string): Observable<string> {
Rajkumar-D's avatar
Rajkumar-D committed
47
    return this.getXml('policys', id);
48
  }
49
  getDatasetXml(id: string): Observable<string> {
50 51 52
    return this.getXml('datasets', id);
  }

53
  private getXml(xmlType: string, id: string): Observable<string> {
54
    const url: string = this._baseUrl + '/' + xmlType + '/' + id + '?format=xml';
55
    //console.log(url);
Rajkumar-D's avatar
Rajkumar-D committed
56
    return this.http.get(url, { responseType: 'text' });
57 58
  }
}