Search/find

Add communityId 
	add community filter in search queries
advanced search - autocomplete
	add acronym and grant id in autocomplete for projects


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@53860 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-11-19 10:15:13 +00:00
parent 62f2c06fa8
commit f17d4735ea
15 changed files with 91 additions and 48 deletions

View File

@ -155,7 +155,7 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='publications'" class ="uk-animation-fade" >
<browse-entities [(properties)]=properties entityName="publication" baseUrl="/search/find/publications" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="publication" baseUrl="/search/find/publications" [refineFields]=searchFields.RESULT_REFINE_FIELDS [connectCommunityId]=connectCommunityId ></browse-entities>
</div>
<!--/li>
<li-->
@ -175,7 +175,7 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='research data'" class ="uk-animation-fade">
<browse-entities [(properties)]=properties entityName="dataset" baseUrl="/search/find/datasets" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="dataset" baseUrl="/search/find/datasets" [refineFields]=searchFields.RESULT_REFINE_FIELDS [connectCommunityId]=connectCommunityId ></browse-entities>
</div>
<!--/li>
<li-->
@ -194,7 +194,7 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='software'" class ="uk-animation-fade">
<browse-entities [(properties)]=properties entityName="software" baseUrl="/search/find/software" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="software" baseUrl="/search/find/software" [refineFields]=searchFields.RESULT_REFINE_FIELDS [connectCommunityId]=connectCommunityId ></browse-entities>
</div>
<!--/li>
<li-->
@ -213,7 +213,7 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='other research products'" class ="uk-animation-fade">
<browse-entities [(properties)]=properties entityName="other" baseUrl="/search/find/other" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="other" baseUrl="/search/find/other" [refineFields]=searchFields.RESULT_REFINE_FIELDS [connectCommunityId]=connectCommunityId ></browse-entities>
</div>
<!--/li>
<li-->

View File

@ -32,6 +32,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service';
import {ConfigurationService} from '../../utils/configuration/configuration.service';
import {EnvProperties} from '../../utils/properties/env-properties';
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
import {StringUtils} from '../../utils/string-utils.class';
@Component({
changeDetection: ChangeDetectionStrategy.Default,
@ -99,6 +100,8 @@ export class SearchComponent {
properties: EnvProperties;
@Input() logoURL;
@Input() name;
@Input() connectCommunityId =null;
@Input() piwikSiteId = null;
public subPub;public subData; public subSoftware; public subOrps; public subProjects;public subOrg; public subDataPr;
constructor ( private route: ActivatedRoute,
@ -142,13 +145,13 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this._meta.updateTag({content:url},"property='og:url'");
this.seoService.createLinkForCanonicalURL(false);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...").subscribe();
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
}
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.properties.adminToolsCommunity ).subscribe(data => {
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, (this.connectCommunityId)?this.connectCommunityId:this.properties.adminToolsCommunity ).subscribe(data => {
var showEntity = {};
for(var i=0; i< data.entities.length; i++){
@ -161,12 +164,17 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.showDataProviders = showEntity["datasource"];
this.showSoftware = showEntity["software"];
this.showOrps = showEntity["orp"];
if(this.connectCommunityId){
this.showProjects = false;
this.showOrganizations = false;
this.showDataProviders = false;
}
this.sub = this.route.queryParams.subscribe(params => {
this.reloadTabs();
this.keyword = (params['keyword'])?params['keyword']:"";
if(this.keyword !=null && this.keyword.length > 0){
this.reloadTabs();
//if showPublications == false will set another entity as the first
if(this.showPublications){
this.activeTab = "publications";
@ -236,10 +244,10 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "publications";
this.advancedSearchLink ="/search/advanced/publications";
if( this.reloadPublications &&
this.fetchPublications.searchUtils.status != this.errorCodes.NONE &&
this.fetchPublications.searchUtils.status != this.errorCodes.ERROR) {
this.fetchPublications.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchPublications.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadPublications = false;
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.connectCommunityId);
this.linkToSearchPublications = this.properties.searchLinkToPublications;// + "?keyword=" + this.keyword;
}
}
@ -247,10 +255,10 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "research data";
this.advancedSearchLink ="/search/advanced/datasets";
if(this.reloadDatasets &&
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE &&
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR) {
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadDatasets = false;
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.connectCommunityId);
this.linkToSearchDatasets =this.properties.searchLinkToDatasets;// + "?keyword=" + this.keyword;
}
}
@ -259,11 +267,12 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "software";
this.advancedSearchLink ="/search/advanced/software";
if(this.reloadSoftware &&
if(this.reloadSoftware
&& this.fetchSoftware.searchUtils.status != this.errorCodes.NONE/* &&
( this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
this.fetchSoftware.searchUtils.status == this.errorCodes.DONE )) {
this.fetchSoftware.searchUtils.status == this.errorCodes.DONE )*/) {
this.reloadSoftware = false;
this.fetchSoftware.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.fetchSoftware.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.connectCommunityId);
this.linkToSearchSoftware = this.properties.searchLinkToSoftware;// + "?keyword=" + this.keyword;
}
}
@ -272,10 +281,10 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "other research products";
this.advancedSearchLink ="/search/advanced/other";
if(this.reloadOrps &&
this.fetchOrps.searchUtils.status != this.errorCodes.NONE &&
this.fetchOrps.searchUtils.status != this.errorCodes.ERROR) {
this.fetchOrps.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchOrps.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadOrps = false;
this.fetchOrps.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.fetchOrps.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.connectCommunityId);
this.linkToSearchOrps =this.properties.searchLinkToOrps;
}
}
@ -283,8 +292,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "projects";
this.advancedSearchLink ="/search/advanced/projects";
if(this.reloadProjects &&
this.fetchProjects.searchUtils.status != this.errorCodes.NONE &&
this.fetchProjects.searchUtils.status != this.errorCodes.ERROR) {
this.fetchProjects.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchProjects.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadProjects = false;
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword;
@ -294,8 +303,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "content providers";
this.advancedSearchLink ="/search/advanced/dataproviders";
if( this.reloadDataproviders &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR) {
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadDataproviders = false;
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword;
@ -305,8 +314,8 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.activeTab = "organizations";
this.advancedSearchLink ="/search/advanced/organizations";
if( this.reloadOrganizations &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR) {
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadOrganizations = false;
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword;
@ -346,10 +355,12 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
}
private count() {
var refineParams = this.connectCommunityId?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((this.connectCommunityId )))):null;
if(this.activeTab != "publications" && this.showPublications){
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
this.fetchPublications.results = [];
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword,this.properties).subscribe(
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword,this.properties, refineParams).subscribe(
data => {
console.log("Count results: "+data);
this.fetchPublications.searchUtils.totalResults = data;
@ -367,7 +378,7 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
if(this.activeTab != "research data" && this.showDatasets){
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
this.fetchDatasets.results = [];
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword,this.properties).subscribe(
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchDatasets.searchUtils.totalResults = data;
this.fetchDatasets.searchUtils.status = this.errorCodes.DONE;
@ -384,7 +395,7 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
if(this.activeTab != "software" && this.showSoftware){
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
this.fetchSoftware.results = [];
this.subSoftware = this._searchSoftwareService.numOfSearchSoftware(this.keyword,this.properties).subscribe(
this.subSoftware = this._searchSoftwareService.numOfSearchSoftware(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchSoftware.searchUtils.totalResults = data;
this.fetchSoftware.searchUtils.status = this.errorCodes.DONE;
@ -408,7 +419,7 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
if(this.activeTab != "other research products" && this.showOrps){
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrps.results = [];
this.subOrps = this._searchOrpsService.numOfSearchOrps(this.keyword,this.properties).subscribe(
this.subOrps = this._searchOrpsService.numOfSearchOrps(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchOrps.searchUtils.totalResults = data;
this.fetchOrps.searchUtils.status = this.errorCodes.DONE;
@ -473,6 +484,13 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.reloadProjects = true;
this.reloadDataproviders = true;
this.reloadOrganizations = true;
this.fetchOrganizations.searchUtils.status = null;
this.fetchDataproviders.searchUtils.status = null;
this.fetchProjects.searchUtils.status = null;
this.fetchPublications.searchUtils.status = null;
this.fetchDatasets.searchUtils.status = null;
this.fetchSoftware.searchUtils.status = null;
this.fetchOrps.searchUtils.status = null;
}

View File

@ -10,6 +10,7 @@ import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';
@Component({
selector: 'browse-entities',
@ -38,6 +39,8 @@ export class BrowseEntitiesComponent {
@Input() public entityName:string = "";
@Input() public refineFields: string[] ;//= this.searchFields.RESULT_REFINE_FIELDS;
@Input() properties:EnvProperties;
@Input() connectCommunityId =null;
public sub: any;
public errorCodes:ErrorCodes = new ErrorCodes();
public status = this.errorCodes.LOADING;
@ -68,7 +71,9 @@ export class BrowseEntitiesComponent {
private getStats(){
this.status = this.errorCodes.LOADING;
this.sub = this._refineFieldsService.getRefineFieldsResultsByEntityName(this.refineFields,this.entityName, this.properties).subscribe(
var refineParams = this.connectCommunityId?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((this.connectCommunityId )))):null;
this.sub = this._refineFieldsService.getRefineFieldsResultsByEntityName(this.refineFields,this.entityName, this.properties,refineParams).subscribe(
data => {
console.info("Get Stats for "+this.entityName+ ": [Total:"+data[0]+" ] [fields: "+data[1].length+"]");
this.filters = data[1];

View File

@ -11,11 +11,14 @@ import{EnvProperties} from '../utils/properties/env-properties';
@Injectable()
export class RefineFieldResultsService {
constructor(private http: Http ) {}
getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties):any{
getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{
let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
for(var i=0; i < fields.length; i++){
url += "&fields="+fields[i];
}
if(communityQuery!= null && communityQuery != '' ) {
url += communityQuery;
}
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())

View File

@ -351,11 +351,14 @@ export class SearchDatasetsService {
return this.numOfDatasets(url, properties);
}
numOfSearchDatasets(params: string, properties:EnvProperties):any {
numOfSearchDatasets(params: string, properties:EnvProperties, refineParams:string=null):any {
let url = properties.searchAPIURLLAst+"datasets/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
return this.numOfDatasets(url, properties);
}
}

View File

@ -355,12 +355,15 @@ export class SearchOrpsService {
return this.numOfOrps(url, properties);
}
numOfSearchOrps(params: string, properties:EnvProperties):any {
numOfSearchOrps(params: string, properties:EnvProperties, refineParams:string=null):any {
let url = properties.searchAPIURLLAst+"other/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
return this.numOfOrps(url, properties);
}
}

View File

@ -465,11 +465,14 @@ export class SearchPublicationsService {
return this.numOfPublications(url, properties);
}
numOfSearchPublications(params: string, properties:EnvProperties):any {
numOfSearchPublications(params: string, properties:EnvProperties, refineParams:string=null):any {
let url = properties.searchAPIURLLAst+"publications/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
return this.numOfPublications(url, properties);
}
/*

View File

@ -366,11 +366,14 @@ export class SearchSoftwareService {
return this.numOfSoftware(url, properties);
}
numOfSearchSoftware(params: string, properties:EnvProperties):any {
numOfSearchSoftware(params: string, properties:EnvProperties, refineParams:string=null):any {
let url = properties.searchAPIURLLAst+"software/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
return this.numOfSoftware(url, properties);
}
}

View File

@ -5,7 +5,6 @@ import { JsonldDocumentSerializerService } from './service/jsonld-document-seria
selector: 'schema2jsonld',
template: `
<ngx-json-ld [json]="json"></ngx-json-ld>
{{json|json}}
`
})
export class Schema2jsonldComponent {

View File

@ -235,8 +235,10 @@ export class EntitiesAutocompleteComponent {
}
showItem(item:any):string{
if (item.name){ //search
console.log(item);
if (item.projectName || item.projectAcronym || item.code){ //project
return ((item.projectAcronym)?"["+item.projectAcronym+"] ":"")+item.projectName+((item.code)?" ("+item.code+")":"");
}else if (item.name){ //search
return item.name;
}else if( item.concept && item.concept.label){ //context
return item.concept.label;

View File

@ -37,7 +37,7 @@ export class FetchDatasets{
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, connectCommunityId=null){
var parameters = "";
if(keyword.length > 0){
var DOIs:string[] = DOI.getDOIsFromString(keyword);
@ -55,8 +55,9 @@ export class FetchDatasets{
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
var refineParams = (connectCommunityId)?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((connectCommunityId )))):null;
this.subResults = this._searchDatasetsService.searchDatasets(parameters,null, page, size, [], properties).subscribe(
this.subResults = this._searchDatasetsService.searchDatasets(parameters,refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Research Data: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");

View File

@ -38,7 +38,7 @@ export class FetchOrps{
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, connectCommunityId=null){
console.info("orps: getResultsByKeyword");
var parameters = "";
if(keyword.length > 0){
@ -56,8 +56,8 @@ export class FetchOrps{
}
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchOrpsService.searchOrps(parameters,null, page, size, [], properties).subscribe(
var refineParams = (connectCommunityId)?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((connectCommunityId )))):null;
this.subResults = this._searchOrpsService.searchOrps(parameters,refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");

View File

@ -49,7 +49,7 @@ export class FetchPublications {
}
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, connectCommunityId=null){
var parameters = "";
if(keyword.length > 0){
var DOIs:string[] = DOI.getDOIsFromString(keyword);
@ -68,8 +68,8 @@ export class FetchPublications {
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchPublicationsService.searchPublications(parameters,null, page, size, [], properties).subscribe(
var refineParams = (connectCommunityId)?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((connectCommunityId )))):null;
this.subResults = this._searchPublicationsService.searchPublications(parameters,refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");

View File

@ -38,7 +38,7 @@ export class FetchSoftware{
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, connectCommunityId=null){
var parameters = "";
if(keyword.length > 0){
var DOIs:string[] = DOI.getDOIsFromString(keyword);
@ -56,8 +56,9 @@ export class FetchSoftware{
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
var refineParams = (connectCommunityId)?("&fq="+StringUtils.URIEncode("communityId exact " + StringUtils.quote((connectCommunityId )))):null;
this.subResults = this._searchSoftwareService.searchSoftware(parameters,null, page, size, [], properties).subscribe(
this.subResults = this._searchSoftwareService.searchSoftware(parameters,refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Software: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");

View File

@ -19,6 +19,8 @@ export class PiwikService {
var ua = this.getUserAgent();
var referrer = this.getReferrer();
console.log("Piwik - id: " + siteId);
if(typeof location !== 'undefined'){
var url = properties.piwikBaseUrl+((siteId!=null)?siteId:properties.piwikSiteId)+"&rec=1&url="+StringUtils.URIEncode(location.href)+"&action_name="+StringUtils.URIEncode(title)+
((ua != null && ua.length > 0)?('&ua='+StringUtils.URIEncode(ua)):'')+