use search with full index query in compatible and entity registries pages

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44433 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-11-10 12:29:56 +00:00
parent 3f972fabcb
commit 413439b784
8 changed files with 189 additions and 69 deletions

View File

@ -17,6 +17,7 @@ import {SearchPageComponent } from '../searchUtils/searchPage.component';
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" [showResultCount]=false (queryChange)="queryChanged($event)" >
</search-page>
<!--table-view [(datasources)] = results></table-view-->
`
@ -63,24 +64,8 @@ export class SearchCompatibleDataprovidersComponent {
this.keyword = (params['keyword']?params['keyword']:'');
this.page = (params['page']=== undefined)?1:+params['page'];
this.filters = this.createFilters();
// for(var i=0; i< this.filters.length ; i++){
// var filter = this.filters[i];
// console.info(params);
// if(params[filter.filterId] != undefined) {
// let values = params[filter.filterId].split(",");
// for(let value of values) {
// for(let filterValue of filter.values) {
// if(filterValue.id == value) {
// filterValue.selected = true;
// filter.countSelectedValues++;
// }
// }
// }
// }
// }
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params);
this._getResults(queryParameters, false, this.page, this.size);
// this.getResults(this.keyword, this.page, this.size, "searchPage");
});
}
@ -92,17 +77,13 @@ export class SearchCompatibleDataprovidersComponent {
this.subResults.unsubscribe();
} }
private _getResults(parameters:string,refine:boolean, page: number, size: number){
// if(!refine && !this.searchPage){
// this.searchPage = new SearchPageComponent(this._location);
// }
this.subResults = this._searchDataprovidersService.searchDataproviders(this._prefixQuery+parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe(
this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
// this.filters = data[2];
this.searchPage.checkSelectedFilters(this.filters);
// this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
@ -126,8 +107,9 @@ export class SearchCompatibleDataprovidersComponent {
}
private queryChanged($event) {
var parameters = $event.value;
var parameters = $event.index;
console.info("queryChanged: Execute search query "+parameters);
this._getResults(parameters, false, this.page, this.size);
}
private createFilters():Filter[] {
@ -136,19 +118,15 @@ export class SearchCompatibleDataprovidersComponent {
var searchFields = new SearchFields();
var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
var value_names=[
["Publication Repositories",
[
"Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository",
"Publication Repositories Aggregators",
"Institutional Repositories Aggregators",
"Thematic Repositories Aggregators", "Other Repositories Aggregators",
"Institutional Repositories Aggregators",
"Thematic Repositories Aggregators", "Other 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=[
["HEADER","pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown","HEADER", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown",
["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","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[] =[];

View File

@ -0,0 +1,74 @@
import {Component, Input, ViewChild} from '@angular/core';
@Component({
selector: 'table-view',
template: `
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Type</th>
<th>Country</th>
<th>Institution</th>
<th>Compatibility</th>
</tr>
<tr *ngFor="let result of datasources">
<td>
<a href="{{result['title'].url}}">
<p *ngIf="result['title'].name != undefined && result['title'].name != ''">
{{result['title'].name}}
</p>
<p *ngIf="result['title'].name == undefined || result['title'].name == ''">
{{result['title'].url}}
</p>
</a>
</td>
<td> {{result['type']}}</td>
<td>....</td>
<td>
<span *ngFor="let organization of result['organizations'] let i=index">
<a *ngIf="organization.url != undefined" href="{{organization.url}}">
{{organization.name}}
</a>
<span *ngIf="organization.url == undefined">
{{organization.name}}
</span>
<span *ngIf="i < result['organizations'].length-1"> ,</span>
</span>
</td>
<td>....</td>
</tr>
</table>
`
})
export class DatasourceTableViewComponent {
@Input() datasources =[];
// private results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = [];
constructor () {
}
private ngOnInit() {
// // var results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = []
// for(var i =0; i < this.datasources.length; i++){
// var datasource: {name:string, type:string, organizations:string, countries:string, compatibility:string} = {name:"",type:"",organizations:"", countries:"", compatibility:""};
// datasource.name = '<a href="'+this.datasources[i]['title'].url+'" >' + (this.datasources[i]['title'].name)?this.datasources[i]['title'].name:this.datasources[i]['title'].url +'</a>';
// datasource.type = this.datasources[i]['type'];
// this.results.push(datasource);
// }
}
private ngOnDestroy() {
}
sort(){
// objs.sort(function(a,b) {return (a.last_nom > b.last_nom) ? 1 : ((b.last_nom > a.last_nom) ? -1 : 0);} );
}
}

View File

@ -65,7 +65,7 @@ export class SearchEntityRegistriesComponent {
this.page = (params['page']=== undefined)?1:+params['page'];
this.filters = this.createFilters();
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params);
this._getResults(queryParameters, false, this.page, this.size);
});
}
@ -78,14 +78,12 @@ export class SearchEntityRegistriesComponent {
this.subResults.unsubscribe();
} }
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this.subResults = this._searchDataprovidersService.searchDataproviders(this._prefixQuery+parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe(
this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
// this.filters = data[2];
this.searchPage.checkSelectedFilters(this.filters);
// this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
@ -109,32 +107,24 @@ export class SearchEntityRegistriesComponent {
}
private queryChanged($event) {
var parameters = $event.value;
var parameters = $event.index;
console.info("queryChanged: Execute search query "+parameters);
this._getResults(parameters, false, this.page, this.size);
}
private createFilters():Filter[] {
var filter_names=["Type","Compatibility Level"];
var filter_ids=["datasourcetypeuiid","datasourcecompatibilityid"];
var filter_ids=["datasourcetypeid","datasourcecompatibilityid"];
var searchFields = new SearchFields();
var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
var filter_original_ids = searchFields.ENTITY_REGISTRIES_FIELDS;
var value_names=[
[],
// ["Publication Repositories",
// "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository",
// "Publication Repositories Aggregators",
// "Institutional Repositories Aggregators",
// "Thematic Repositories Aggregators", "Other Repositories Aggregators",
// "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"],
["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=[
[],
// ["HEADER","pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown","HEADER", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown",
// "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"],
["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"],
["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[] = [];

View File

@ -29,7 +29,7 @@ import {SearchPeopleComponent} from './searchPeople.component';
import {SearchComponent} from './find/search.component';
import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component';
import {SearchEntityRegistriesComponent} from './dataProviders/entityRegistries.component';
import {DatasourceTableViewComponent} from './dataProviders/datasourceTableView.component';
//Advanced
import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
@ -64,6 +64,7 @@ import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchO
SearchProjectsComponent,
SearchCompatibleDataprovidersComponent,
SearchEntityRegistriesComponent,
DatasourceTableViewComponent,
SearchDatasetsComponent,
SearchOrganizationsComponent,
SearchPeopleComponent

View File

@ -96,6 +96,31 @@ export class SearchPageComponent {
var keyword = params['keyword'];
return (keyword && keyword.length > 0?'q='+keyword+"&op=and":'')+parameters;
}
public getIndexQueryParametersFromUrl(params){
var parameters = "";
for(var i=0; i< this.refineFields.length ; i++){
var filterId = this.refineFields[i];
if(params[filterId] != undefined) {
if(this.queryParameters == undefined){
this.queryParameters = new Map<string,string>();
}
this.queryParameters[filterId]=decodeURIComponent(params[filterId]);
let values = decodeURIComponent(this.queryParameters[filterId]).split(",");
var countvalues = 0
for(let value of values) {
countvalues++;
parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value;
}
parameters+= " ) "
}
}
var keyword = params['keyword'];
parameters += (keyword && keyword.length > 0?' and '+keyword+' ':'');
return parameters;
}
/*
* Mark as check the new filters that are selected, when you get them from search
*/
@ -160,28 +185,38 @@ export class SearchPageComponent {
var fieldId = this.indexIdsMap[filter.filterId];
for (let value of filter.values){
if(value.selected == true){
// if(filter.filterOperator == 'not') {
// filterLimits+=((filterLimits.length == 0)?'':' and ') + filter.filterId + '<>'+ value.id;
// } else {
// filterLimits+=((filterLimits.length == 0)?'':' '+filter.filterOperator+' ') + filter.filterId + '='+ value.id;
// }
count_selected++;
// if(filter.filterOperator == 'not') {
// filterLimits+='&' + fieldId + '='+ value.id+"&" + this.fieldIdsMap[fieldId].operator + "=not";
// } else {
filterLimits+='&' + fieldId+ '='+ value.id+"&" + this.fieldIdsMap[fieldId].operator + "="+((count_selected == 1)?"and":filter.filterOperator);
filterLimits+='&' + fieldId+ '='+ value.id+"&" + this.fieldIdsMap[fieldId].operator + "="+((count_selected == 1)?"and":filter.filterOperator);
// }
}
}
allLimits += filterLimits;
}
}
// if(this.keyword.length > 0 ){
// allLimits= this.keyword + allLimits /*+ ' keyword=' */;
// }
return (this.keyword.length > 0?'q='+this.keyword+"&op=and":'')+allLimits;
}
private createIndexQueryParameters(filters:Filter[]){
var allLimits="";
for (let filter of filters){
if(filter.countSelectedValues > 0){
var filterLimits="";
var count_selected=0;
var fieldId = this.indexIdsMap[filter.filterId];
for (let value of filter.values){
if(value.selected == true){
count_selected++;
filterLimits+=((count_selected == 1)?" and (":" "+filter.filterOperator+" ") + filter.filterId+ '='+ value.id;
}
}
filterLimits+=(filterLimits.length > 0 )?' ) ':'';
allLimits += filterLimits;
}
}
allLimits += (this.keyword && this.keyword.length > 0?' and '+this.keyword+' ':'');
return allLimits;
}
//
private isFiltered(){
var filtered=false;
@ -220,10 +255,14 @@ export class SearchPageComponent {
var urlParameters = this.createUrlParameters(this.filters,true);
this.updateBaseUrlWithParameters(this.filters);
var queryParameters = this.createSearchQueryParameters(this.filters);
var indexQuery = this.createIndexQueryParameters(this.filters);
this.location.go(location.pathname,urlParameters);
this.queryChange.emit({
value: queryParameters
value: queryParameters,
index:indexQuery
});
}

View File

@ -29,6 +29,36 @@ export class SearchDataprovidersService {
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
}
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL();
url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = hostedBy) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
if(params!= null && params != '' ) {
url += params;
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
url += "&page="+page+"&size="+size;
return this.http.get(url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
}
searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any {
let url = OpenaireProperties.getSearchResourcesAPIURL();
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"
if(params!= null && params != '' ) {
url += params;
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
url += "&page="+page+"&size="+size;
return this.http.get(url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
}
searchDataprovidersForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURL();

View File

@ -28,6 +28,7 @@ export class OpenaireProperties {
// private static searchAPIURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/";
// private searchAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/";
private static searchAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/";
private static searchResourcesAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/resources";
//private static searchServiveURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/";
private static searchServiveURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/";
@ -107,6 +108,11 @@ export class OpenaireProperties {
public static getSearchAPIURL():string{
return this.searchAPIURL;
}
//query using full query:
//
public static getSearchResourcesAPIURL():string{
return this.searchResourcesAPIURL;
}
public static getSearchAPIURLForEntity(entityType:string):string{
var suffix = "";
if(entityType == "project"){

View File

@ -56,7 +56,7 @@ export class SearchFields {
public ADVANCED_DATAPROVIDER_PARAM:string[] = ["q", "officialname",
"engname","subjects", "type","lang","contenttype", "compatibility"];
public DATAPROVIDER_INDEX_PARAM_MAP:{ [key:string]:string } = {
[ "datasourcetypeuiid"]:"type", ["datasourceodlanguages"]:"lang",["datasourceodcontenttypes"]:"contenttype",
[ "datasourcetypeuiid"]:"type", [ "datasourcetypeid"]:"datasourcetype", ["datasourceodlanguages"]:"lang",["datasourceodcontenttypes"]:"contenttype",
["datasourcecompatibilityid"]:"compatibility"};
public DATAPROVIDER_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={
@ -65,12 +65,14 @@ export class SearchFields {
["engname"]:{name:"Start Year",operator:"eg", type:"keyword", indexField:"datasourceenglishname"},
["subjects"]: {name:"Subject",operator:"sb", type:"keyword", indexField:"datasourceodsubjects"},
["type"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeuiid"},
["datasourcetype"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeid"},
["lang"]:{name:"Language",operator:"ln", type:"vocabulary", indexField:"datasourceodlanguages"},
["contenttype"]:{name:"Content Type",operator:"cn", type:"refine", indexField:"datasourceodcontenttypes"},
["compatibility"]:{name:"Compatibility Level",operator:"cm", type:"vocabulary", indexField:"datasourcecompatibilityid"},
};
public COMPATIBLE_DATAPROVIDER_FIELDS:string[] = ["type","compatibility"];
public ENTITY_REGISTRIES_FIELDS:string[] = ["datasourcetype","compatibility"];