updating searchPages with refine results | tabs filled with extra query use special methods (getResultsForEntity(...) in components, search*ForEntity(...) in services)

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44338 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2016-10-26 11:38:06 +00:00
parent 5d799b7fe7
commit 5b62ed7715
24 changed files with 497 additions and 142 deletions

View File

@ -122,7 +122,7 @@ export class ClaimDatasetComponent {
} }
private searchOpenaire (term: string, size : number, page : number) { private searchOpenaire (term: string, size : number, page : number) {
this._searchDatasetsService.searchDatasets(term, page, size, "claim", []).subscribe( this._searchDatasetsService.searchDatasets(term, null, page, size, []).subscribe(
data => { data => {
if(data != null) { if(data != null) {
this.openairePage=page; this.openairePage=page;

View File

@ -162,7 +162,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
} }
private searchOpenaire(term: string, size : number, page : number) { private searchOpenaire(term: string, size : number, page : number) {
this.openaireStatus = this.errorCodes.LOADING; this.openaireStatus = this.errorCodes.LOADING;
this._searchPublicationsService.searchPublications(term, page, size, "claim").subscribe( this._searchPublicationsService.searchPublications(term, null, page, size, []).subscribe(
data => { data => {
if(data != null) { if(data != null) {
this.openairePage=page; this.openairePage=page;

View File

@ -100,11 +100,11 @@ export class DepositResultComponent {
} }
private searchDataproviders() { private searchDataproviders() {
if(this.organization != undefined) { // if(this.organization != undefined) {
this.searchDataprovidersComponent.getResults(this.organization.name, 1, 10, "searchPage"); // this.searchDataprovidersComponent.getResults(this.organization.name, false, 1, 10);
} else if(this.organizationId != undefined) { // } else if(this.organizationId != undefined) {
this.searchDataprovidersComponent.getResults(this.organizationId, 1, 10, "organizationPage"); this.searchDataprovidersComponent.getResultsForEntity("organization", this.organizationId, 1, 10);
} //}
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders(); this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
} }

View File

@ -108,10 +108,10 @@ export class TabsComponent {
} }
private searchPublications() { private searchPublications() {
this.searchPublicationsComponent.getResults(this.id, 1, 10, "dataproviderPage"); this.searchPublicationsComponent.getResultsForEntity("dataprovider", this.id, 1, 10);
} }
private searchDatasets() { private searchDatasets() {
this.searchDatasetsComponent.getResults(this.id, 1, 10, "dataproviderPage"); this.searchDatasetsComponent.getResultsForEntity("dataprovider", this.id, 1, 10);
} }
} }

View File

@ -33,7 +33,7 @@
<span class="badge">{{projectsNum}}</span> <span class="badge">{{projectsNum}}</span>
</a> </a>
</li> </li>
<li role="presentation"> <li (click)="searchDataprovidersInit()" role="presentation">
<a data-toggle="tab" href="#dataProvidersTab"> <a data-toggle="tab" href="#dataProvidersTab">
Data Providers Data Providers
<!--span *ngIf="organizationInfo.dataProviders == undefined" class="badge">0</span> <!--span *ngIf="organizationInfo.dataProviders == undefined" class="badge">0</span>

View File

@ -28,6 +28,7 @@ export class OrganizationComponent {
sub: any; sub: any;
subDataproviders: any; subDataproviders: any;
subDataprovidersCount: any;
private searchDataprovidersComponent : SearchDataprovidersComponent; private searchDataprovidersComponent : SearchDataprovidersComponent;
private linkToSearchDataproviders = ""; private linkToSearchDataproviders = "";
@ -51,16 +52,26 @@ export class OrganizationComponent {
} }
}); });
this.subDataproviders = this.route.queryParams.subscribe(params => { this.subDataprovidersCount = this.route.queryParams.subscribe(params => {
this.searchDataproviders(); this._searchDataprovidersService.numOfEntityDataproviders(this.organizationId, "organizations/").subscribe(
}); data => {
this.searchDataprovidersComponent.totalResults = data;
},
err => {
console.error(err);
}
);
})
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
if(this.subDataproviders != undefined) {
this.subDataproviders.unsubscribe(); this.subDataproviders.unsubscribe();
} }
this.subDataprovidersCount.unsubscribe();
}
private getOrganizationInfo () { private getOrganizationInfo () {
console.info("inside getOrganizationInfo of component"); console.info("inside getOrganizationInfo of component");
@ -136,7 +147,15 @@ export class OrganizationComponent {
private searchDataproviders() { private searchDataproviders() {
this.searchDataprovidersComponent.getResults(this.organizationId, 1, 10, "organizationPage"); this.searchDataprovidersComponent.getResultsForEntity("organization", this.organizationId, 1, 10);
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders(); this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
} }
private searchDataprovidersInit() {
if(this.subDataproviders == undefined && this.searchDataprovidersComponent.totalResults > 0) {
this.subDataproviders = this.route.queryParams.subscribe(params => {
this.searchDataproviders();
});
}
}
} }

View File

@ -75,7 +75,7 @@ export class PersonComponent {
} }
private searchDatasetsInit() { private searchDatasetsInit() {
if(this.subDatasets == undefined) { if(this.subDatasets == undefined && this.searchDatasetsComponent.totalResults > 0) {
this.subDatasets = this.route.queryParams.subscribe(params => { this.subDatasets = this.route.queryParams.subscribe(params => {
this.searchDatasets(); this.searchDatasets();
}); });
@ -113,12 +113,12 @@ export class PersonComponent {
} }
private searchPublications() { private searchPublications() {
this.searchPublicationsComponent.getResults(this.personId, 1, 10, "personPage"); this.searchPublicationsComponent.getResultsForEntity("person", this.personId, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications(); this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();
} }
private searchDatasets() { private searchDatasets() {
this.searchDatasetsComponent.getResults(this.personId, 1, 10, "personPage"); this.searchDatasetsComponent.getResultsForEntity("person", this.personId, 1, 10);
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets(); this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();
} }
} }

View File

@ -95,17 +95,17 @@ export class ProjectComponent implements OnInit{
} }
private searchPublications() { private searchPublications() {
this.searchPublicationsComponent.getResults(this.projectId, 1, 10, "projectPage"); this.searchPublicationsComponent.getResultsForEntity("project", this.projectId, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications(); this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();
} }
private searchDatasets() { private searchDatasets() {
this.searchDatasetsComponent.getResults(this.projectId, 1, 10, "projectPage"); this.searchDatasetsComponent.getResultsForEntity("project", this.projectId, 1, 10);
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets(); this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();
} }
private searchDatasetsInit() { private searchDatasetsInit() {
if(this.subDatasets == undefined) { if(this.subDatasets == undefined && this.searchDatasetsComponent.totalResults > 0) {
this.subDatasets = this.route.queryParams.subscribe(params => { this.subDatasets = this.route.queryParams.subscribe(params => {
this.searchDatasets(); this.searchDatasets();
}); });

View File

@ -77,7 +77,7 @@ export class AdvancedSearchPublicationsComponent {
public getResults(parameters:string, page: number, size: number){ public getResults(parameters:string, page: number, size: number){
console.info("Advanced Search Publications: Execute search query "+parameters); console.info("Advanced Search Publications: Execute search query "+parameters);
this._searchPublicationsService.searchPublications(parameters, page, size, 'searchPage').subscribe( this._searchPublicationsService.searchPublications(parameters, null, page, size, []).subscribe(
data => { data => {
this.totalResults = data[0]; this.totalResults = data[0];
console.info("searchPubl total="+this.totalResults); console.info("searchPubl total="+this.totalResults);

View File

@ -57,14 +57,14 @@ export class SearchCompatibleDataprovidersComponent {
} }
} }
} }
this.getResults(this.keyword, this.page, this.size, "searchPage"); // this.getResults(this.keyword, this.page, this.size, "searchPage");
}); });
} }
private ngOnDestroy() { private ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
/*
public getResults(parameters:string, page: number, size: number, flag: string){ public getResults(parameters:string, page: number, size: number, flag: string){
console.info("getResults: Execute search query "+parameters); console.info("getResults: Execute search query "+parameters);
//q=(not datasourcecompatibilityid exact 'UNKNOWN' )and (not datasourcecompatibilityid exact 'hostedBy' ) and (not datasourcecompatibilityid exact 'notCompatible' ) //q=(not datasourcecompatibilityid exact 'UNKNOWN' )and (not datasourcecompatibilityid exact 'hostedBy' ) and (not datasourcecompatibilityid exact 'notCompatible' )
@ -90,7 +90,7 @@ export class SearchCompatibleDataprovidersComponent {
} }
); );
} }
*/
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
} }
@ -98,7 +98,7 @@ export class SearchCompatibleDataprovidersComponent {
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters); console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size, "searchPage"); //this.getResults(parameters, this.page, this.size, "searchPage");
} }
private createFilters():Filter[] { private createFilters():Filter[] {
var filter_names=["Type","Compatibility Level"]; var filter_names=["Type","Compatibility Level"];

View File

@ -182,7 +182,7 @@ export class SearchComponent {
this.activeTab = "publications"; this.activeTab = "publications";
if(this.reloadPublications) { if(this.reloadPublications) {
this.reloadPublications = false; this.reloadPublications = false;
this.searchPublicationsComponent.getResults(this.keyword, 1, 10, "searchPage"); this.searchPublicationsComponent.getResults(this.keyword, false, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications() + this.keyword; this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications() + this.keyword;
} }
} }
@ -190,7 +190,7 @@ export class SearchComponent {
this.activeTab = "datasets"; this.activeTab = "datasets";
if(this.reloadDatasets) { if(this.reloadDatasets) {
this.reloadDatasets = false; this.reloadDatasets = false;
this.searchDatasetsComponent.getResults(this.keyword, 1, 10, "searchPage"); this.searchDatasetsComponent.getResults(this.keyword, false, 1, 10);
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets() + this.keyword; this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets() + this.keyword;
} }
} }
@ -206,7 +206,7 @@ export class SearchComponent {
this.activeTab = "datproviders"; this.activeTab = "datproviders";
if(this.reloadDataproviders) { if(this.reloadDataproviders) {
this.reloadDataproviders = false; this.reloadDataproviders = false;
this.searchDataProvidersComponent.getResults(this.keyword, 1, 10, "searchPage"); this.searchDataProvidersComponent.getResults(this.keyword, false, 1, 10);
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders() + this.keyword; this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders() + this.keyword;
} }
} }
@ -214,7 +214,7 @@ export class SearchComponent {
this.activeTab = "organizations"; this.activeTab = "organizations";
if(this.reloadOrganizations) { if(this.reloadOrganizations) {
this.reloadOrganizations = false; this.reloadOrganizations = false;
this.searchOrganizationsComponent.getResults(this.keyword, 1, 10); this.searchOrganizationsComponent.getResults(this.keyword, false, 1, 10);
this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations() + this.keyword; this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations() + this.keyword;
} }
} }
@ -222,7 +222,7 @@ export class SearchComponent {
this.activeTab = "people"; this.activeTab = "people";
if(this.reloadPeople) { if(this.reloadPeople) {
this.reloadPeople = false; this.reloadPeople = false;
this.searchPeopleComponent.getResults(this.keyword, 1, 10); this.searchPeopleComponent.getResults(this.keyword, false, 1, 10);
this.linkToSearchPeople = OpenaireProperties.getLinkToSearchPeople() + this.keyword; this.linkToSearchPeople = OpenaireProperties.getLinkToSearchPeople() + this.keyword;
} }
} }

View File

@ -55,7 +55,7 @@ export class SearchDataprovidersComponent {
this.page = (params['page']=== undefined)?1:+params['page']; this.page = (params['page']=== undefined)?1:+params['page'];
this.filters = this.createFilters(); this.filters = this.createFilters();
this.getResults(this.keyword, this.page, this.size, "searchPage"); this.getResults(this.keyword, true, this.page, this.size);
}); });
} }
@ -63,6 +63,75 @@ export class SearchDataprovidersComponent {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
public getResultsForEntity(entity:string, id:string, page: number, size: number){
var parameters = "";
if(entity == "organization") {
parameters = "organizations/"+id;
}
if(parameters != "") {
this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [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 getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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 getResults(parameters:string, page: number, size: number, flag: string){ public getResults(parameters:string, page: number, size: number, flag: string){
console.log("Search Dataproviders: Execute search query "+parameters); console.log("Search Dataproviders: Execute search query "+parameters);
@ -89,14 +158,14 @@ export class SearchDataprovidersComponent {
} }
); );
} }
*/
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
} }
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
this.getResults(parameters, this.page, this.size, "searchPage"); this._getResults(parameters, true, this.page, this.size);
} }
private createFilters():Filter[] { private createFilters():Filter[] {

View File

@ -55,8 +55,9 @@ export class SearchDatasetsComponent {
this.keyword = (params['keyword']?params['keyword']:''); this.keyword = (params['keyword']?params['keyword']:'');
this.page = (params['page']=== undefined)?1:+params['page']; this.page = (params['page']=== undefined)?1:+params['page'];
// this.getRefineResults(); // this.getRefineResults();
this.getResults(this.keyword, this.page, this.size, "searchPage"); //this.getResults(this.keyword, this.page, this.size, "searchPage");
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.keyword, true, this.page, this.size);
}); });
} }
@ -82,6 +83,8 @@ export class SearchDatasetsComponent {
} }
); );
} }
/*
public getResults(parameters:string, page: number, size: number, flag: string){ public getResults(parameters:string, page: number, size: number, flag: string){
console.info("Search Datasets: Execute search query "+parameters); console.info("Search Datasets: Execute search query "+parameters);
if(flag == 'searchPage' || flag == 'claim') { if(flag == 'searchPage' || flag == 'claim') {
@ -111,6 +114,80 @@ export class SearchDatasetsComponent {
} }
); );
} }
*/
public getResultsForEntity(entity:string, id:string, page: number, size: number){
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id;
} else if(entity == "person") {
parameters = "people/"+id;
} else if(entity == "dataprovider") {
parameters = "datasources/"+id;
}
if(parameters != "") {
this._searchDatasetsService.searchDatasetsForEntity(parameters, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("search Datasets for "+entity+": [Parameters:"+parameters+" ] [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 getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchDatasetsService.searchDatasets(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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;
}
);
}
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
@ -118,6 +195,7 @@ export class SearchDatasetsComponent {
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
this.getResults(parameters, this.page, this.size, "searchPage"); //this.getResults(parameters, this.page, this.size, "searchPage");
this._getResults(parameters, true, this.page, this.size);
} }
} }

