Use proper query for deposit results - pubs and data repo

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44435 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-11-10 14:43:13 +00:00
parent b5931f654c
commit c9abfbf046
3 changed files with 43 additions and 57 deletions

View File

@ -104,7 +104,7 @@ export class DepositResultComponent {
// if(this.organization != undefined) {
// this.searchDataprovidersComponent.getResults(this.organization.name, false, 1, 10);
// } else if(this.organizationId != undefined) {
this.searchDataprovidersComponent.getResultsForEntity("organization", this.organizationId, 1, 10);
this.searchDataprovidersComponent.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10);
//}
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
}

View File

@ -115,6 +115,34 @@ export class SearchDataprovidersComponent {
);
}
public getResultsForDeposit(id:string, type:string, page: number, size: number){
if(id != "") {
this._searchDataprovidersService.searchDataprovidersForDeposit(id,type, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
if(this.totalResults == 0 ){
this.status = errorCodes.NONE;
}
},
err => {
console.error(err);
//TODO check erros (service not available, bad request)
// if( ){
// this.status = ErrorCodes.ERROR;
// }
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.ERROR;
}
);
}
}
public getResultsForEntity(entity:string, id:string, page: number, size: number){
var parameters = "";
@ -186,35 +214,7 @@ export class SearchDataprovidersComponent {
}
);
}
/*
public getResults(parameters:string, page: number, size: number, flag: string){
console.log("Search Dataproviders: Execute search query "+parameters);
this._searchDataprovidersService.searchDataproviders(parameters, page, size, flag).subscribe(
data => {
this.totalResults = data[0];
console.log("Search Dataproviders: results: "+this.totalResults);
this.results = data[1];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
if(this.totalResults == 0 ){
this.status = errorCodes.NONE;
}
},
err => {
console.error(err);
console.info("error");
//TODO check erros (service not available, bad request)
// if( ){
// this.status = ErrorCodes.ERROR;
// }
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.NOT_AVAILABLE;
}
);
}
*/
private setFilters(){
//TODO set filters from
}
@ -224,32 +224,4 @@ export class SearchDataprovidersComponent {
this._getResults(parameters, true, this.page, this.size);
}
// private createFilters():Filter[] {
// var filter_names=["Type","Compatibility Level"];
// var filter_ids=["type","compatibility"];
// var searchFields = new SearchFields();
// var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; //["datasourcetypeid","openairecompatibilityid"];
// var value_names=[
// ["Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Publication Repositories Aggregators",
// "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
// ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]];
// var value_ids=[
// ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"],
// ["compBasic","comp2", "comp2plus", "comp3","comp2data"]];
// var value_original_ids=[
// ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic or aggregator::pubsrepository::institutional or aggregator::pubsrepository::unknown",
// "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"],
// ["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]];
// var filters: Filter[] =[];
// for(var i =0 ; i < filter_names.length;i++){
// var values:Value[] = [];
// for(var j =0 ; j < value_names[i].length;j++){
// var value:Value = {name: value_names[i][j], id: value_ids[i][j], number:j, selected:false}
// values.push(value);
// }
// var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'}
// filters.push(filter);
// }
// return filters;
// }
}

View File

@ -60,6 +60,20 @@ export class SearchDataprovidersService {
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
}
searchDataprovidersForDeposit (id: string,type:string, page: number, size: number):any {
let link = OpenaireProperties.getSearchResourcesAPIURL();
var compatibilities = "";
if(type == "Datasets"){
compatibilities = " and (datasourcecompatibilityid = openaire2.0_data)"
}else if(type == "Publications"){
compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
}
let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact "+id+")";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
searchDataprovidersForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURL();
let url = link+params+"/datasources";