1 |
54479
|
myrto.kouk
|
/*
|
2 |
|
|
* Created by myrto on 1/24/2018
|
3 |
|
|
*/
|
4 |
|
|
|
5 |
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
6 |
|
|
import { Injectable } from '@angular/core';
|
7 |
|
|
import { environment } from '../../environments/environment';
|
8 |
|
|
import { Observable } from 'rxjs';
|
9 |
57586
|
andreas.ma
|
import {InterfaceInformation, JobForValidation, RuleSet, StoredJob} from '../domain/typeScriptClasses';
|
10 |
54479
|
myrto.kouk
|
|
11 |
|
|
const headerOptions = {
|
12 |
|
|
headers : new HttpHeaders().set('Content-Type', 'application/json')
|
13 |
|
|
.set('Accept', 'application/json'),
|
14 |
|
|
withCredentials: true
|
15 |
|
|
};
|
16 |
|
|
|
17 |
|
|
@Injectable ()
|
18 |
|
|
export class ValidatorService {
|
19 |
|
|
|
20 |
|
|
private apiUrl = environment.API_ENDPOINT + '/validator/';
|
21 |
|
|
|
22 |
|
|
constructor(private httpClient: HttpClient) { }
|
23 |
|
|
|
24 |
|
|
/* returns array of sets of rules according to mode (literature, data, cris) */
|
25 |
|
|
getRuleSets(mode: string): Observable<RuleSet[]> {
|
26 |
|
|
const url = `${this.apiUrl}getRuleSets/${mode}`;
|
27 |
|
|
console.log(`knocking on: ${url}`);
|
28 |
|
|
|
29 |
|
|
return this.httpClient.get<RuleSet[]>(url, headerOptions);
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
getSetsOfRepository(baseUrl: string): Observable<string[]> {
|
34 |
|
|
const url = `${this.apiUrl}getSetsOfRepository?url=${baseUrl}`;
|
35 |
|
|
console.log(`knocking on: ${url}`);
|
36 |
|
|
|
37 |
|
|
return this.httpClient.get<string[]>(url, headerOptions);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
57990
|
andreas.ma
|
getStoredJobsNew(): Observable<StoredJob[]> {
|
41 |
|
|
const url = `${this.apiUrl}`;
|
42 |
54479
|
myrto.kouk
|
console.log(`knocking on: ${url}`);
|
43 |
|
|
|
44 |
|
|
return this.httpClient.get<StoredJob[]>(url, headerOptions);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/* returns true if there is a repository containing the baseUrl */
|
48 |
|
|
identifyRepository(baseUrl: string): Observable<boolean> {
|
49 |
|
|
const url = `${this.apiUrl}identifyRepository?url=${baseUrl}`;
|
50 |
|
|
console.log(`knocking on: ${url}`);
|
51 |
|
|
|
52 |
|
|
return this.httpClient.get<boolean>(url, headerOptions);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
getInterfaceInformation(baseUrl: string): Observable<InterfaceInformation> {
|
56 |
|
|
const url = `${this.apiUrl}getInterfaceInformation?baseUrl=${encodeURIComponent(baseUrl)}`;
|
57 |
|
|
console.log(`knocking on: ${url}`);
|
58 |
|
|
|
59 |
|
|
return this.httpClient.get<InterfaceInformation>(url, headerOptions);
|
60 |
|
|
}
|
61 |
|
|
|
62 |
57990
|
andreas.ma
|
reSubmitJobForValidation(id: string) {
|
63 |
|
|
const url = `${this.apiUrl}reSubmitJobForValidation/${id}`;
|
64 |
54479
|
myrto.kouk
|
console.log(`knocking on: ${url}`);
|
65 |
|
|
const body = {};
|
66 |
|
|
|
67 |
|
|
return this.httpClient.post(url, body, {withCredentials: true, responseType: 'text'});
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
submitJobForValidation(job: JobForValidation): Observable<JobForValidation> {
|
71 |
|
|
const url = `${this.apiUrl}submitJobForValidation`;
|
72 |
|
|
console.log(`knocking on: ${url}`);
|
73 |
|
|
const body = JSON.stringify(job);
|
74 |
|
|
|
75 |
|
|
return this.httpClient.post<JobForValidation>(url, body, headerOptions);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
57586
|
andreas.ma
|
getValidationSummary(repoId: string): Observable<StoredJob[]> {
|
79 |
|
|
const url = `${this.apiUrl}validationSummary/${repoId}/?size=5`;
|
80 |
|
|
console.log(`knocking on: ${url}`);
|
81 |
|
|
|
82 |
|
|
return this.httpClient.get<StoredJob[]>(url, headerOptions);
|
83 |
|
|
}
|
84 |
54479
|
myrto.kouk
|
}
|