[Library | Trunk]: fetchResearchResults.class.ts: [Bug fix] Rename method "getEntityName()" to "getEnityQueryName()" and return types for queries (wrong usage of OpenaireEntities in commit bd6e141801
)
This commit is contained in:
parent
dea5b96f56
commit
ac2c67d0ca
|
@ -58,7 +58,7 @@ export class FetchResearchResults {
|
|||
}
|
||||
},
|
||||
err => {
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for community: "+communityId, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for community: "+communityId, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -77,7 +77,7 @@ export class FetchResearchResults {
|
|||
}
|
||||
},
|
||||
err => {
|
||||
this.handleError("Error getting number of "+this.getEntityName(resultType,true)+" for community: "+communityId, err);
|
||||
this.handleError("Error getting number of "+this.getEntityQueryName(resultType,true)+" for community: "+communityId, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -96,7 +96,7 @@ export class FetchResearchResults {
|
|||
}
|
||||
},
|
||||
err => {
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for community: "+communityId, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for community: "+communityId, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -122,7 +122,7 @@ export class FetchResearchResults {
|
|||
if(customFilter){
|
||||
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
|
||||
}
|
||||
this.subscriptions.push(this._searchResearchResultsService.search(this.getEntityName(resultType,false), parameters,refineParams, page, size, "", [], properties).subscribe(
|
||||
this.subscriptions.push(this._searchResearchResultsService.search(this.getEntityQueryName(resultType,false), parameters,refineParams, page, size, "", [], properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
|
@ -147,7 +147,7 @@ export class FetchResearchResults {
|
|||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -157,7 +157,7 @@ export class FetchResearchResults {
|
|||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
if(id != "" && entity != "") {
|
||||
this.subscriptions.push(this._searchResearchResultsService.numOfEntityResults(this.getEntityName(resultType,false), id, entity, properties).subscribe(
|
||||
this.subscriptions.push(this._searchResearchResultsService.numOfEntityResults(this.getEntityQueryName(resultType,false), id, entity, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data;
|
||||
|
||||
|
@ -181,7 +181,7 @@ export class FetchResearchResults {
|
|||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for "+entity+" with id: "+id, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -243,7 +243,7 @@ export class FetchResearchResults {
|
|||
}
|
||||
|
||||
if(parameters != "") {
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchResultForEntity(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe(
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchResultForEntity(this.getEntityQueryName(resultType,false), parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
|
@ -269,7 +269,7 @@ export class FetchResearchResults {
|
|||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for "+entity+" with id: "+id, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -286,11 +286,11 @@ export class FetchResearchResults {
|
|||
// parameters = this.getEntityName(resultType,true)+"?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
// }
|
||||
|
||||
parameters = this.getEntityName(resultType,true)+"?fq=collectedfromdatasourceid exact "+'"'+id+'"' + "or resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
parameters = this.getEntityQueryName(resultType,true)+"?fq=collectedfromdatasourceid exact "+'"'+id+'"' + "or resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchForDataproviders(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe(
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchForDataproviders(this.getEntityQueryName(resultType,false), parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
|
@ -315,7 +315,7 @@ export class FetchResearchResults {
|
|||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for "+OpenaireEntities.DATASOURCE+" ("+resultsFrom+") with id: "+id, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for "+OpenaireEntities.DATASOURCE+" ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
));
|
||||
|
@ -325,7 +325,7 @@ export class FetchResearchResults {
|
|||
public getAggregatorResults(resultType: string, id:string, page: number, size: number, properties:EnvProperties){
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
// this.getEntityName(resultType,false)
|
||||
// this.getEntityQueryName(resultType,false)
|
||||
this.subscriptions.push(this._searchResearchResultsService.searchAggregators(resultType, id, '&fq=(collectedfromdatasourceid exact "'+id+'" or resulthostingdatasourceid exact "'+id+'")',"&refine=true&fields=resulthostingdatasource&type="+resultType , page, size, properties).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
|
@ -353,7 +353,7 @@ export class FetchResearchResults {
|
|||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting "+this.getEntityName(resultType,true)+" for aggregator with id: "+id, err);
|
||||
this.handleError("Error getting "+this.getEntityQueryName(resultType,true)+" for aggregator with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.requestComplete.complete();
|
||||
|
@ -365,25 +365,12 @@ export class FetchResearchResults {
|
|||
console.error("Fetch "+OpenaireEntities.RESULTS+" (class): "+message, error);
|
||||
}
|
||||
|
||||
private getEntityName (entityType:string, plural:boolean){
|
||||
if(entityType == "publication") {
|
||||
return plural ? OpenaireEntities.PUBLICATIONS : OpenaireEntities.PUBLICATION;
|
||||
} else if (entityType == "dataset") {
|
||||
return plural ? OpenaireEntities.DATASETS : OpenaireEntities.DATASET;
|
||||
} else if (entityType == "software") {
|
||||
return plural ? OpenaireEntities.SOFTWARE : OpenaireEntities.SOFTWARE_SINGULAR;
|
||||
} else if (entityType == "other") {
|
||||
return plural ? OpenaireEntities.OTHER : OpenaireEntities.OTHER_SINGULAR;
|
||||
} else if (entityType == "organization") {
|
||||
return plural ? OpenaireEntities.ORGANIZATIONS : OpenaireEntities.ORGANIZATION;
|
||||
} else if (entityType == "datasource") {
|
||||
return plural ? OpenaireEntities.DATASOURCES : OpenaireEntities.DATASOURCE;
|
||||
} else if (entityType == "project" ) {
|
||||
return plural ? OpenaireEntities.PROJECTS : OpenaireEntities.PROJECT;
|
||||
} else if(entityType == "result") {
|
||||
return plural ? OpenaireEntities.RESULTS : OpenaireEntities.RESULT;
|
||||
} else {
|
||||
return entityType;
|
||||
private getEntityQueryName(entityType: string, plural: boolean) {
|
||||
if (entityType == "publication" || entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project") {
|
||||
if (plural) {
|
||||
return entityType + "s";
|
||||
}
|
||||
}
|
||||
return entityType;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue