[Trunk | Library]: Delete all unnecessary files (simple search, advanced search, search service, landing entity-info, fetch class), after merging research results (publication, dataset, software, other).
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57033 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
cde4550dfc
commit
32b3c3f6c0
|
@ -1,198 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AdvancedField} from '../searchUtils/searchHelperClasses.class';
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'advanced-search-datasets',
|
||||
template: `
|
||||
<advanced-search-page pageTitle="Advanced Search for Research Data" entityType="dataset"
|
||||
type = "research data"
|
||||
[(results)] = "results"
|
||||
[(searchUtils)] = "searchUtils"
|
||||
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||
(queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="datasets" simpleSearchLink="/search/find/datasets"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
searchFormClass="datasetsSearchForm"
|
||||
[(sort)]=sort >
|
||||
</advanced-search-page>
|
||||
|
||||
`
|
||||
})
|
||||
|
||||
export class AdvancedSearchDatasetsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
properties:EnvProperties;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
|
||||
public results =[];
|
||||
public filters =[];
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
|
||||
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
||||
public fieldIdsMap= this.searchFields.RESULT_FIELDS;
|
||||
public selectedFields:AdvancedField[] = [];
|
||||
|
||||
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
|
||||
public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact dataset) )";
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
public pagingLimit: number = 0;
|
||||
public sort: boolean = true;
|
||||
public isPiwikEnabled;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
this.results =[];
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties= data.envSpecific;
|
||||
this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedDatasets;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
|
||||
});
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
let page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.page = ( page <= 0 ) ? 1 : page;
|
||||
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields =[];
|
||||
this.searchPage.selectedFields = this.selectedFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
this.searchPage.getSelectedFiltersFromUrl(params);
|
||||
this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
sub: any;
|
||||
public getResults(parameters:string, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
if(parameters!= null && parameters != '' ) {
|
||||
this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
|
||||
}else{
|
||||
this.csvParams ="&fq="+this.resourcesQuery;
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
//this.searchPage.openLoading();
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
//console.info("Advanced Search for Research Data: Execute search query "+parameters);
|
||||
this._searchResearchResultsService.advancedSearch("dataset", parameters, page, size, sortBy, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
this.searchPage.updateBaseUrlWithParameters();
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting research data", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = errorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page,this.searchUtils.size, this.searchUtils.sortBy);
|
||||
//console.info("queryChanged: Execute search query "+parameters);
|
||||
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Research Data advanced Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component';
|
||||
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
AdvancedSearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
AdvancedSearchDatasetsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
AdvancedSearchDatasetsComponent
|
||||
]
|
||||
})
|
||||
export class AdvancedSearchDatasetsModule { }
|
|
@ -1,189 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AdvancedField} from '../searchUtils/searchHelperClasses.class';
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'advanced-search-orps',
|
||||
template: `
|
||||
<advanced-search-page pageTitle="Advanced Search for Other Research Products" entityType="other"
|
||||
type = "other research products"
|
||||
[(results)] = "results"
|
||||
[(searchUtils)] = "searchUtils"
|
||||
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||
(queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="other" simpleSearchLink="/search/find/other"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
searchFormClass="orpsSearchForm"
|
||||
[(sort)]=sort >
|
||||
</advanced-search-page>
|
||||
|
||||
`
|
||||
})
|
||||
|
||||
export class AdvancedSearchOrpsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
properties:EnvProperties;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
|
||||
public results =[];
|
||||
public filters =[];
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
|
||||
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
||||
public fieldIdsMap= this.searchFields.RESULT_FIELDS;
|
||||
public selectedFields:AdvancedField[] = [];
|
||||
|
||||
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
|
||||
public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact other) )";
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
public pagingLimit: number = 0;
|
||||
public sort: boolean = true;
|
||||
public isPiwikEnabled;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
this.results =[];
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties= data.envSpecific;
|
||||
this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedOrps;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
|
||||
});
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
let page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.page = ( page <= 0 ) ? 1 : page;
|
||||
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields =[];
|
||||
this.searchPage.selectedFields = this.selectedFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
this.searchPage.getSelectedFiltersFromUrl(params);
|
||||
this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
sub: any;
|
||||
public getResults(parameters:string, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
if(parameters!= null && parameters != '' ) {
|
||||
this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
|
||||
}else{
|
||||
this.csvParams ="&fq="+this.resourcesQuery;
|
||||
}
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
//console.info("Advanced Search for Other Research Products: Execute search query "+parameters);
|
||||
this._searchResearchResultsService.advancedSearch("other", parameters, page, size, sortBy, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
this.searchPage.updateBaseUrlWithParameters();
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting other research products", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page,this.searchUtils.size, this.searchUtils.sortBy);
|
||||
//console.info("queryChanged: Execute search query "+parameters);
|
||||
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Other Research Products advanced Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import{AdvancedSearchOrpsComponent} from './advancedSearchOrps.component';
|
||||
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
AdvancedSearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
AdvancedSearchOrpsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
AdvancedSearchOrpsComponent
|
||||
]
|
||||
})
|
||||
export class AdvancedSearchOrpsModule { }
|
|
@ -1,200 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import { Router, ActivatedRoute} from '@angular/router';
|
||||
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
|
||||
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'advanced-search-publications',
|
||||
template: `
|
||||
<advanced-search-page pageTitle="Advanced Search for Publications" entityType="publication"
|
||||
type="publications"
|
||||
[(results)] = "results"
|
||||
[(searchUtils)] = "searchUtils"
|
||||
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||
(queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="publications" simpleSearchLink="/search/find/publications"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[(openaireLink)]=openaireLink
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
searchFormClass="publicationsSearchForm"
|
||||
[(sort)]=sort >
|
||||
</advanced-search-page>
|
||||
`
|
||||
})
|
||||
|
||||
export class AdvancedSearchPublicationsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results =[];
|
||||
public filters =[];
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
|
||||
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
||||
public fieldIdsMap= this.searchFields.RESULT_FIELDS;
|
||||
public selectedFields:AdvancedField[] = [];
|
||||
public resourcesQuery = "((oaftype exact result) and (resulttypeid exact publication))";
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
@Input() openaireLink: string ;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
public pagingLimit: number = 0;
|
||||
public isPiwikEnabled;
|
||||
public sort: boolean = true;
|
||||
properties:EnvProperties;
|
||||
|
||||
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
|
||||
|
||||
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.results =[];
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties= data.envSpecific;
|
||||
this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedPublications;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
|
||||
});
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
let page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.page = ( page <= 0 ) ? 1 : page;
|
||||
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields =[];
|
||||
this.searchPage.selectedFields = this.selectedFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
this.searchPage.getSelectedFiltersFromUrl(params);
|
||||
this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
sub: any;
|
||||
public getResults(parameters:string, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
if(parameters!= null && parameters != '' ) {
|
||||
this.csvParams ="&fq=("+this.resourcesQuery +" and (" + parameters + "))";
|
||||
}else{
|
||||
this.csvParams ="&fq="+this.resourcesQuery;
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
//this.searchPage.openLoading();
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
//console.info("Advanced Search for Publications: Execute search query "+parameters);
|
||||
this._searchResearchResultsService.advancedSearch("publication", parameters, page, size, sortBy, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
this.searchPage.updateBaseUrlWithParameters();
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting publications", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page,this.searchUtils.size, this.searchUtils.sortBy);
|
||||
//console.info("queryChanged: Execute search query "+parameters);
|
||||
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Publications advanced Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component';
|
||||
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
AdvancedSearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
AdvancedSearchPublicationsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
AdvancedSearchPublicationsComponent
|
||||
]
|
||||
})
|
||||
export class AdvancedSearchPublicationsModule { }
|
|
@ -1,198 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AdvancedField} from '../searchUtils/searchHelperClasses.class';
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'advanced-search-software',
|
||||
template: `
|
||||
<advanced-search-page pageTitle="Advanced Search for Software" entityType="software"
|
||||
type = "software"
|
||||
[(results)] = "results"
|
||||
[(searchUtils)] = "searchUtils"
|
||||
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||
(queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="software" simpleSearchLink="/search/find/software"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
searchFormClass="softwareSearchForm"
|
||||
[(sort)]=sort >
|
||||
</advanced-search-page>
|
||||
|
||||
`
|
||||
})
|
||||
|
||||
export class AdvancedSearchSoftwareComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
public results =[];
|
||||
public filters =[];
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
|
||||
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
||||
public fieldIdsMap= this.searchFields.RESULT_FIELDS;
|
||||
public selectedFields:AdvancedField[] = [];
|
||||
|
||||
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
|
||||
public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact software) )";
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
public pagingLimit: number = 0;
|
||||
public isPiwikEnabled;
|
||||
public sort: boolean = true;
|
||||
properties:EnvProperties;
|
||||
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
this.results =[];
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties= data.envSpecific;
|
||||
this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedSoftware;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
|
||||
});
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
let page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.page = ( page <= 0 ) ? 1 : page;
|
||||
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields =[];
|
||||
this.searchPage.selectedFields = this.selectedFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
this.searchPage.getSelectedFiltersFromUrl(params);
|
||||
this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
sub: any;
|
||||
public getResults(parameters:string, page: number, size: number, sortBy: string){
|
||||
if(page >this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
if(parameters!= null && parameters != '' ) {
|
||||
this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
|
||||
}else{
|
||||
this.csvParams ="&fq="+this.resourcesQuery;
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
//this.searchPage.openLoading();
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
//console.info("Advanced Search for Software: Execute search query "+parameters);
|
||||
this._searchResearchResultsService.advancedSearch("software", parameters, page, size, sortBy, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
this.searchPage.updateBaseUrlWithParameters();
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting software", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = errorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page,this.searchUtils.size, this.searchUtils.sortBy);
|
||||
//console.info("queryChanged: Execute search query "+parameters);
|
||||
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Software advanced Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import{AdvancedSearchSoftwareComponent} from './advancedSearchSoftware.component';
|
||||
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
AdvancedSearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
AdvancedSearchSoftwareComponent
|
||||
],
|
||||
providers:[FreeGuard
|
||||
],
|
||||
exports: [
|
||||
AdvancedSearchSoftwareComponent
|
||||
]
|
||||
})
|
||||
export class AdvancedSearchSoftwareModule { }
|
|
@ -1,318 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
import {Filter} from '../searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-datasets',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Research Data"
|
||||
formPlaceholderText = "Search for Research Data"
|
||||
type="research data" entityType="dataset" [(filters)] = "filters"
|
||||
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
||||
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="datasets" advancedSearchLink="/search/advanced/datasets"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[searchFormClass]="customFilter && customFilter.queryFieldName == 'communityId' ?
|
||||
'communityPanelBackground' : 'datasetsSearchForm'"
|
||||
[(openaireLink)]=openaireLink
|
||||
[(advancedSearchParameters)]=advancedSearchParameters
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
[(sort)]=sort >
|
||||
</search-page>
|
||||
<!--[(sortBy)]="sortBy"-->
|
||||
`
|
||||
})
|
||||
|
||||
export class SearchDatasetsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results =[];
|
||||
public filters: Filter[] =[];
|
||||
// public totalResults:number = 0 ;
|
||||
public baseUrl:string;
|
||||
@Input() openaireLink: string ;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
@Input() advancedSearchParameters ;
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
private searchFields:SearchFields = new SearchFields();
|
||||
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
||||
private urlParams : Map<string, string>;
|
||||
private _location:Location;
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
pagingLimit = 0;
|
||||
//public sortBy: string = "";
|
||||
public sort: boolean = true;
|
||||
properties: EnvProperties;
|
||||
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.searchUtils.page =1;
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.baseUrl = data.envSpecific.searchLinkToDatasets;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
|
||||
});
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.type = "research data";
|
||||
var firstLoad =true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
||||
var refine = true;
|
||||
if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
||||
refine = false;
|
||||
}
|
||||
firstLoad = false;
|
||||
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
||||
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number){
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("dataset", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting research data for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "datasets?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "datasets?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("dataset", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Research Data for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting research data for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResults(keyword:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + keyword;
|
||||
}
|
||||
}
|
||||
this._getResults(parameters,refine,page,size,sortBy);
|
||||
}
|
||||
private _getResults(parameters:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
this.csvParams = parameters;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
//this.searchPage.openLoading();
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.search("dataset", parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, sortBy, this.searchPage.getFields(), this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Research Data: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
if(refine){
|
||||
this.filters = data[2];
|
||||
}
|
||||
this.searchPage.checkSelectedFilters(this.filters);
|
||||
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting research data", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage");
|
||||
//this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Research Data simple Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchDatasetsComponent} from './searchDatasets.component';
|
||||
|
||||
import {SearchResultsModule } from '../searchUtils/searchResults.module';
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {SearchFormModule} from '../searchUtils/searchForm.module';
|
||||
import {SearchPageModule} from '../searchUtils/searchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
SearchFormModule, SearchResultsModule, SearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
SearchDatasetsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
SearchDatasetsComponent
|
||||
]
|
||||
})
|
||||
export class SearchDatasetsModule { }
|
|
@ -1,295 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
import {Filter} from '../searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-orps',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Other Research Products"
|
||||
formPlaceholderText = "Search for Other Research Products"
|
||||
type="other research products" entityType="other" [(filters)] = "filters"
|
||||
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
||||
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="other" advancedSearchLink="/search/advanced/other"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[searchFormClass]="customFilter && customFilter.queryFieldName == 'communityId' ?
|
||||
'communityPanelBackground' : 'orpsSearchForm'"
|
||||
[(openaireLink)]=openaireLink
|
||||
[(advancedSearchParameters)]=advancedSearchParameters
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
[(sort)]=sort >
|
||||
</search-page>
|
||||
`
|
||||
})
|
||||
|
||||
export class SearchOrpsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results =[];
|
||||
public filters: Filter[] =[];
|
||||
public baseUrl:string;
|
||||
@Input() openaireLink: string ;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
@Input() advancedSearchParameters ;
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
private searchFields:SearchFields = new SearchFields();
|
||||
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
||||
private urlParams : Map<string, string>;
|
||||
private _location:Location;
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
pagingLimit = 0;
|
||||
public sort: boolean = true;
|
||||
properties: EnvProperties;
|
||||
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.searchUtils.page =1;
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.baseUrl = data.envSpecific.searchLinkToOrps;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
|
||||
});
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.type = "other research products";
|
||||
var firstLoad =true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
||||
var refine = true;
|
||||
if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
||||
refine = false;
|
||||
}
|
||||
firstLoad = false;
|
||||
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
||||
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number){
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("other", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Other Research Products for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting other research products for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "orps?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "orps?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("other", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Other Research Products for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting other research products for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResults(keyword:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + keyword;
|
||||
}
|
||||
}
|
||||
this._getResults(parameters,refine,page,size,sortBy);
|
||||
}
|
||||
private _getResults(parameters:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
this.csvParams = parameters;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.search("other", parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, sortBy, this.searchPage.getFields(), this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Other Research Products: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
if(refine){
|
||||
this.filters = data[2];
|
||||
}
|
||||
this.searchPage.checkSelectedFilters(this.filters);
|
||||
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting other research products", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Other Research Products simple Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchOrpsComponent} from './searchOrps.component';
|
||||
|
||||
import {SearchResultsModule } from '../searchUtils/searchResults.module';
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {SearchFormModule} from '../searchUtils/searchForm.module';
|
||||
import {SearchPageModule} from '../searchUtils/searchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
SearchFormModule, SearchResultsModule, SearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
SearchOrpsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
SearchOrpsComponent
|
||||
]
|
||||
})
|
||||
export class SearchOrpsModule { }
|
|
@ -1,347 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchPageComponent} from '../searchUtils/searchPage.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-publications',
|
||||
template: `
|
||||
<!-- [searchFormClass]="customFilter.queryFieldName == 'communityId' ? 'communityPanelBackground' : 'publicationsSearchForm'"-->
|
||||
|
||||
<search-page pageTitle="Search Publications"
|
||||
formPlaceholderText = "Search for Publications"
|
||||
type="publications" entityType="publication"
|
||||
[(filters)] = "filters" [(results)] = "results"
|
||||
[(searchUtils)] = "searchUtils" [(baseUrl)] = baseUrl
|
||||
(queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="publications"
|
||||
advancedSearchLink="/search/advanced/publications"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[searchFormClass]="customFilter && customFilter.queryFieldName == 'communityId' ?
|
||||
'communityPanelBackground' : 'publicationsSearchForm'"
|
||||
[(openaireLink)]=openaireLink
|
||||
[(advancedSearchParameters)]=advancedSearchParameters
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
[(sort)]=sort >
|
||||
</search-page>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class SearchPublicationsComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results =[];
|
||||
public filters =[];
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
public baseUrl:string = "";
|
||||
public sub: any;
|
||||
public subResults: any;
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
||||
//: { [key:string] :{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PUBLICATION_FIELDS_MAP;
|
||||
public urlParams : Map<string, string>;
|
||||
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||
public _location:Location;
|
||||
|
||||
public CSV: any = { "columnNames": ["Title", "Authors", "Publication Year", "DOI",
|
||||
/*"Download From", "Publication type", "Journal",*/
|
||||
"Funder", "Project Name (GA Number)", "Access"],
|
||||
"export":[]
|
||||
};
|
||||
public CSVDownloaded = false;
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
@Input() openaireLink: string;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
@Input() advancedSearchParameters ;
|
||||
pagingLimit = 0;
|
||||
public sort: boolean = true;
|
||||
properties: EnvProperties;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.searchUtils.page =1;
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.baseUrl = data.envSpecific.searchLinkToPublications;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
|
||||
});
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.type = "publications";
|
||||
var firstLoad =true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
||||
var refine = true;
|
||||
if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
||||
refine = false;
|
||||
|
||||
}
|
||||
firstLoad = false;
|
||||
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
||||
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number){
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("publication", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting publications for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "publications?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "publications?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("publication", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting publications for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResults(keyword:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + keyword;
|
||||
}
|
||||
}
|
||||
this._getResults(parameters,refine,page,size,sortBy);
|
||||
}
|
||||
|
||||
private _getResults(parameters:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
this.csvParams = parameters;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.search("publication", parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, sortBy, this.searchPage.getFields(), this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
if(refine){
|
||||
this.filters = data[2];
|
||||
}
|
||||
this.searchPage.checkSelectedFilters(this.filters);
|
||||
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting publications", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
public getAggregatorResults(id:string, page: number, size: number){
|
||||
this.subResults = this._searchPublicationsService.searchAggregators('&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = errorCodes.ERROR;
|
||||
}
|
||||
);
|
||||
}*/
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//console.info("queryChanged: Execute search query "+parameters);
|
||||
//this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Publications simple Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import{SearchPublicationsComponent} from './searchPublications.component';
|
||||
|
||||
import {SearchResultsModule } from '../searchUtils/searchResults.module';
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {SearchFormModule} from '../searchUtils/searchForm.module';
|
||||
//import {SearchFilterModalModule} from '../searchUtils/searchFilterModal.module';
|
||||
import {SearchPageModule} from '../searchUtils/searchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
|
||||
SearchResearchResultsServiceModule,
|
||||
SearchFormModule, SearchResultsModule, SearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
SearchPublicationsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
SearchPublicationsComponent
|
||||
]
|
||||
})
|
||||
export class SearchPublicationsModule { }
|
|
@ -1,318 +0,0 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
import {Filter} from '../searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchFields} from '../../utils/properties/searchFields';
|
||||
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-software',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Software"
|
||||
formPlaceholderText = "Search for Software"
|
||||
type="software" entityType="software" [(filters)] = "filters"
|
||||
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
||||
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
|
||||
[csvParams]="csvParams" csvPath="software" advancedSearchLink="/search/advanced/software"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[searchFormClass]="customFilter && customFilter.queryFieldName == 'communityId' ?
|
||||
'communityPanelBackground' : 'softwareSearchForm'"
|
||||
[(openaireLink)]=openaireLink
|
||||
[(advancedSearchParameters)]=advancedSearchParameters
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
[(sort)]=sort >
|
||||
</search-page>
|
||||
`
|
||||
})
|
||||
|
||||
export class SearchSoftwareComponent {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() openaireLink: string ;
|
||||
@Input() customFilter:SearchCustomFilter= null;
|
||||
@Input() advancedSearchParameters ;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results =[];
|
||||
public filters: Filter[] =[];
|
||||
// public totalResults:number = 0 ;
|
||||
public baseUrl:string;
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
private searchFields:SearchFields = new SearchFields();
|
||||
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
||||
private urlParams : Map<string, string>;
|
||||
private _location:Location;
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
pagingLimit = 0;
|
||||
public sort: boolean = true;
|
||||
properties: EnvProperties;
|
||||
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||
constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.searchUtils.page =1;
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.baseUrl = data.envSpecific.searchLinkToSoftware;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
|
||||
});
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.type = "software";
|
||||
var firstLoad =true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if(params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
|
||||
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
||||
var refine = true;
|
||||
if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
||||
refine = false;
|
||||
}
|
||||
firstLoad = false;
|
||||
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:'';
|
||||
if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
||||
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number){
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("software", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting software for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "software?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "software?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("software", parameters, page, size, this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting software for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResults(keyword:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + keyword;
|
||||
}
|
||||
}
|
||||
this._getResults(parameters,refine,page,size,sortBy);
|
||||
}
|
||||
private _getResults(parameters:string,refine:boolean, page: number, size: number, sortBy: string){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
this.csvParams = parameters;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
//this.searchPage.openLoading();
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.search("software", parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, sortBy, this.searchPage.getFields(), this.properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
if(refine){
|
||||
this.filters = data[2];
|
||||
}
|
||||
this.searchPage.checkSelectedFilters(this.filters);
|
||||
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting software", err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
public queryChanged($event) {
|
||||
this.loadPaging = true;
|
||||
|
||||
var parameters = $event.value;
|
||||
//this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage");
|
||||
//this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Software simple Search Page: "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchSoftwareComponent} from './searchSoftware.component';
|
||||
|
||||
import {SearchResultsModule } from '../searchUtils/searchResults.module';
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module';
|
||||
import {SearchFormModule} from '../searchUtils/searchForm.module';
|
||||
import {SearchPageModule} from '../searchUtils/searchPage.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
SearchFormModule, SearchResultsModule, SearchPageModule
|
||||
],
|
||||
declarations: [
|
||||
SearchSoftwareComponent
|
||||
],
|
||||
providers:[FreeGuard
|
||||
],
|
||||
exports: [
|
||||
SearchSoftwareComponent
|
||||
]
|
||||
})
|
||||
export class SearchSoftwareModule { }
|
|
@ -1,20 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchDatasetsService} from './searchDatasets.service';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers:[
|
||||
SearchDatasetsService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class DatasetsServiceModule { }
|
|
@ -1,20 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchOrpsService} from './searchOrps.service';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers:[
|
||||
SearchOrpsService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class OrpsServiceModule { }
|
|
@ -1,20 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchPublicationsService} from './searchPublications.service';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers:[
|
||||
SearchPublicationsService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class PublicationsServiceModule { }
|
|
@ -1,393 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
||||
|
||||
|
||||
import {DOI, StringUtils} from '../utils/string-utils.class';
|
||||
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class SearchDatasetsService {
|
||||
private sizeOfDescription: number = 270;
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchDatasets (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"datasets";
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
url += "&sortBy=" + sortBy;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
|
||||
|
||||
}
|
||||
searchDatasetById (id: string , properties:EnvProperties):any {
|
||||
|
||||
let url = properties.searchAPIURLLAst+"datasets/"+id+"?format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseResults(res, properties)));
|
||||
}
|
||||
|
||||
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"datasets";
|
||||
|
||||
let url = link+"?"+"&format=json";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
|
||||
}
|
||||
|
||||
searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
||||
let link = properties.searchAPIURLLAst+"datasets";
|
||||
let url = link+"?";
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
|
||||
|
||||
}
|
||||
advancedSearchDatasets (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact dataset) "
|
||||
url += "?query=";
|
||||
if(params!= null && params != '' ) {
|
||||
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
searchDatasetsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+"/datasets"+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
|
||||
}
|
||||
|
||||
searchDatasetsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
|
||||
}
|
||||
|
||||
parseResults(data: any, properties: EnvProperties): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
result.entityType = "dataset";
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
|
||||
let instance;
|
||||
for(let i=0; i<length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
}
|
||||
|
||||
if(resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['language'])) {
|
||||
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['language'].length; i++) {
|
||||
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['country'])) {
|
||||
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['country'].length; i++) {
|
||||
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
result['title'].name = String(resData['title'][0].content);
|
||||
} else {
|
||||
result['title'].name = String(resData['title'].content);
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToDataset();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
/*if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "id": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
|
||||
} else */if(relation['to'].class == "isProducedBy") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"fullName": string, "orcid": string}>();
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
let length = Array.isArray(authors) ? authors.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let author = Array.isArray(authors) ? authors[i] : authors;
|
||||
if(author) {
|
||||
/*if (author.ORCID && author.ORCID.indexOf(properties.orcidURL) != -1) {
|
||||
author.ORCID = author.ORCID.substr(properties.orcidURL.length);
|
||||
}*/
|
||||
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.ORCID};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
|
||||
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = String(resData.description);
|
||||
} else {
|
||||
result.description = String(resData.description[0]);
|
||||
}
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
if(!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for(let i=0; i<resData.publisher.length; i++) {
|
||||
if(result.publisher != undefined){
|
||||
result.publisher += ', '+resData['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
parseProjects(projects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[], relation: any ) : {
|
||||
"id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[] {
|
||||
if(projects == undefined) {
|
||||
projects = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = projects.length;
|
||||
|
||||
projects[countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
projects[countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
projects[countProjects]['acronym'] = relation.acronym;
|
||||
projects[countProjects]['title'] = relation.title;
|
||||
projects[countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
projects[countProjects]['id'] = "";
|
||||
projects[countProjects]['acronym'] = "";
|
||||
projects[countProjects]['title'] = "";
|
||||
projects[countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
projects[countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
parseRefineResults(id: string, data: any): any {
|
||||
var results:any = [];
|
||||
if(data.hasOwnProperty("resulthostingdatasource")) {
|
||||
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
|
||||
|
||||
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
|
||||
result['name'] = datasource.name;
|
||||
result['id'] = datasource.id.split("||")[0];
|
||||
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
|
||||
result['count'] = datasource.count;
|
||||
|
||||
if(result['id'] != id && result['name'] != "Unknown Repository") {
|
||||
results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
numOfDatasets(url: string, properties:EnvProperties):any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['total']));
|
||||
}
|
||||
|
||||
numOfEntityDatasets(id: string, entity: string, properties:EnvProperties):any {
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id+"/datasets/count";
|
||||
} else if(entity == "organization") {
|
||||
parameters = "organizations/"+id+"/datasets/count";
|
||||
}
|
||||
|
||||
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
||||
return this.numOfDatasets(url, properties);
|
||||
}
|
||||
|
||||
numOfSearchDatasets(params: string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+"datasets/count?format=json";
|
||||
|
||||
if(params.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(params);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
}else{
|
||||
url += "&q=" + StringUtils.URIEncode(params);
|
||||
}
|
||||
}
|
||||
// if(params != "") {
|
||||
// url += "&q=" + StringUtils.URIEncode(params);
|
||||
// }
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
return this.numOfDatasets(url, properties);
|
||||
}
|
||||
}
|
|
@ -1,390 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
||||
import {DOI, StringUtils} from '../utils/string-utils.class';
|
||||
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class SearchOrpsService {
|
||||
private sizeOfDescription: number = 270;
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchOrps (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"other";
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
url += "&sortBy=" + sortBy;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
|
||||
}
|
||||
searchOrpById (id: string , properties:EnvProperties):any {
|
||||
|
||||
let url = properties.searchAPIURLLAst+"other/"+id+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseResults(res, properties)));
|
||||
}
|
||||
|
||||
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"other";
|
||||
|
||||
let url = link+"?"+"&format=json";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
|
||||
}
|
||||
|
||||
searchOrpsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
||||
let link = properties.searchAPIURLLAst+"other";
|
||||
|
||||
let url = link+"?";
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
|
||||
}
|
||||
advancedSearchOrps (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact other) "
|
||||
url += "?query=";
|
||||
if(params!= null && params != '' ) {
|
||||
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
searchOrpsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
|
||||
let url = link+params+"/other"+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
|
||||
searchOrpsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
|
||||
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
|
||||
parseResults(data: any, properties: EnvProperties): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
result.entityType = "other";
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
|
||||
let instance;
|
||||
for(let i=0; i<length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
}
|
||||
|
||||
if(resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['language'])) {
|
||||
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['language'].length; i++) {
|
||||
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['country'])) {
|
||||
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['country'].length; i++) {
|
||||
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
result['title'].name = String(resData['title'][0].content);
|
||||
} else {
|
||||
result['title'].name = String(resData['title'].content);
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToOrp();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
/*if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "id": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
|
||||
} else */if(relation['to'].class == "isProducedBy") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"fullName": string, "orcid": string}>();
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
let length = Array.isArray(authors) ? authors.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let author = Array.isArray(authors) ? authors[i] : authors;
|
||||
if(author) {
|
||||
/*if (author.ORCID && author.ORCID.indexOf(properties.orcidURL) != -1) {
|
||||
author.ORCID = author.ORCID.substr(properties.orcidURL.length);
|
||||
}*/
|
||||
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.ORCID};
|
||||
} }
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
|
||||
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = String(resData.description);
|
||||
} else {
|
||||
result.description = String(resData.description[0]);
|
||||
}
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
if(!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for(let i=0; i<resData.publisher.length; i++) {
|
||||
if(result.publisher != undefined){
|
||||
result.publisher += ', '+resData['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
parseProjects(projects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[], relation: any ) : {
|
||||
"id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[] {
|
||||
if(projects == undefined) {
|
||||
projects = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = projects.length;
|
||||
|
||||
projects[countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
projects[countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
projects[countProjects]['acronym'] = relation.acronym;
|
||||
projects[countProjects]['title'] = relation.title;
|
||||
projects[countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
projects[countProjects]['id'] = "";
|
||||
projects[countProjects]['acronym'] = "";
|
||||
projects[countProjects]['title'] = "";
|
||||
projects[countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
projects[countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
parseRefineResults(id: string, data: any): any {
|
||||
var results:any = [];
|
||||
if(data.hasOwnProperty("resulthostingdatasource")) {
|
||||
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
|
||||
|
||||
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
|
||||
result['name'] = datasource.name;
|
||||
result['id'] = datasource.id.split("||")[0];
|
||||
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
|
||||
result['count'] = datasource.count;
|
||||
|
||||
if(result['id'] != id && result['name'] != "Unknown Repository") {
|
||||
results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
numOfOrps(url: string, properties:EnvProperties):any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['total']));
|
||||
}
|
||||
|
||||
numOfEntityOrps(id: string, entity: string, properties:EnvProperties):any {
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id+"/other/count";
|
||||
}
|
||||
|
||||
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
||||
|
||||
return this.numOfOrps(url, properties);
|
||||
}
|
||||
|
||||
numOfSearchOrps(params: string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+"other/count?format=json";
|
||||
|
||||
if(params.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(params);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
}else{
|
||||
url += "&q=" + StringUtils.URIEncode(params);
|
||||
}
|
||||
}
|
||||
// if(params != "") {
|
||||
// url += "&q=" + StringUtils.URIEncode(params);
|
||||
// }
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
return this.numOfOrps(url, properties);
|
||||
}
|
||||
}
|
|
@ -1,499 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
||||
import {DOI, StringUtils} from '../utils/string-utils.class';
|
||||
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class SearchPublicationsService {
|
||||
private sizeOfDescription: number = 270;
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchPublications (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst+"publications";
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
url += "&sortBy=" + sortBy;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
searchPublicationById (id: string, properties:EnvProperties ):any {
|
||||
|
||||
let url = properties.searchAPIURLLAst+"publications/"+id+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => this.parseResults(res, properties)));
|
||||
}
|
||||
|
||||
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"publications";
|
||||
|
||||
let url = link+"?"+"&format=json";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
|
||||
}
|
||||
|
||||
searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"publications";
|
||||
|
||||
let url = link+"?"+"&format=json&";
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url +="&"+doisParams;
|
||||
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
|
||||
advancedSearchPublications (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact publication) ";
|
||||
url += "?query=";
|
||||
if(params!= null && params != '' ) {
|
||||
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
searchPublicationsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+"/publications"+ "?format=json";
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
|
||||
searchPublicationsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
/*
|
||||
searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"publications";
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size+ "&format=json";
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
|
||||
.map(res => this.parseResultsCSV(res['results']));
|
||||
}
|
||||
*/
|
||||
|
||||
parseResults(data: any, properties: EnvProperties): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
result.entityType = "publication";
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
|
||||
let instance;
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
}
|
||||
|
||||
if(resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['language'])) {
|
||||
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['language'].length; i++) {
|
||||
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['country'])) {
|
||||
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['country'].length; i++) {
|
||||
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
// resData['title'][0].hasOwnProperty("content") {
|
||||
result['title'].name = String(resData['title'][0].content);
|
||||
// }
|
||||
} else {
|
||||
// resData['title'].hasOwnProperty("content") {
|
||||
result['title'].name = String(resData['title'].content);
|
||||
// }
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToPublication();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
/*if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "id": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
|
||||
} else */if(relation['to'].class == "isProducedBy") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"fullName": string, "orcid": string}>();
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
let length = Array.isArray(authors) ? authors.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let author = Array.isArray(authors) ? authors[i] : authors;
|
||||
if(author) {
|
||||
/*if (author.ORCID && author.ORCID.indexOf(properties.orcidURL) != -1) {
|
||||
author.ORCID = author.ORCID.substr(properties.orcidURL.length);
|
||||
}*/
|
||||
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.ORCID};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
|
||||
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = String(resData.description);
|
||||
} else {
|
||||
result.description = String(resData.description[0]);
|
||||
}
|
||||
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
}
|
||||
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
parseProjects(projects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[], relation: any ) : {
|
||||
"id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[] {
|
||||
if(projects == undefined) {
|
||||
projects = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = projects.length;
|
||||
|
||||
projects[countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
projects[countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
projects[countProjects]['acronym'] = relation.acronym;
|
||||
projects[countProjects]['title'] = relation.title;
|
||||
projects[countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
projects[countProjects]['id'] = "";
|
||||
projects[countProjects]['acronym'] = "";
|
||||
projects[countProjects]['title'] = "";
|
||||
projects[countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
projects[countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
/*
|
||||
parseResultsCSV(data: any): any {
|
||||
let results: any = [];
|
||||
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: any = [];
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
result.push(this.quote(resData['title'][0].content));
|
||||
} else {
|
||||
result.push(this.quote(resData['title'].content));
|
||||
}
|
||||
|
||||
var authors: string[] = [];
|
||||
var projects: string[] = [];
|
||||
var funder: string = "";
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class == "hasAuthor") {
|
||||
authors.push(relation.fullname);
|
||||
} else if(relation['to'].class == "isProducedBy") {
|
||||
if(relation.code != "") {
|
||||
projects.push(relation.title+" ("+relation.code+")");
|
||||
} else {
|
||||
projects.push(relation.title);
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
funder = fundingData['funder'].shortname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
result.push(this.quote(authors));
|
||||
var year: string = "";
|
||||
if(resData.hasOwnProperty("dateofacceptance")) {
|
||||
year = resData.dateofacceptance;
|
||||
}
|
||||
result.push(year);
|
||||
var id:string = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result.push(this.quote(id));
|
||||
result.push(funder);
|
||||
result.push(this.quote(projects));
|
||||
} else {
|
||||
result.push(this.quote(''));
|
||||
var year: string = "";
|
||||
if(resData.hasOwnProperty("dateofacceptance")) {
|
||||
year = resData.dateofacceptance;
|
||||
}
|
||||
result.push(year);
|
||||
var id:string = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result.push(this.quote(id));
|
||||
result.push(funder);
|
||||
result.push("");
|
||||
}
|
||||
|
||||
|
||||
//result.push(resData.embargoenddate);
|
||||
|
||||
if(resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result.push(this.quote(resData['bestaccessright'].classid));
|
||||
} else {
|
||||
result.push("");
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
*/
|
||||
parseRefineResults(id: string, data: any): any {
|
||||
var results:any = [];
|
||||
if(data.hasOwnProperty("resulthostingdatasource")) {
|
||||
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
|
||||
|
||||
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
|
||||
result['name'] = datasource.name;
|
||||
result['id'] = datasource.id.split("||")[0];
|
||||
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
|
||||
result['count'] = datasource.count;
|
||||
|
||||
if(result['id'] != id && result['name'] != "Unknown Repository") {
|
||||
results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
numOfPublications(url: string, properties:EnvProperties): any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['total']));
|
||||
}
|
||||
|
||||
numOfEntityPublications(id: string, entity: string, properties:EnvProperties):any {
|
||||
var parameters: string = "";
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id+"/publications/count";
|
||||
} else if(entity == "organization") {
|
||||
parameters = "organizations/"+id+"/publications/count";
|
||||
}
|
||||
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
||||
return this.numOfPublications(url, properties);
|
||||
}
|
||||
|
||||
numOfSearchPublications(params: string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+"publications/count?format=json";
|
||||
if(params.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(params);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
}else{
|
||||
url += "&q=" + StringUtils.URIEncode(params);
|
||||
}
|
||||
}
|
||||
// if(params != "") {
|
||||
// url += "&q=" + StringUtils.URIEncode(params);
|
||||
// }
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
return this.numOfPublications(url, properties);
|
||||
}
|
||||
/*
|
||||
private quote(word: any): string {
|
||||
return '"'+word+'"';
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,400 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Observable} from 'rxjs';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
||||
|
||||
|
||||
|
||||
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
|
||||
import{EnvProperties} from '../utils/properties/env-properties';
|
||||
import {DOI, StringUtils} from '../utils/string-utils.class';
|
||||
import {map} from "rxjs/operators";
|
||||
@Injectable()
|
||||
export class SearchSoftwareService {
|
||||
private sizeOfDescription: number = 270;
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchSoftware (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"software";
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
url += "&sortBy=" + sortBy;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]));
|
||||
|
||||
}
|
||||
searchSoftwareById (id: string, properties:EnvProperties ):any {
|
||||
|
||||
let url = properties.searchAPIURLLAst+"software/"+id+"?format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => this.parseResults(res, properties)));
|
||||
}
|
||||
|
||||
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"software";
|
||||
|
||||
let url = link+"?"+"&format=json";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
|
||||
}
|
||||
|
||||
searchSoftwareByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
||||
let link = properties.searchAPIURLLAst+"software";
|
||||
let url = link+"?";
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]));
|
||||
}
|
||||
advancedSearchSoftware (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact software) "
|
||||
url += "?query=";
|
||||
if(params!= null && params != '' ) {
|
||||
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
|
||||
}
|
||||
searchSoftwareForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+"/software"+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
|
||||
}
|
||||
|
||||
searchSoftwareForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
||||
}
|
||||
|
||||
parseResults(data: any, properties: EnvProperties): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
result.entityType = "software";
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
|
||||
let instance;
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
}
|
||||
|
||||
if(resData['programmingLanguage'] && resData['programmingLanguage'] != null) {
|
||||
result.programmingLanguages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['programmingLanguage'])) {
|
||||
if(resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) {
|
||||
result.programmingLanguages.push(resData['programmingLanguage'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['programmingLanguage'].length; i++) {
|
||||
if(resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) {
|
||||
result.programmingLanguages.push(resData['programmingLanguage'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['language'])) {
|
||||
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['language'].length; i++) {
|
||||
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['country'])) {
|
||||
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['country'].length; i++) {
|
||||
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
result['title'].name = String(resData['title'][0].content);
|
||||
} else {
|
||||
result['title'].name = String(resData['title'].content);
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToSoftware();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
/*if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "id": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
|
||||
} else */if(relation['to'].class == "isProducedBy") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"fullName": string, "orcid": string}>();
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
let length = Array.isArray(authors) ? authors.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let author = Array.isArray(authors) ? authors[i] : authors;
|
||||
if(author) {
|
||||
/*if (author.ORCID && author.ORCID.indexOf(properties.orcidURL) != -1) {
|
||||
author.ORCID = author.ORCID.substr(properties.orcidURL.length);
|
||||
}*/
|
||||
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.ORCID};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
|
||||
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||
result.description = Array.isArray(resData.description) ? String(resData.description[0]) : String(resData.description);
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
if(!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for(let i=0; i<resData.publisher.length; i++) {
|
||||
if(result.publisher != undefined){
|
||||
result.publisher += ', '+resData['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
parseProjects(projects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[], relation: any ) : {
|
||||
"id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[] {
|
||||
if(projects == undefined) {
|
||||
projects = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = projects.length;
|
||||
|
||||
projects[countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
projects[countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
projects[countProjects]['acronym'] = relation.acronym;
|
||||
projects[countProjects]['title'] = relation.title;
|
||||
projects[countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
projects[countProjects]['id'] = "";
|
||||
projects[countProjects]['acronym'] = "";
|
||||
projects[countProjects]['title'] = "";
|
||||
projects[countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
projects[countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
parseRefineResults(id: string, data: any): any {
|
||||
var results:any = [];
|
||||
if(data.hasOwnProperty("resulthostingdatasource")) {
|
||||
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
|
||||
|
||||
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
|
||||
result['name'] = datasource.name;
|
||||
result['id'] = datasource.id.split("||")[0];
|
||||
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
|
||||
result['count'] = datasource.count;
|
||||
|
||||
if(result['id'] != id && result['name'] != "Unknown Repository") {
|
||||
results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
numOfSoftware(url: string, properties:EnvProperties):any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['total']));
|
||||
}
|
||||
|
||||
numOfEntitySoftware(id: string, entity: string, properties:EnvProperties):any {
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id+"/software/count";
|
||||
}
|
||||
|
||||
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
||||
return this.numOfSoftware(url, properties);
|
||||
}
|
||||
|
||||
numOfSearchSoftware(params: string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+"software/count?format=json";
|
||||
|
||||
if(params.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(params);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
}else{
|
||||
url += "&q=" + StringUtils.URIEncode(params);
|
||||
}
|
||||
}
|
||||
// if(params != "") {
|
||||
// url += "&q=" + StringUtils.URIEncode(params);
|
||||
// }
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
return this.numOfSoftware(url, properties);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchSoftwareService} from './searchSoftware.service';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers:[
|
||||
SearchSoftwareService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class SoftwareServiceModule { }
|
|
@ -1,54 +0,0 @@
|
|||
export class DatasetInfo {
|
||||
underCurationMessage: boolean;
|
||||
//title: { "name": string, "url": string, "accessMode": string};
|
||||
title: string;
|
||||
subtitle: string;
|
||||
accessMode: string;
|
||||
authors: {"fullName": string, "orcid": string}[];
|
||||
date: string;
|
||||
dateofacceptance: string;
|
||||
embargoEndDate: string;
|
||||
types: string[];
|
||||
hostedBy_collectedFrom: { "downloadName": string, "downloadUrl": string[],
|
||||
"collectedName": string, "collectedId": string,
|
||||
"accessMode": string[], "bestAccessMode": string,
|
||||
"type": string, "year":string}[];
|
||||
identifiers: Map<string, string[]>;
|
||||
publisher: string;
|
||||
journal: {"journal": string, "issn": string, "lissn": string, "eissn": string, "issue": string, "volume": string, "start_page": string, "end_page": string};
|
||||
languages: string[];
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
otherSubjects: Map<string, string[]>;
|
||||
classifiedSubjects: Map<string, string[]>;
|
||||
description: string;
|
||||
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
|
||||
"sysimport:crosswalk:entityregistry": string,
|
||||
"sysimport:crosswalk:datasetarchive": string,
|
||||
"iis": string,
|
||||
"sysimport:mining:repository": string,
|
||||
"user:claim:pid": string,
|
||||
"user:claim:search": string,
|
||||
"user:claim:datacite": string
|
||||
} = {
|
||||
"sysimport:crosswalk:repository": "Repository",
|
||||
"sysimport:crosswalk:entityregistry": "Repository",
|
||||
"sysimport:crosswalk:datasetarchive": "Repository",
|
||||
"iis": "OpenAIRE",
|
||||
"sysimport:mining:repository": "OpenAIRE",
|
||||
"user:claim:pid": "User",
|
||||
"user:claim:search": "User",
|
||||
"user:claim:datacite": "User"
|
||||
};
|
||||
fundedByProjects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"funding": string, "code": string, "provenanceAction": string, "inline": boolean}[];
|
||||
researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"};
|
||||
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
|
||||
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
|
||||
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
|
||||
record;
|
||||
references: { "name": string, "url": string}[];
|
||||
|
||||
deletedByInferenceIds: string[];
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
export class OrpInfo {
|
||||
underCurationMessage: boolean;
|
||||
title: string;
|
||||
accessMode: string;
|
||||
authors: {"fullName": string, "orcid": string}[];
|
||||
date: string;
|
||||
dateofacceptance: string;
|
||||
embargoEndDate: string;
|
||||
types: string[];
|
||||
hostedBy_collectedFrom: { "downloadName": string, "downloadUrl": string[],
|
||||
"collectedName": string, "collectedId": string,
|
||||
"accessMode": string[], "bestAccessMode": string,
|
||||
"type": string, "year":string}[];
|
||||
identifiers: Map<string, string[]>;
|
||||
publisher: string;
|
||||
journal: {"journal": string, "issn": string, "lissn": string, "eissn": string, "issue": string, "volume": string, "start_page": string, "end_page": string};
|
||||
languages: string[];
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
otherSubjects: Map<string, string[]>;
|
||||
classifiedSubjects: Map<string, string[]>;
|
||||
description: string;
|
||||
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
|
||||
"sysimport:crosswalk:entityregistry": string,
|
||||
"sysimport:crosswalk:datasetarchive": string,
|
||||
"iis": string,
|
||||
"sysimport:mining:repository": string,
|
||||
"user:claim:pid": string,
|
||||
"user:claim:search": string,
|
||||
"user:claim:datacite": string
|
||||
} = {
|
||||
"sysimport:crosswalk:repository": "Repository",
|
||||
"sysimport:crosswalk:entityregistry": "Repository",
|
||||
"sysimport:crosswalk:datasetarchive": "Repository",
|
||||
"iis": "OpenAIRE",
|
||||
"sysimport:mining:repository": "OpenAIRE",
|
||||
"user:claim:pid": "User",
|
||||
"user:claim:search": "User",
|
||||
"user:claim:datacite": "User"
|
||||
};
|
||||
fundedByProjects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"funding": string, "code": string, "provenanceAction": string, "inline": boolean}[];
|
||||
researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"};
|
||||
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
|
||||
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
|
||||
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
|
||||
references: { "name": string, "url": string}[];
|
||||
record;
|
||||
|
||||
deletedByInferenceIds: string[];
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
export class PublicationInfo {
|
||||
underCurationMessage: boolean;
|
||||
//title: { "name": string, "url": string, "accessMode": string};
|
||||
title: string;
|
||||
accessMode: string;
|
||||
authors: {"fullName": string, "orcid": string}[];
|
||||
date: string;
|
||||
dateofacceptance: string;
|
||||
embargoEndDate: string;
|
||||
types: string[];
|
||||
//downloadFrom: Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>; //key is name
|
||||
//publishedIn: Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>; //key is name
|
||||
|
||||
hostedBy_collectedFrom: {"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}[];
|
||||
|
||||
identifiers: Map<string, string[]>; //key is the classname
|
||||
publisher: string;
|
||||
journal: {"journal": string, "issn": string, "lissn": string, "eissn": string, "issue": string, "volume": string, "start_page": string, "end_page": string};
|
||||
languages: string[];
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
otherSubjects: Map<string, string[]>;
|
||||
classifiedSubjects: Map<string, string[]>; //<class of subject, subjects>
|
||||
description: string;
|
||||
//bestaccessright: string;
|
||||
//collectedFrom: { "name": string, "id": string}[];
|
||||
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
|
||||
"sysimport:crosswalk:entityregistry": string,
|
||||
"sysimport:crosswalk:datasetarchive": string,
|
||||
"iis": string,
|
||||
"sysimport:mining:repository": string,
|
||||
"user:claim:pid": string,
|
||||
"user:claim:search": string,
|
||||
"user:claim:datacite": string
|
||||
} = {
|
||||
"sysimport:crosswalk:repository": "Repository",
|
||||
"sysimport:crosswalk:entityregistry": "Repository",
|
||||
"sysimport:crosswalk:datasetarchive": "Repository",
|
||||
"iis": "OpenAIRE",
|
||||
"sysimport:mining:repository": "OpenAIRE",
|
||||
"user:claim:pid": "User",
|
||||
"user:claim:search": "User",
|
||||
"user:claim:datacite": "User"
|
||||
};
|
||||
fundedByProjects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"funding": string, "code": string, "provenanceAction": string,
|
||||
"inline": boolean}[];
|
||||
bioentities: Map<string, Map<string, string>>; //<site name, <>>
|
||||
software: { "name": string, "url": string}[]; //<site name, <>>
|
||||
//relatedPublications: { "name": string, "url": string, "date": string, "trust": number}[];
|
||||
//relatedResearchData: { "name": string, "url": string, "date": string, "trust": number}[];
|
||||
//similarPublications: {"name": string, "url": string, "date": string, "trust": number}[];
|
||||
//similarDatasets: {"name": string, "url": string, "date": string, "trust": number}[];
|
||||
researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"};
|
||||
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
|
||||
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
|
||||
references: { "name": string, "url": string}[];
|
||||
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
|
||||
organizations: {"name": string, "shortname":string, "id": string, "websiteUrl": string, "country": string, "trust": number}[];
|
||||
|
||||
openCitations: {"url": string, "title": string, "year": string, "doi": string, "authors": string[]}[];
|
||||
|
||||
record;
|
||||
|
||||
deletedByInferenceIds: string[];
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
export class SoftwareInfo {
|
||||
underCurationMessage: boolean;
|
||||
//title: { "name": string, "url": string, "accessMode": string};
|
||||
title: string;
|
||||
accessMode: string;
|
||||
authors: {"fullName": string, "orcid": string}[];
|
||||
date: string;
|
||||
dateofacceptance: string;
|
||||
embargoEndDate: string;
|
||||
types: string[];
|
||||
hostedBy_collectedFrom: { "downloadName": string, "downloadUrl": string[],
|
||||
"collectedName": string, "collectedId": string,
|
||||
"accessMode": string[], "bestAccessMode": string,
|
||||
"type": string, "year":string}[];
|
||||
identifiers: Map<string, string[]>;
|
||||
publisher: string;
|
||||
journal: {"journal": string, "issn": string, "lissn": string, "eissn": string, "issue": string, "volume": string, "start_page": string, "end_page": string};
|
||||
languages: string[];
|
||||
countries: string[];
|
||||
subjects: string[];
|
||||
otherSubjects: Map<string, string[]>;
|
||||
classifiedSubjects: Map<string, string[]>;
|
||||
description: string;
|
||||
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
|
||||
"sysimport:crosswalk:entityregistry": string,
|
||||
"sysimport:crosswalk:datasetarchive": string,
|
||||
"iis": string,
|
||||
"sysimport:mining:repository": string,
|
||||
"user:claim:pid": string,
|
||||
"user:claim:search": string,
|
||||
"user:claim:datacite": string
|
||||
} = {
|
||||
"sysimport:crosswalk:repository": "Repository",
|
||||
"sysimport:crosswalk:entityregistry": "Repository",
|
||||
"sysimport:crosswalk:datasetarchive": "Repository",
|
||||
"iis": "OpenAIRE",
|
||||
"sysimport:mining:repository": "OpenAIRE",
|
||||
"user:claim:pid": "User",
|
||||
"user:claim:search": "User",
|
||||
"user:claim:datacite": "User"
|
||||
};
|
||||
fundedByProjects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"funding": string, "code": string, "provenanceAction": string, "inline": boolean}[];
|
||||
researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"};
|
||||
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
|
||||
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
|
||||
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
|
||||
record;
|
||||
//softwareType: string;
|
||||
programmingLanguages: string[];
|
||||
|
||||
deletedByInferenceIds: string[];
|
||||
}
|
|
@ -1,283 +0,0 @@
|
|||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {Subject} from 'rxjs';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
export class FetchDatasets{
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
public results =[];
|
||||
public requestComplete: Subject<void>;
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
|
||||
public csvParams: string;
|
||||
|
||||
constructor ( private _searchResearchResultsService: SearchResearchResultsService) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.requestComplete = new Subject<void>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + StringUtils.URIEncode(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var refineParams = null;
|
||||
if(customFilter){
|
||||
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
|
||||
}
|
||||
this.subResults = this._searchResearchResultsService.search("dataset", parameters,refineParams, page, size, "", [], properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Research Data: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
*/
|
||||
this.handleError("Error getting research data for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public getNumForEntity(entity:string, id:string, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
if(id != "" && entity != "") {
|
||||
this._searchResearchResultsService.numOfEntityResults("dataset", id, entity, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
*/
|
||||
this.handleError("Error getting research data for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
} else if(entity == "organization") {
|
||||
parameters = "organizations/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("dataset", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Research Data for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
*/
|
||||
this.handleError("Error getting research data for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "datasets?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "datasets?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("dataset", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Research Data for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting research data for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getAggregatorResults(id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.searchAggregators("dataset", id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size, properties).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
this.searchUtils.totalResults = this.results.length;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.requestComplete.complete();
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//console.info("status: "+err.status);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting research data for aggregator with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.requestComplete.complete();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Fetch Research Data (class): "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,241 +0,0 @@
|
|||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {Subject} from 'rxjs';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
|
||||
export class FetchOrps{
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
public results =[];
|
||||
public requestComplete: Subject<void>;
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
|
||||
public csvParams: string;
|
||||
|
||||
constructor ( private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.requestComplete = new Subject<void>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + StringUtils.URIEncode(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var refineParams = null;
|
||||
if(customFilter){
|
||||
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
|
||||
}
|
||||
this.subResults = this._searchResearchResultsService.search("other", 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+"]");
|
||||
this.results = data[1];
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting other research products for keyword: "+keyword+ (doisParams ? "(DOI)" : ""), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public getNumForEntity(entity:string, id:string, properties:EnvProperties){
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
if(id != "" && entity != "") {
|
||||
this._searchResearchResultsService.numOfEntityResults("other", id, entity, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting number of other research products for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number, properties:EnvProperties){
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("other", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Other Research Products for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting other research products for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "other?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "other?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("other", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Other Research Products for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting other research products for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getAggregatorResults(id:string, page: number, size: number, properties:EnvProperties){
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.searchAggregators("other", id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size, properties).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
this.searchUtils.totalResults = this.results.length;
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.requestComplete.complete();
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//console.info("status: "+err.status);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting other research products for aggrgator with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.requestComplete.complete();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Fetch Other Research Data (class): "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,288 +0,0 @@
|
|||
|
||||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {Subject} from 'rxjs';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
|
||||
export class FetchPublications {
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
public results =[];
|
||||
|
||||
public requestComplete: Subject<void>;
|
||||
|
||||
// public filters =[];
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
// public baseUrl:string = "";
|
||||
public sub: any;
|
||||
public subResults: any;
|
||||
public searchFields:SearchFields = new SearchFields();
|
||||
// public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
// public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
||||
//: { [key:string] :{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PUBLICATION_FIELDS_MAP;
|
||||
|
||||
public CSV: any = { "columnNames": ["Title", "Authors", "Publication Year", "DOI",
|
||||
/*"Download From", "Publication type", "Journal",*/
|
||||
"Funder", "Project Name (GA Number)", "Access"],
|
||||
"export":[]
|
||||
};
|
||||
public CSVDownloaded = false;
|
||||
public csvParams: string;
|
||||
|
||||
constructor ( private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.requestComplete = new Subject<void>();
|
||||
}
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + StringUtils.URIEncode(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var refineParams = null;
|
||||
if(customFilter){
|
||||
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
|
||||
}
|
||||
this.subResults = this._searchResearchResultsService.search("publication", parameters,refineParams, page, size, "", [], properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting publications for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public getNumForEntity(entity:string, id:string, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
if(id != "" && entity != "") {
|
||||
this._searchResearchResultsService.numOfEntityResults("publication", id, entity, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting publications for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters = "";
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
} else if(entity == "organization") {
|
||||
parameters = "organizations/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
this._searchResearchResultsService.searchResultForEntity("publication", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
|
||||
//console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting publications for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "publications?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "publications?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("publication", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting publications for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getAggregatorResults(id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.searchAggregators("publication", id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size, properties).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
this.searchUtils.totalResults = this.results.length;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.requestComplete.complete();
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting publications for aggregator with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.requestComplete.complete();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Fetch Publications (class): "+message, error);
|
||||
}
|
||||
}
|
|
@ -1,274 +0,0 @@
|
|||
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
||||
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
|
||||
import {DOI} from '../../utils/string-utils.class';
|
||||
import {Subject} from 'rxjs';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
|
||||
export class FetchSoftware{
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
public results =[];
|
||||
public requestComplete: Subject<void>;
|
||||
|
||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||
private sub: any;
|
||||
private subResults: any;
|
||||
|
||||
public csvParams: string;
|
||||
|
||||
constructor ( private _searchResearchResultsService: SearchResearchResultsService ) {
|
||||
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.requestComplete = new Subject<void>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
if(this.sub){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if(this.subResults){
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
|
||||
var parameters = "";
|
||||
if(keyword.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
parameters += "&"+doisParams;
|
||||
}else{
|
||||
parameters = "q=" + StringUtils.URIEncode(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var refineParams = null;
|
||||
if(customFilter){
|
||||
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
|
||||
}
|
||||
this.subResults = this._searchResearchResultsService.search("software", parameters,refineParams, page, size, "", [], properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting software for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public getNumForEntity(entity:string, id:string, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
|
||||
if(id != "" && entity != "") {
|
||||
this._searchResearchResultsService.numOfEntityResults("software", id, entity, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting software for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForEntity(entity:string, id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters = "";
|
||||
|
||||
if(entity == "project") {
|
||||
parameters = "projects/"+id;
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchResultForEntity("software", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting software for "+entity+" with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
var parameters;
|
||||
if(resultsFrom == "collectedFrom") {
|
||||
parameters = "software?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||
} else if(resultsFrom == "hostedBy") {
|
||||
parameters = "software?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||
}
|
||||
|
||||
if(parameters != "") {
|
||||
|
||||
this._searchResearchResultsService.searchForDataproviders("software", parameters, page, size, properties).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
//console.info("search Software for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||
this.results = data[1];
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting software for content provider ("+resultsFrom+") with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getAggregatorResults(id:string, page: number, size: number, properties:EnvProperties){
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.subResults = this._searchResearchResultsService.searchAggregators("software", id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size, properties).subscribe(
|
||||
data => {
|
||||
this.results = data;
|
||||
this.searchUtils.totalResults = this.results.length;
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if(this.searchUtils.totalResults == 0 ){
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.requestComplete.complete();
|
||||
},
|
||||
err => {
|
||||
/*console.log(err);
|
||||
//console.info("status: "+err.status);
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.ERROR;
|
||||
if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
this.handleError("Error getting software for aggregator with id: "+id, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.requestComplete.complete();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Fetch Software (class): "+message, error);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue