Functions for count results of an entity better structured in search services

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47541 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2017-06-16 15:03:30 +00:00
parent ff7fc02161
commit 5012261491
10 changed files with 147 additions and 151 deletions

View File

@ -260,7 +260,7 @@ export class OrganizationComponent {
{
projects = data[1];
for(let index=0; index < projects.length; index++) {
this._searchPublicationsService.numOfEntityPublications(projects[index].id, "projects/").subscribe(
this._searchPublicationsService.numOfEntityPublications(projects[index].id, "project").subscribe(
data =>
{
// let index: number = this.organizationInfo.projects.get(funder).indexOf(project);

View File

@ -82,18 +82,20 @@ export class SearchDataprovidersComponent {
}
public getNumForEntity(entity: string, id:string) {
console.info("getNumForEntity : Dataproviders Component");
var parameters="";
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
if(entity == "organization") {
parameters = "organizations/"+id+"/datasources/count";
}
if(id != "" && entity != "") {
if(parameters != "") {
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
this._searchDataprovidersService.numOfEntityDataproviders(id, entity).subscribe(
data => {
this.searchUtils.totalResults = data;
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = errorCodes.NONE;
}
},
err => {
console.log(err);
@ -109,13 +111,18 @@ export class SearchDataprovidersComponent {
}
public getNumForSearch(keyword: string) {
var parameters="datasources/count";
if(keyword != "") {
parameters += "?q="+keyword;
}
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
this._searchDataprovidersService.numOfDataproviders(keyword).subscribe(
data => {
this.searchUtils.totalResults = data;
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = errorCodes.NONE;
}
},
err => {
console.log(err);

View File

@ -449,8 +449,8 @@ export class SearchDataprovidersService {
return results;
}
numOfDataproviders(params: string):any {
let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
numOfDataproviders(url: string):any {
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
@ -463,6 +463,25 @@ export class SearchDataprovidersService {
});
}
numOfEntityDataproviders(id: string, entity: string):any {
var parameters = "";
if(entity == "organization") {
parameters = "organizations/"+id+"/datasources/count";
}
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
return this.numOfDataproviders(url);
}
numOfSearchDataproviders(params: string):any {
let url: string = OpenaireProperties.getSearchAPIURLLast()+"datasources/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.numOfDataproviders(url);
}
private quote(word: any): string {
return '"'+word+'"';
}

View File

@ -303,37 +303,37 @@ export class SearchDatasetsService {
return results;
}
numOfEntityDatasets(parameters: string):any {
numOfDatasets(url: string):any {
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
}
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"/datasets/count"+"?format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
numOfEntityDatasets(id: string, entity: string):any {
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id+"/datasets/count";
} else if(entity == "person") {
parameters = "people/"+id+"/datasets/count";
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
return this.numOfDatasets(url);
}
numOfSearchDatasets(params: string):any {
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+"datasets/count?q=" + params + "&format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
let url = OpenaireProperties.getSearchAPIURLLast()+"datasets/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
return this.numOfDatasets(url);
}
}

View File

@ -173,38 +173,35 @@ export class SearchOrganizationsService {
return results;
}
numOfEntityOrganizations(id: string, entity: string):any {
numOfOrganizations(url: string): any {
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
}
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+entity+id+"/organizations/count"+ "?format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
numOfEntityOrganizations(id: string, entity: string):any {
// currently not used - if used fix entity comparison below
var parameters: string = "";
if(entity == "organization") {
parameters = "organizations/"+id+"/organizations/count";
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
return this.numOfOrganizations(url);
}
numOfSearchOrganizations(params: string):any {
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+"organizations/count?q=" + params + "&format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
let url = OpenaireProperties.getSearchAPIURLLast()+"organizations/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
return this.numOfOrganizations(url);
}
}

View File

@ -243,37 +243,36 @@ export class SearchProjectsService {
return results;
}
numOfProjects(params: string):any {
numOfProjects(url: string):any {
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
}
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
numOfEntityProjects(id: string, entity: string):any {
//let url = OpenaireProperties.getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
var parameters: string = "";
if(entity == "organization") {
parameters = "organizations/"+id+"/projects/count";
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+ "?format=json";
return this.numOfProjects(url);
}
numOfSearchProjects(params: string):any {
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+"projects/count?q=" + params + "&format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
let url = OpenaireProperties.getSearchAPIURLLast()+"projects/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
return this.numOfProjects(url);
}
}

View File

@ -423,37 +423,34 @@ export class SearchPublicationsService {
return results;
}
numOfEntityPublications(id: string, entity: string):any {
numOfPublications(url: string): any {
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
}
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+entity+id+"/publications/count"+ "?format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
numOfEntityPublications(id: string, entity: string):any {
var parameters: string = "";
if(entity == "project") {
parameters = "projects/"+id+"/publications/count";
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total)
.do(res => {
this._cache.set(key, res);
});
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
return this.numOfPublications(url);
}
numOfSearchPublications(params: string):any {
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+"publications/count?q="+ params +"&format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
let url = OpenaireProperties.getSearchAPIURLLast()+"publications/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res.total).do(res => {
this._cache.set(key, res);
});
return this.numOfPublications(url);
}
private quote(word: any): string {

View File

@ -64,18 +64,12 @@ export class FetchDataproviders {
}
public getNumForEntity(entity: string, id:string) {
var parameters="";
if(entity == "organization") {
parameters = "organizations/"+id+"/datasources/count";
}
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
if(parameters != "") {
if(id != "" && entity != "") {
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
this._searchDataprovidersService.numOfEntityDataproviders(id, entity).subscribe(
data => {
this.searchUtils.totalResults = data;
@ -101,11 +95,8 @@ export class FetchDataproviders {
public getNumForSearch(keyword: string) {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
var parameters="datasources/count";
if(keyword != "") {
parameters += "?q=" +keyword ;
}
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
this._searchDataprovidersService.numOfDataproviders(keyword).subscribe(
data => {
this.searchUtils.totalResults = data;
this.searchUtils.status = errorCodes.DONE;

View File

@ -78,17 +78,9 @@ public getNumForEntity(entity:string, id:string){
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
var parameters = "";
if(id != "" && entity != "") {
if(entity == "project") {
parameters = "projects/"+id;
} else if(entity == "person") {
parameters = "people/"+id;
}
if(parameters != "") {
this._searchDatasetsService.numOfEntityDatasets(parameters).subscribe(
this._searchDatasetsService.numOfEntityDatasets(id, entity).subscribe(
data => {
this.searchUtils.totalResults = data;

View File

@ -91,18 +91,12 @@ export class FetchProjects{
}
public getNumForEntity(entity: string, id:string) {
var parameters="";
if(entity == "organization") {
parameters = "organizations/"+id+"/projects/count";
}
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
if(parameters != "") {
if(id != "" && entity != "") {
this._searchProjectsService.numOfProjects(parameters).subscribe(
this._searchProjectsService.numOfEntityProjects(id, entity).subscribe(
data => {
this.searchUtils.totalResults = data;