1 |
54479
|
myrto.kouk
|
/*
|
2 |
|
|
* Created by myrto on 12/05/2017
|
3 |
|
|
*/
|
4 |
|
|
|
5 |
56443
|
andreas.ma
|
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
6 |
54479
|
myrto.kouk
|
import { Injectable } from '@angular/core';
|
7 |
|
|
import { environment } from '../../environments/environment';
|
8 |
|
|
import {
|
9 |
|
|
AggregationDetails,
|
10 |
|
|
Country, MetricsInfo,
|
11 |
|
|
Repository,
|
12 |
|
|
RepositoryInterface,
|
13 |
56470
|
stefania.m
|
RepositorySnippet, RepositorySummaryInfo,
|
14 |
54479
|
myrto.kouk
|
Timezone,
|
15 |
|
|
Typology
|
16 |
|
|
} from '../domain/typeScriptClasses';
|
17 |
|
|
import { Observable, of } from 'rxjs';
|
18 |
|
|
import { timezones } from '../domain/timezones';
|
19 |
|
|
import { typologies } from '../domain/typologies';
|
20 |
56580
|
andreas.ma
|
import {URLParameter} from '../domain/url-parameter';
|
21 |
54479
|
myrto.kouk
|
|
22 |
|
|
const headerOptions = {
|
23 |
|
|
headers : new HttpHeaders().set('Content-Type', 'application/json')
|
24 |
56436
|
andreas.ma
|
.set('Accept', 'application/json'),
|
25 |
54479
|
myrto.kouk
|
withCredentials: true
|
26 |
|
|
};
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
@Injectable ()
|
30 |
|
|
export class RepositoryService {
|
31 |
|
|
private apiUrl = environment.API_ENDPOINT + '/repository/';
|
32 |
56470
|
stefania.m
|
private dashboardAPIUrl = environment.API_ENDPOINT + '/dashboard/';
|
33 |
54479
|
myrto.kouk
|
|
34 |
|
|
constructor(private httpClient: HttpClient) { }
|
35 |
|
|
|
36 |
|
|
addInterface(datatype: string, repoId: string, registeredBy: string, newInterface: RepositoryInterface): Observable<RepositoryInterface> {
|
37 |
|
|
const url = `${this.apiUrl}addInterface?datatype=${datatype}&repoId=${repoId}®isteredBy=${registeredBy}`;
|
38 |
|
|
console.log(`knocking on: ${url}`);
|
39 |
|
|
console.log(`sending ${JSON.stringify(newInterface)}`);
|
40 |
|
|
return this.httpClient.post<RepositoryInterface>(url, newInterface, headerOptions);
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
updateInterface(repoId: string, registeredBy: string, interfaceInfo: RepositoryInterface): Observable<RepositoryInterface> {
|
44 |
|
|
const url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}®isteredBy=${registeredBy}`;
|
45 |
|
|
console.log(`knocking on: ${url}`);
|
46 |
|
|
console.log(`sending ${JSON.stringify(interfaceInfo)}`);
|
47 |
|
|
return this.httpClient.post<RepositoryInterface>(url, interfaceInfo, headerOptions);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
deleteInterface(id: string, registeredBy: string) {
|
51 |
|
|
const url = `${this.apiUrl}deleteInterface/?id=${id}®isteredBy=${registeredBy}`;
|
52 |
|
|
console.log(`knocking on: ${url}`);
|
53 |
|
|
|
54 |
|
|
return this.httpClient.delete(url, {withCredentials: true, responseType: 'text'});
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
addRepository(datatype: string, newRepository: Repository): Observable<Repository> {
|
58 |
|
|
const url = `${this.apiUrl}addRepository?datatype=${datatype}`;
|
59 |
|
|
console.log(`knocking on: ${url}`);
|
60 |
|
|
console.log(`sending ${JSON.stringify(newRepository)}`);
|
61 |
|
|
return this.httpClient.post<Repository>(url, newRepository, headerOptions);
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
updateRepository(repoInfo: Repository): Observable<Repository> {
|
65 |
|
|
const url = `${this.apiUrl}updateRepository`;
|
66 |
|
|
console.log(`knocking on: ${url}`);
|
67 |
|
|
console.log(`sending ${JSON.stringify(repoInfo)}`);
|
68 |
|
|
return this.httpClient.post<Repository>(url, repoInfo, headerOptions);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
getRepositoriesOfCountry(country: string, mode: string): Observable<RepositorySnippet[]> {
|
72 |
|
|
const url = `${this.apiUrl}getRepositoriesByCountry/${country}/${mode}`;
|
73 |
|
|
console.log(`knocking on: ${url}`);
|
74 |
|
|
return this.httpClient.get<RepositorySnippet[]>(url, headerOptions);
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
getRepositoriesOfUser(userEmail: string): Observable<Repository[]> {
|
78 |
|
|
const url = `${this.apiUrl}getRepositoriesOfUser/${userEmail}/0/100`;
|
79 |
|
|
console.log(`knocking on: ${url}`);
|
80 |
|
|
return this.httpClient.get<Repository[]>(url, headerOptions);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
getRepositoryById(id: string): Observable<Repository> {
|
85 |
|
|
const url = `${this.apiUrl}getRepositoryById/${id}`;
|
86 |
|
|
console.log(`knocking on: ${url}`);
|
87 |
|
|
return this.httpClient.get<Repository>(url, headerOptions);
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
getRepositoryInterface(id: string): Observable<RepositoryInterface[]> {
|
91 |
|
|
const url = `${this.apiUrl}getRepositoryInterface/${id}`;
|
92 |
|
|
console.log(`knocking on: ${url}`);
|
93 |
|
|
return this.httpClient.get<RepositoryInterface[]>(url, headerOptions);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
getUrlsOfUserRepos(userEmail: string): Observable<string[]> {
|
98 |
|
|
const url = `${this.apiUrl}getUrlsOfUserRepos/${userEmail}/0/100/`;
|
99 |
|
|
console.log(`knocking on: ${url}`);
|
100 |
|
|
return this.httpClient.get<string[]>(url, headerOptions);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
getRepositoryAggregations(id: string): Observable<AggregationDetails[]> {
|
104 |
|
|
const url = `${this.apiUrl}getRepositoryAggregations/${id}`;
|
105 |
|
|
console.log(`knocking on: ${url}`);
|
106 |
|
|
return this.httpClient.get<AggregationDetails[]>(url, headerOptions);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
getRepositoryAggregationsByYear(id: string): Observable<Map<string, AggregationDetails[]>> {
|
110 |
|
|
const url = `${this.apiUrl}getRepositoryAggregationsByYear/${id}`;
|
111 |
|
|
console.log(`knocking on: ${url}`);
|
112 |
|
|
return this.httpClient.get<Map<string, AggregationDetails[]>>(url, headerOptions);
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
getTimezones(): Observable<Timezone[]> {
|
116 |
|
|
/* const url = `${this.apiUrl}getTimezones`;
|
117 |
|
|
console.log(`knocking on: ${url}`);
|
118 |
|
|
return this.httpClient.get<Timezone[]>(url, headerOptions);*/
|
119 |
|
|
return of(<Timezone[]>timezones);
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
getTypologies(): Observable<Typology[]> {
|
123 |
|
|
/* const url = `${this.apiUrl}getTypologies`;
|
124 |
|
|
console.log(`knocking on: ${url}`);
|
125 |
|
|
return this.httpClient.get<Typology[]>(url, headerOptions);*/
|
126 |
|
|
return of(<Typology[]>typologies);
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
getCountries(): Observable<Country[]> {
|
130 |
|
|
const url = `${this.apiUrl}getCountries`;
|
131 |
|
|
console.log(`knocking on: ${url}`);
|
132 |
|
|
return this.httpClient.get<Country[]>(url, headerOptions);
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
getCompatibilityClasses (mode: string): Observable<Map<string, string>> {
|
137 |
|
|
const url = `${this.apiUrl}getCompatibilityClasses/${mode}`;
|
138 |
|
|
console.log(`knocking on: ${url}`);
|
139 |
|
|
return this.httpClient.get<Map<string, string>>(url, headerOptions);
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
getDatasourceClasses(mode: string): Observable<Map<string, string>> {
|
143 |
|
|
const url = `${this.apiUrl}getDatasourceClasses/${mode}`;
|
144 |
|
|
console.log(`knocking on: ${url}`);
|
145 |
|
|
return this.httpClient.get<Map<string, string>>(url, headerOptions);
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
getMetricsInfoForRepository (repoId: string): Observable<MetricsInfo> {
|
150 |
|
|
const url = `${this.apiUrl}getMetricsInfoForRepository/${repoId}`;
|
151 |
|
|
console.log(`knocking on: ${url}`);
|
152 |
|
|
return this.httpClient.get<MetricsInfo>(url, headerOptions);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
getListLatestUpdate(mode: string): Observable<any> {
|
156 |
|
|
const url = `${this.apiUrl}getListLatestUpdate/${mode}`;
|
157 |
|
|
console.log(`knocking on: ${url}`);
|
158 |
|
|
return this.httpClient.get<any>(url, headerOptions);
|
159 |
|
|
}
|
160 |
|
|
|
161 |
56632
|
andreas.ma
|
searchRegisteredRepositories(page, size, urlParams: URLParameter[]) {
|
162 |
|
|
const url = `${this.apiUrl}searchRegisteredRepositories/${page}/${size}`;
|
163 |
56634
|
andreas.ma
|
console.log(`knocking on: ${url}`);
|
164 |
56443
|
andreas.ma
|
let params = new HttpParams();
|
165 |
56580
|
andreas.ma
|
for (const urlParameter of urlParams) {
|
166 |
|
|
for (const value of urlParameter.value) {
|
167 |
|
|
params = params.append(urlParameter.key, value);
|
168 |
|
|
}
|
169 |
56443
|
andreas.ma
|
}
|
170 |
|
|
|
171 |
|
|
return this.httpClient.get<RepositorySnippet[]>(url, {params, withCredentials: true});
|
172 |
56436
|
andreas.ma
|
}
|
173 |
56470
|
stefania.m
|
|
174 |
|
|
getRepositoriesSummaryInfo(userEmail: string): Observable<RepositorySummaryInfo[]> {
|
175 |
|
|
const url = `${this.dashboardAPIUrl}getRepositoriesSummary/${userEmail}/0/100`;
|
176 |
|
|
console.log(`knocking on: ${url}`);
|
177 |
|
|
return this.httpClient.get<RepositorySummaryInfo[]>(url, headerOptions);
|
178 |
|
|
}
|
179 |
54479
|
myrto.kouk
|
}
|