View File

@ -57,13 +57,15 @@ export class SearchOrganizationsComponent {
this.page = (params['page']=== undefined)?1:+params['page']; this.page = (params['page']=== undefined)?1:+params['page'];
this.getRefineResults(); this.getRefineResults();
this.getResults(this.keyword, this.page, this.size); this.getResults(this.keyword, true, this.page, this.size);
}); });
} }
private ngOnDestroy() { private ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
public getRefineResults (){ public getRefineResults (){
// this._refineResultsService.getRefineResults(this.searchPage.getFields()).subscribe( // this._refineResultsService.getRefineResults(this.searchPage.getFields()).subscribe(
this._refineResultsService.getRefineResults(["projectendyear","projectstartyear","funderid","projectecsc39"]).subscribe( this._refineResultsService.getRefineResults(["projectendyear","projectstartyear","funderid","projectecsc39"]).subscribe(
@ -83,6 +85,7 @@ export class SearchOrganizationsComponent {
} }
); );
} }
/*
public getResults(parameters:string, page: number, size: number){ public getResults(parameters:string, page: number, size: number){
console.info("getResults: Execute search query "+parameters); console.info("getResults: Execute search query "+parameters);
@ -110,6 +113,79 @@ export class SearchOrganizationsComponent {
); );
} }
*/
public getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchOrganizationsService.searchOrganizations(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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 getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchOrganizationsService.searchOrganizations(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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;
}
);
}
*/
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
} }
@ -117,6 +193,6 @@ export class SearchOrganizationsComponent {
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters); console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size); this._getResults(parameters, true, this.page, this.size);
} }
} }

View File

@ -91,7 +91,7 @@ export class SearchPeopleComponent {
}); });
var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'} var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
this.filters.push(filter1); this.filters.push(filter1);
this.getResults(this.keyword, this.page, this.size); this.getResults(this.keyword, true, this.page, this.size);
} }
@ -117,7 +117,7 @@ export class SearchPeopleComponent {
private ngOnDestroy() { private ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
/*
public getResults(parameters:string, page: number, size: number){ public getResults(parameters:string, page: number, size: number){
console.info("getResults: Execute search query "+parameters); console.info("getResults: Execute search query "+parameters);
@ -144,6 +144,41 @@ export class SearchPeopleComponent {
} }
); );
} }
*/
public getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchPeopleService.searchPeople(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search People: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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;
}
);
}
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
@ -152,7 +187,7 @@ export class SearchPeopleComponent {
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters); console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size); this._getResults(parameters, true, this.page, this.size);
} }

View File

@ -92,7 +92,7 @@ export class SearchPublicationsComponent {
}); });
var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'} var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
this.filters.push(filter1); this.filters.push(filter1);
this.getResults(this.keyword, this.page, this.size, "searchPage"); this.getResults(this.keyword, true, this.page, this.size);
} }
@ -118,7 +118,7 @@ export class SearchPublicationsComponent {
private ngOnDestroy() { private ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
/*
public getResults(parameters:string, page: number, size: number, flag: string){ public getResults(parameters:string, page: number, size: number, flag: string){
console.info("getResults: Execute search query "+parameters); console.info("getResults: Execute search query "+parameters);
@ -145,6 +145,79 @@ export class SearchPublicationsComponent {
} }
); );
} }
*/
public getResultsForEntity(entity:string, id:string, page: number, size: number){
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id;
} else if(entity == "person") {
parameters = "people/"+id;
} else if(entity == "dataprovider") {
parameters = "datasources/"+id;
}
if(parameters != "") {
this._searchPublicationsService.searchPublicationsForEntity(parameters, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("search Datasets for "+entity+": [Parameters:"+parameters+" ] [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 getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + keyword + "&op=and";
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
this._searchPublicationsService.searchPublications(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
data => {
this.totalResults = data[0];
console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]");
this.results = data[1];
this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
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;
}
);
}
private setFilters(){ private setFilters(){
//TODO set filters from //TODO set filters from
@ -153,7 +226,7 @@ export class SearchPublicationsComponent {
private queryChanged($event) { private queryChanged($event) {
var parameters = $event.value; var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters); console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size, "searchPage"); this._getResults(parameters, true, this.page, this.size);
} }

View File

@ -62,11 +62,11 @@ export class SearchPageComponent {
private sub: any; private sub: any;
constructor (private location: Location ) { constructor (private location: Location ) {
console.info("constructor of SearchPage");
} }
ngOnInit() { ngOnInit() {
console.info("ngOnInit of SearchPage");
} }
ngAfterViewChecked(){ ngAfterViewChecked(){
@ -165,7 +165,7 @@ export class SearchPageComponent {
// if(this.keyword.length > 0 ){ // if(this.keyword.length > 0 ){
// allLimits= this.keyword + allLimits /*+ ' keyword=' */; // allLimits= this.keyword + allLimits /*+ ' keyword=' */;
// } // }
return (this.keyword.length > 0?'q='+this.keyword+"op=and":'')+allLimits; return (this.keyword.length > 0?'q='+this.keyword+"&op=and":'')+allLimits;
} }
// //
private isFiltered(){ private isFiltered(){

View File

@ -100,10 +100,12 @@ export class ProjectService {
name = data[2].legalname; name = data[2].legalname;
} }
if(data[2].hasOwnProperty("to")) { if(data[2].hasOwnProperty("to") && name != "") {
url = OpenaireProperties.getsearchLinkToOrganization()+data[2]['to'].content; url = OpenaireProperties.getsearchLinkToOrganization()+data[2]['to'].content;
} }
if(name != "") {
this.projectInfo.organizations.set(name, url); this.projectInfo.organizations.set(name, url);
}
} else { } else {
for(let i=0; i<data[2].length; i++) { for(let i=0; i<data[2].length; i++) {
if(data[2][i].hasOwnProperty("legalshortname")) { if(data[2][i].hasOwnProperty("legalshortname")) {
@ -112,13 +114,16 @@ export class ProjectService {
name = data[2][i].legalname; name = data[2][i].legalname;
} }
if(data[2][i].hasOwnProperty("to")) { if(data[2][i].hasOwnProperty("to") && name!="") {
url = OpenaireProperties.getsearchLinkToOrganization()+data[2][i]['to'].content; url = OpenaireProperties.getsearchLinkToOrganization()+data[2][i]['to'].content;
} }
if(name != "") {
this.projectInfo.organizations.set(name, url); this.projectInfo.organizations.set(name, url);
} }
} }
} }
}
if(this.projectInfo.funder == "EC") { if(this.projectInfo.funder == "EC") {
this.projectInfo.url = OpenaireProperties.getCordisURL()+this.projectInfo.contractNum; this.projectInfo.url = OpenaireProperties.getCordisURL()+this.projectInfo.contractNum;

View File

@ -325,11 +325,11 @@ export class PublicationService {
if(data[3].hasOwnProperty("externalreference")) { if(data[3].hasOwnProperty("externalreference")) {
this.publicationInfo.bioentities = new Map<string, Map<string, string>>(); this.publicationInfo.bioentities = new Map<string, Map<string, string>>();
let length = data[3]['externalreference'].length!=undefined ? data[3]['externalreference'].length : 1; let length = Array.isArray(data[3]['externalreference']) ? data[3]['externalreference'].length : 1;
let mydata; let mydata;
for(let i=0; i<length; i++) { for(let i=0; i<length; i++) {
mydata = length > 1 ? data[3]['externalreference'][i] : data[3]['externalreference']; mydata = Array.isArray(data[3]['externalreference']) ? data[3]['externalreference'][i] : data[3]['externalreference'];
if(!this.publicationInfo.bioentities.has(mydata.sitename)) { if(!this.publicationInfo.bioentities.has(mydata.sitename)) {
this.publicationInfo.bioentities.set(mydata.sitename, new Map<string, string>()); this.publicationInfo.bioentities.set(mydata.sitename, new Map<string, string>());

View File

@ -3,39 +3,41 @@ import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../utils/properties/openaireProperties'; import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {SearchResult} from '../utils/entities/searchResult'; import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
@Injectable() @Injectable()
export class SearchDataprovidersService { export class SearchDataprovidersService {
constructor(private http: Http) {} constructor(private http: Http) {}
searchDataproviders (params: string, page: number, size: number, flag: string):any { searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
console.info("In searchDataproviders"); let link = OpenaireProperties.getSearchAPIURL()+"datasources";
let link, url; let url = link+"?";
if(params!= null && params != '' ) {
if(flag == "searchPage") { url += params;
link = OpenaireProperties.getSearchAPIURL()+"datasources";
url = link+"?";
if(params != '') {
url += params+"&page="+page+"&size="+size;
} else {
url += "page="+page+"&size="+size;
} }
} else if(flag == 'organizationPage') { if(refineParams!= null && params != '' ) {
url = OpenaireProperties.getSearchAPIURL() + 'organizations/'+params+"/datasources"; url += refineParams;
} }
url += "&page="+page+"&size="+size;
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.do(res => console.info(res)) //.do(res => console.info(res))
//.map(res => []); .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
.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";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];

View File

@ -11,36 +11,35 @@ export class SearchDatasetsService {
constructor(private http: Http) {} constructor(private http: Http) {}
searchDatasets (params: string, page: number, size: number, flag: string, refineFields:string[] ):any { searchDatasets (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
let link, url; let link = OpenaireProperties.getSearchAPIURL()+"datasets";
if(flag == 'searchPage' || flag == 'claim') { let url = link+"?";
link = OpenaireProperties.getSearchAPIURL()+"datasets"; if(params!= null && params != '' ) {
url += params;
url = link+"?";
if(params != '') {
url += params+"&page="+page+"&size="+size;
} else {
url += "page="+page+"&size="+size;
} }
} else if(flag == 'personPage') { if(refineParams!= null && params != '' ) {
url = OpenaireProperties.getSearchAPIURL() + 'people/'+params+"/datasets"; url += refineParams;
} else if(flag == 'projectPage') {
url = OpenaireProperties.getSearchAPIURL() + 'projects/'+params+"/datasets";
} else if(flag == 'dataproviderPage') {
url = OpenaireProperties.getSearchAPIURL() + 'datasources/'+params+"/datasets";
} }
url += "&page="+page+"&size="+size;
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.do(res => console.info(res)) //.do(res => console.info(res))
//.map(res => []); .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)])
;
} }
searchDatasetsForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURL();
let url = link+params+"/datasets";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];

View File

@ -3,36 +3,35 @@ import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../utils/properties/openaireProperties'; import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {SearchResult} from '../utils/entities/searchResult'; import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
@Injectable() @Injectable()
export class SearchOrganizationsService { export class SearchOrganizationsService {
constructor(private http: Http) {} constructor(private http: Http) {}
searchOrganizations (params: string, page: number, size: number):any { searchOrganizations (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
console.info("In searchOrganizations"); console.info("In searchProjects");
let link, url; let link = OpenaireProperties.getSearchAPIURL()+"organizations";
link = OpenaireProperties.getSearchAPIURL()+"organizations"; let url = link+"?";
if(params!= null && params != '' ) {
url = link+"?"; url += params;
if(params != '') {
url += params+"&page="+page+"&size="+size;
} else {
url += "page="+page+"&size="+size;
} }
if(refineParams!= null && params != '' ) {
url += refineParams;
}
url += "&page="+page+"&size="+size;
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.do(res => console.info(res)) //.do(res => console.info(res))
//.map(res => []); .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
.map(res => [res['meta'].total, this.parseResults(res['results'])])
;
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];

View File

@ -3,34 +3,35 @@ import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../utils/properties/openaireProperties'; import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {SearchResult} from '../utils/entities/searchResult'; import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
@Injectable() @Injectable()
export class SearchPeopleService { export class SearchPeopleService {
constructor(private http: Http) {} constructor(private http: Http) {}
searchPeople (params: string, page: number, size: number):any { searchPeople (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
console.info("In searchPeople"); console.info("In searchProjects");
let link = OpenaireProperties.getSearchAPIURL()+"people"; let link = OpenaireProperties.getSearchAPIURL()+"people";
let url = link+"?"; let url = link+"?";
if(params != '') { if(params!= null && params != '' ) {
url += params+"&page="+page+"&size="+size; url += params;
} else {
url += "page="+page+"&size="+size;
} }
if(refineParams!= null && params != '' ) {
url += refineParams;
}
url += "&page="+page+"&size="+size;
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
.do(res => console.info(res)) //.do(res => console.info(res))
//.map(res => []); .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
.map(res => [res['meta'].total, this.parseResults(res['results'])])
;
} }
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];

View File

@ -3,6 +3,7 @@ import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../utils/properties/openaireProperties'; import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {SearchResult} from '../utils/entities/searchResult'; import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
@Injectable() @Injectable()
export class SearchPublicationsService { export class SearchPublicationsService {
@ -10,37 +11,35 @@ export class SearchPublicationsService {
constructor(private http: Http) {} constructor(private http: Http) {}
searchPublications (params: string, page: number, size: number, flag: string):any { searchPublications (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
console.info("In searchPublications"); let link = OpenaireProperties.getSearchAPIURL()+"publications";
let link, url; let url = link+"?";
if(params!= null && params != '' ) {
if(flag == 'searchPage' || flag == 'claim') { url += params;
link = OpenaireProperties.getSearchAPIURL()+"publications";
url = link+"?";
if(params != '') {
url += params+"&page="+page+"&size="+size;
} else {
url += "page="+page+"&size="+size;
} }
} else if(flag == 'projectPage') { if(refineParams!= null && params != '' ) {
url = OpenaireProperties.getSearchAPIURL() + 'projects/'+params+"/publications"; url += refineParams;
} else if(flag == 'dataproviderPage') {
url = OpenaireProperties.getSearchAPIURL() + 'datasources/'+params+"/publications";
} else if(flag == 'personPage') {
url = OpenaireProperties.getSearchAPIURL() + 'people/'+params+"/publications";
} }
url += "&page="+page+"&size="+size;
return this.http.get(url) return this.http.get(url)
.map(res => <any> res.json()) .map(res => <any> res.json())
//.do(res => console.info(res)) //.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])]) .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields)]);
;
} }
searchPublicationsForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURL();
let url = link+params+"/publications";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
parseResults(data: any): SearchResult[] { parseResults(data: any): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];