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:
parent
ff7fc02161
commit
5012261491
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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+'"';
|
||||
}
|
||||
|
|
|
@ -303,11 +303,7 @@ export class SearchDatasetsService {
|
|||
return results;
|
||||
}
|
||||
|
||||
numOfEntityDatasets(parameters: string):any {
|
||||
|
||||
//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";
|
||||
numOfDatasets(url: string):any {
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
|
@ -320,20 +316,24 @@ export class SearchDatasetsService {
|
|||
});
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,11 +173,7 @@ export class SearchOrganizationsService {
|
|||
return results;
|
||||
}
|
||||
|
||||
numOfEntityOrganizations(id: string, entity: string):any {
|
||||
|
||||
//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";
|
||||
numOfOrganizations(url: string): any {
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
|
@ -190,21 +186,22 @@ export class SearchOrganizationsService {
|
|||
});
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,11 +243,7 @@ export class SearchProjectsService {
|
|||
return results;
|
||||
}
|
||||
|
||||
numOfProjects(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()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
|
||||
numOfProjects(url: string):any {
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
|
@ -260,20 +256,23 @@ export class SearchProjectsService {
|
|||
});
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,11 +423,7 @@ export class SearchPublicationsService {
|
|||
return results;
|
||||
}
|
||||
|
||||
numOfEntityPublications(id: string, entity: string):any {
|
||||
|
||||
//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";
|
||||
numOfPublications(url: string): any {
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
|
@ -440,20 +436,21 @@ export class SearchPublicationsService {
|
|||
});
|
||||
}
|
||||
|
||||
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));
|
||||
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 {
|
||||
let url = OpenaireProperties.getSearchAPIURLLast()+"publications/count?format=json";
|
||||
if(params != "") {
|
||||
url += "&q=" + params;
|
||||
}
|
||||
return this.numOfPublications(url);
|
||||
}
|
||||
|
||||
private quote(word: any): string {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue