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];
|
projects = data[1];
|
||||||
for(let index=0; index < projects.length; index++) {
|
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 =>
|
data =>
|
||||||
{
|
{
|
||||||
// let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
|
// let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
|
||||||
|
|
|
@ -82,18 +82,20 @@ export class SearchDataprovidersComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumForEntity(entity: string, id:string) {
|
public getNumForEntity(entity: string, id:string) {
|
||||||
console.info("getNumForEntity : Dataproviders Component");
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
var parameters="";
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
if(entity == "organization") {
|
if(id != "" && entity != "") {
|
||||||
parameters = "organizations/"+id+"/datasources/count";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parameters != "") {
|
this._searchDataprovidersService.numOfEntityDataproviders(id, entity).subscribe(
|
||||||
|
|
||||||
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
|
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = 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 => {
|
err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -109,13 +111,18 @@ export class SearchDataprovidersComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumForSearch(keyword: string) {
|
public getNumForSearch(keyword: string) {
|
||||||
var parameters="datasources/count";
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
if(keyword != "") {
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
parameters += "?q="+keyword;
|
|
||||||
}
|
this._searchDataprovidersService.numOfDataproviders(keyword).subscribe(
|
||||||
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
|
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = 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 => {
|
err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
@ -449,8 +449,8 @@ export class SearchDataprovidersService {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfDataproviders(params: string):any {
|
numOfDataproviders(url: string):any {
|
||||||
let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
|
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(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 {
|
private quote(word: any): string {
|
||||||
return '"'+word+'"';
|
return '"'+word+'"';
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,11 +303,7 @@ export class SearchDatasetsService {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfEntityDatasets(parameters: string):any {
|
numOfDatasets(url: 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";
|
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(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 {
|
numOfSearchDatasets(params: string):any {
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+"datasets/count?format=json";
|
||||||
//OpenaireProperties.getSearchAPIURLLast()
|
if(params != "") {
|
||||||
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
|
url += "&q=" + params;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
return this.http.get(url)
|
return this.numOfDatasets(url);
|
||||||
.map(res => <any> res.json())
|
|
||||||
.map(res => res.total)
|
|
||||||
.do(res => {
|
|
||||||
this._cache.set(key, res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,11 +173,7 @@ export class SearchOrganizationsService {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfEntityOrganizations(id: string, entity: string):any {
|
numOfOrganizations(url: 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";
|
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(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 {
|
numOfSearchOrganizations(params: string):any {
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+"organizations/count?format=json";
|
||||||
//OpenaireProperties.getSearchAPIURLLast()
|
if(params != "") {
|
||||||
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
|
url += "&q=" + params;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
return this.http.get(url)
|
return this.numOfOrganizations(url);
|
||||||
.map(res => <any> res.json())
|
|
||||||
.map(res => res.total)
|
|
||||||
.do(res => {
|
|
||||||
this._cache.set(key, res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,11 +243,7 @@ export class SearchProjectsService {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfProjects(params: string):any {
|
numOfProjects(url: 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";
|
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(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 {
|
numOfSearchProjects(params: string):any {
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+"projects/count?format=json";
|
||||||
//OpenaireProperties.getSearchAPIURLLast()
|
if(params != "") {
|
||||||
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
|
url += "&q=" + params;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
return this.http.get(url)
|
return this.numOfProjects(url);
|
||||||
.map(res => <any> res.json())
|
|
||||||
.map(res => res.total)
|
|
||||||
.do(res => {
|
|
||||||
this._cache.set(key, res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,11 +423,7 @@ export class SearchPublicationsService {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfEntityPublications(id: string, entity: string):any {
|
numOfPublications(url: 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";
|
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(key));
|
return Observable.of(this._cache.get(key));
|
||||||
|
@ -440,20 +436,21 @@ export class SearchPublicationsService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfSearchPublications(params: string):any {
|
numOfEntityPublications(id: string, entity: string):any {
|
||||||
|
var parameters: string = "";
|
||||||
//OpenaireProperties.getSearchAPIURLLast()
|
if(entity == "project") {
|
||||||
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
|
parameters = "projects/"+id+"/publications/count";
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
return this.http.get(url)
|
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
|
||||||
.map(res => <any> res.json())
|
return this.numOfPublications(url);
|
||||||
.map(res => res.total).do(res => {
|
}
|
||||||
this._cache.set(key, res);
|
|
||||||
});
|
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 {
|
private quote(word: any): string {
|
||||||
|
|
|
@ -64,18 +64,12 @@ export class FetchDataproviders {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumForEntity(entity: string, id:string) {
|
public getNumForEntity(entity: string, id:string) {
|
||||||
var parameters="";
|
|
||||||
|
|
||||||
if(entity == "organization") {
|
|
||||||
parameters = "organizations/"+id+"/datasources/count";
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
if(parameters != "") {
|
if(id != "" && entity != "") {
|
||||||
|
|
||||||
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
|
this._searchDataprovidersService.numOfEntityDataproviders(id, entity).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = data;
|
this.searchUtils.totalResults = data;
|
||||||
|
|
||||||
|
@ -101,11 +95,8 @@ export class FetchDataproviders {
|
||||||
public getNumForSearch(keyword: string) {
|
public getNumForSearch(keyword: string) {
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
var parameters="datasources/count";
|
|
||||||
if(keyword != "") {
|
this._searchDataprovidersService.numOfDataproviders(keyword).subscribe(
|
||||||
parameters += "?q=" +keyword ;
|
|
||||||
}
|
|
||||||
this._searchDataprovidersService.numOfDataproviders(parameters).subscribe(
|
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = data;
|
this.searchUtils.totalResults = data;
|
||||||
this.searchUtils.status = errorCodes.DONE;
|
this.searchUtils.status = errorCodes.DONE;
|
||||||
|
|
|
@ -78,17 +78,9 @@ public getNumForEntity(entity:string, id:string){
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
var parameters = "";
|
if(id != "" && entity != "") {
|
||||||
|
|
||||||
if(entity == "project") {
|
this._searchDatasetsService.numOfEntityDatasets(id, entity).subscribe(
|
||||||
parameters = "projects/"+id;
|
|
||||||
} else if(entity == "person") {
|
|
||||||
parameters = "people/"+id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parameters != "") {
|
|
||||||
|
|
||||||
this._searchDatasetsService.numOfEntityDatasets(parameters).subscribe(
|
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = data;
|
this.searchUtils.totalResults = data;
|
||||||
|
|
||||||
|
|
|
@ -91,18 +91,12 @@ export class FetchProjects{
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumForEntity(entity: string, id:string) {
|
public getNumForEntity(entity: string, id:string) {
|
||||||
var parameters="";
|
|
||||||
|
|
||||||
if(entity == "organization") {
|
|
||||||
parameters = "organizations/"+id+"/projects/count";
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
if(parameters != "") {
|
if(id != "" && entity != "") {
|
||||||
|
|
||||||
this._searchProjectsService.numOfProjects(parameters).subscribe(
|
this._searchProjectsService.numOfEntityProjects(id, entity).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.searchUtils.totalResults = data;
|
this.searchUtils.totalResults = data;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue