50 lines
2.4 KiB
TypeScript
50 lines
2.4 KiB
TypeScript
import {Injectable} from '@angular/core';
|
|
import {Jsonp, URLSearchParams,ResponseOptions} from '@angular/http';
|
|
import {Http, Response} from '@angular/http';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {Claim} from '../entities/claim';
|
|
|
|
@Injectable()
|
|
export class ContextsService {
|
|
// baseUrl='http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
|
baseUrl='http://scoobydoo.di.uoa.gr:8181/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
|
//'http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/communities';
|
|
//http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/communities/egi/categories
|
|
//http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/categories/egi::classification/concepts
|
|
constructor(private http: Http) {
|
|
|
|
}
|
|
|
|
public getCommunities():any {
|
|
let url = this.baseUrl + 'communities';
|
|
console.info('ContextsService: request communities '+url);
|
|
return this.http.get( url)
|
|
.map(request => <any> request.json().data)
|
|
.do(request => console.info("Get claims: offset = "))
|
|
.catch(this.handleError);
|
|
}
|
|
public getCategories(communityId :string):any {
|
|
console.info('ContextsService: request categories for community with id '+communityId);
|
|
let url= this.baseUrl + 'communities/' + communityId + '/categories';
|
|
return this.http.get( url)
|
|
.map(request => <any> request.json().data)
|
|
.do(request => console.info("Get claims: offset = " ))
|
|
.catch(this.handleError);
|
|
}
|
|
public getConcepts(categoryId :string, keyword: string):any {
|
|
console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword);
|
|
let url= this.baseUrl + 'categories/' + categoryId+ "/concepts";
|
|
return this.http.get( url)
|
|
.map(request => <any> request.json().data)
|
|
.do(request => console.info("Get claims: offset = " ))
|
|
.catch(this.handleError);
|
|
}
|
|
|
|
private handleError (error: Response) {
|
|
// in a real world app, we may send the error to some remote logging infrastructure
|
|
// instead of just logging it to the console
|
|
console.error(error);
|
|
return Observable.throw(error || 'Server error');
|
|
}
|
|
}
|