2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import {SearchCrossrefService} from '../claim-utils/service/searchCrossref.service';
|
|
|
|
import {SearchOrcidService} from '../claim-utils/service/searchOrcid.service';
|
|
|
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
|
|
|
import { SearchDataciteService } from '../claim-utils/service/searchDatacite.service';
|
|
|
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|
|
|
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
|
|
|
|
2018-02-15 11:36:12 +01:00
|
|
|
import { ErrorCodes} from '../../utils/properties/errorCodes';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {ClaimResult} from '../claim-utils/claimEntities.class';
|
|
|
|
import{DOI} from '../../utils/string-utils.class';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
declare var UIkit:any;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'claim-result-search-form',
|
|
|
|
templateUrl: 'claimResultSearchForm.component.html',
|
|
|
|
|
|
|
|
})
|
|
|
|
export class ClaimResultSearchFormComponent {
|
|
|
|
constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService, private _searchSoftwareService:SearchSoftwareService,
|
|
|
|
private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService,
|
|
|
|
private route: ActivatedRoute) {
|
|
|
|
var myDate = new Date();
|
|
|
|
this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
|
|
this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
|
|
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
console.log("Init of ClaimResultSearchFormComponent");
|
|
|
|
console.log(this.properties);
|
2017-12-19 13:53:46 +01:00
|
|
|
if(this.keyword !=null && this.keyword.length > 0){
|
|
|
|
this.search(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
page : number = 1;
|
|
|
|
size:number = 5;
|
|
|
|
navigateTo: string = "Search";
|
|
|
|
source: string = "datacite";
|
|
|
|
type : string = "dataset";
|
|
|
|
showSearchResults:boolean=false;
|
|
|
|
// searchType ="publication";
|
|
|
|
@Input() public select:boolean = true ;
|
|
|
|
@Input() public keyword:string = '';
|
|
|
|
@Input() public selectedResults:ClaimResult[];
|
2018-02-05 14:14:59 +01:00
|
|
|
@Input() public properties:EnvProperties;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
// @Output() datasetsChange = new EventEmitter();
|
|
|
|
// @Output() publicationsChange = new EventEmitter();
|
|
|
|
|
|
|
|
// @Output() resultsChange = new EventEmitter();
|
|
|
|
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
dataciteResults=[];
|
|
|
|
dataciteResultsNum:number = null;
|
|
|
|
// dataciteResultsNum : Observable<number> = null;
|
|
|
|
dataciteStatus = this.errorCodes.NONE;
|
|
|
|
datacitePage : number = 1;
|
|
|
|
|
|
|
|
openaireData=[];
|
|
|
|
openaireDataNum:number = 0 ;
|
|
|
|
openaireDataStatus = this.errorCodes.NONE;
|
|
|
|
openaireDataPage : number = 1;
|
|
|
|
openaireSoftware=[];
|
|
|
|
openaireSoftwareNum:number = 0 ;
|
|
|
|
openaireSoftwareStatus = this.errorCodes.NONE;
|
|
|
|
openaireSoftwarePage : number = 1;
|
|
|
|
|
|
|
|
public warningMessage = "";
|
|
|
|
public infoMessage = "";
|
|
|
|
|
|
|
|
public todayDate = '';
|
|
|
|
public nextDate = '';
|
|
|
|
public DOIs:string[] = [];
|
|
|
|
sub: any;
|
|
|
|
public searchSource:string = "openaire"
|
|
|
|
public activeTab:string = "openairePub"
|
|
|
|
|
|
|
|
|
|
|
|
crossrefResults=[];
|
|
|
|
crossrefResultsNum : number = null;
|
|
|
|
crossrefPage : number = 1;
|
|
|
|
crossrefStatus:number = this.errorCodes.NONE;
|
|
|
|
|
|
|
|
openairePubs = [];
|
|
|
|
openairePubsNum: number ;
|
|
|
|
openairePubsPage : number = 1;
|
|
|
|
openairePubsStatus:number = this.errorCodes.NONE;
|
|
|
|
|
|
|
|
orcidResults: string[];
|
|
|
|
orcidResultsNum: number ;
|
|
|
|
totalPages: number;
|
|
|
|
orcidResultsToShow: string[];
|
|
|
|
orcidPage : number = 1;
|
|
|
|
orcidStatus:number = this.errorCodes.NONE;
|
|
|
|
authorId: string;
|
|
|
|
selectAuthorId: string = "0";
|
|
|
|
authorGivenName: string;
|
|
|
|
authorFamilyName: string;
|
|
|
|
|
|
|
|
authorIds: string[];
|
|
|
|
authorGivenNames: string[];
|
|
|
|
authorFamilyNames: string[];
|
|
|
|
|
|
|
|
authorsNum : number ;
|
|
|
|
|
|
|
|
reloadOpenaire:boolean = true;
|
|
|
|
reloadCrossref:boolean = false;
|
|
|
|
reloadDatacite:boolean = false;
|
|
|
|
reloadOrcid:boolean = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
search(sourceChanged){
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
if(!sourceChanged){
|
|
|
|
this.DOIs = DOI.getDOIsFromString(this.keyword);
|
|
|
|
this.reloadOpenaire = true;
|
|
|
|
this.reloadCrossref = true;
|
|
|
|
this.reloadDatacite = true;
|
|
|
|
this.reloadOrcid = true;
|
|
|
|
}
|
|
|
|
if((this.searchSource == "all" || this.searchSource == "openaire") && this.reloadOpenaire){
|
|
|
|
this.searchOpenairePubs(this.keyword, this.size, 1);
|
|
|
|
this.searchOpenaireData(this.keyword,this.size,1);
|
|
|
|
this.searchOpenaireSoftware(this.keyword,this.size,1);
|
|
|
|
this.reloadOpenaire = false;
|
|
|
|
}
|
|
|
|
if((this.searchSource == "all" || this.searchSource == "crossref")&&this.reloadCrossref){
|
|
|
|
this.getCrossrefResults(this.keyword, this.size,1);
|
|
|
|
this.reloadCrossref = false;
|
|
|
|
}
|
|
|
|
if((this.searchSource == "all" || this.searchSource == "datacite")&& this.reloadDatacite){
|
|
|
|
this.searchDatacite(this.keyword,this.size,1);
|
|
|
|
this.reloadDatacite = false;
|
|
|
|
}
|
|
|
|
if((this.searchSource == "all" || this.searchSource == "orcid")&& this.reloadOrcid){
|
|
|
|
this.searchOrcid(this.keyword);
|
|
|
|
this.reloadOrcid = false;
|
|
|
|
}
|
|
|
|
this.showSearchResults = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private getCrossrefResults (term: string, size : number, page : number) {
|
|
|
|
this.crossrefStatus = this.errorCodes.LOADING;
|
|
|
|
if( this.DOIs.length > 0 ){
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties.searchCrossrefAPIURL).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.crossrefResults = data.items;
|
|
|
|
this.crossrefPage=page;
|
|
|
|
this.crossrefResultsNum = data['total-results'];
|
|
|
|
if(data.items == 0){
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.crossrefResults = data.items;
|
|
|
|
this.crossrefPage=page;
|
|
|
|
this.crossrefResultsNum = data['total-results'];
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err =>{
|
|
|
|
console.log(err.status);
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
}else{
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err);
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
this.crossrefResults = data.items;
|
|
|
|
this.crossrefPage=page;
|
|
|
|
this.crossrefResultsNum = data['total-results'];
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err.status);
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.crossrefResults = data.items;
|
|
|
|
this.crossrefPage=page;
|
|
|
|
this.crossrefResultsNum = data['total-results'];
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err.status);
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private searchOpenairePubs(term: string, size : number, page : number) {
|
|
|
|
|
|
|
|
if(this.DOIs.length > 0 ){
|
|
|
|
this.openairePubsStatus = this.errorCodes.LOADING;
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchPublicationsService.searchPublicationsByDois(this.DOIs, null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openairePubsPage=page;
|
|
|
|
this.openairePubsNum = data[0];
|
|
|
|
this.openairePubs = data[1];
|
|
|
|
this.openairePubsStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openairePubsNum == 0){
|
|
|
|
this.openairePubsStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}else{
|
|
|
|
this.openairePubsStatus = this.errorCodes.LOADING;
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchPublicationsService.searchPublications('q='+term, null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openairePubsPage=page;
|
|
|
|
this.openairePubsNum = data[0];
|
|
|
|
this.openairePubs = data[1];
|
|
|
|
this.openairePubsStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openairePubsNum == 0){
|
|
|
|
this.openairePubsStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private searchOrcid (term: string) {
|
|
|
|
if(this.DOIs.length > 0){
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
|
|
|
this.authorIds = new Array<string>();
|
|
|
|
this.authorGivenNames = new Array<string>();
|
|
|
|
this.authorFamilyNames = new Array<string>();
|
|
|
|
|
|
|
|
this.getOrcidAuthor(term);
|
|
|
|
|
|
|
|
console.info('searchOrcid in searchOrcid file');
|
|
|
|
}
|
|
|
|
|
|
|
|
private readData(data: any) {
|
|
|
|
this.authorIds.push(data[2].path);
|
|
|
|
|
|
|
|
if(data[0] != null) {
|
|
|
|
this.authorGivenNames.push(data[0].value);
|
|
|
|
} else {
|
|
|
|
this.authorGivenNames.push("");
|
|
|
|
}
|
|
|
|
if(data[1] != null) {
|
|
|
|
this.authorFamilyNames.push(data[1].value);
|
|
|
|
} else {
|
|
|
|
this.authorFamilyNames.push("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private getOrcidAuthor (term: string) {
|
|
|
|
this.orcidResultsNum = null;
|
|
|
|
|
|
|
|
//passing structures in order to fill them in service
|
|
|
|
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
|
2018-02-05 14:14:59 +01:00
|
|
|
this.authorGivenNames, this.authorFamilyNames, this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null && data == true) {
|
|
|
|
this.getOrcidResultsByIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
|
|
|
|
|
|
|
},
|
|
|
|
err => this.errorHandler(err, term)
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private errorHandler(err: any, term: string) {
|
|
|
|
if(err.status == 404){
|
|
|
|
this.getOrcidAuthors(term);
|
|
|
|
} else {
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private getOrcidAuthors (term: string) {
|
|
|
|
this.orcidResultsNum = null;
|
|
|
|
this.selectAuthorId = "0";
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
|
|
|
//passing structures in order to fill them in service
|
|
|
|
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
|
2018-02-05 14:14:59 +01:00
|
|
|
this.authorGivenNames, this.authorFamilyNames, this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null && data == true) {
|
|
|
|
this.getOrcidResultsByIndex(0);
|
|
|
|
}else{
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private getOrcidResultsByIndex (index:number) {
|
|
|
|
if(this.authorIds.length > index) {
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
|
|
|
let id = this.authorIds[index];
|
|
|
|
this.authorGivenName = this.authorGivenNames[index];
|
|
|
|
this.authorFamilyName = this.authorFamilyNames[index];
|
|
|
|
this.getOrcidResultsById(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private getOrcidResultsById (id:string) {
|
|
|
|
if(id=="0"){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var index = this.authorIds.indexOf(id);
|
|
|
|
this.authorGivenName = this.authorGivenNames[index];
|
|
|
|
this.authorFamilyName = this.authorFamilyNames[index];
|
|
|
|
this.authorId = id;
|
|
|
|
console.info("getOrcidResultsById: "+id);
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchOrcidService.searchOrcidPublications(id, this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.orcidResults=data['orcid-work'];
|
|
|
|
this.orcidResultsNum = data['orcid-work'].length;
|
|
|
|
this.orcidPage = 1;
|
|
|
|
if((this.orcidResultsNum % this.size) == 0){
|
|
|
|
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
|
|
|
|
} else{
|
|
|
|
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.orcidResultsToShow = this.orcidResults.slice(0,10);
|
|
|
|
|
|
|
|
this.orcidStatus = this.errorCodes.DONE;
|
|
|
|
if(this.orcidResultsNum == 0){
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.orcidResultsNum = 0;
|
|
|
|
this.totalPages=0;
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err.status);
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Is it USED???
|
|
|
|
private remove(item){
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
var index:number =this.selectedResults.indexOf(item);
|
|
|
|
item.selected=false;
|
|
|
|
if (index > -1) {
|
|
|
|
this.selectedResults.splice(index, 1);
|
|
|
|
// this.publicationsChange.emit({
|
|
|
|
// value: this.selectedResults
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
private crossrefPageChange($event) {
|
|
|
|
this.crossrefPage=$event.value;
|
|
|
|
this.crossrefResults=[];
|
|
|
|
console.log("Crossref chaenged "+this.crossrefPage);
|
|
|
|
this.getCrossrefResults(this.keyword,this.size,this.crossrefPage);
|
|
|
|
}
|
|
|
|
private orcidPageChange($event) {
|
|
|
|
this.orcidPage=$event.value;
|
|
|
|
this.orcidResultsToShow=[];
|
|
|
|
this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size);
|
|
|
|
}
|
|
|
|
private openairePubsPageChange($event) {
|
|
|
|
this.openairePubsPage=$event.value;
|
|
|
|
this.searchOpenairePubs(this.keyword,this.size,this.openairePubsPage);
|
|
|
|
}
|
|
|
|
datacitePageChange($event) {
|
|
|
|
this.datacitePage=$event.value;
|
|
|
|
this.dataciteResults=[];
|
|
|
|
this.searchDatacite(this.keyword,10,this.datacitePage);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
openaireDataPageChange($event) {
|
|
|
|
this.openaireDataPage=$event.value;
|
|
|
|
this.openaireData=[];
|
|
|
|
this.searchOpenaireData(this.keyword,10,this.openaireDataPage);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
openaireSoftwarePageChange($event) {
|
|
|
|
this.openaireSoftwarePage=$event.value;
|
|
|
|
this.openaireSoftware=[];
|
|
|
|
this.searchOpenaireSoftware(this.keyword,10,this.openaireSoftwarePage);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private isSelected(id:string){
|
|
|
|
|
|
|
|
var found:boolean = false;
|
|
|
|
this.warningMessage = "";
|
|
|
|
for (var _i = 0; _i < this.selectedResults.length; _i++) {
|
|
|
|
let item = this.selectedResults[_i];
|
|
|
|
if(item.id == id){
|
|
|
|
found=true;
|
|
|
|
this.warningMessage = "Publication already in selected list";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// isSelected(id:string){
|
|
|
|
//
|
|
|
|
// var found:boolean = false;
|
|
|
|
// this.warningMessage = "";
|
|
|
|
// for (var _i = 0; _i < this.selectedResults.length; _i++) {
|
|
|
|
// let item = this.selectedResults[_i];
|
|
|
|
// if(item.id == id){
|
|
|
|
// found=true;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return found;
|
|
|
|
// }
|
|
|
|
private searchDatacite (term: string, size : number, page : number) {
|
|
|
|
this.getDataciteResults(term,size,page);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
private searchOpenaireData (term: string, size : number, page : number) {
|
|
|
|
if(this.DOIs.length > 0 ){
|
|
|
|
this.openaireDataStatus = this.errorCodes.LOADING;
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchDatasetsService.searchDatasetsByDois(this.DOIs, null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openaireDataPage=page;
|
|
|
|
this.openaireDataNum = data[0];
|
|
|
|
this.openaireData = data[1];
|
|
|
|
this.openaireDataStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openaireDataNum == 0){
|
|
|
|
this.openaireDataStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openaireDataStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}else{
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchDatasetsService.searchDatasets('q='+term+'', null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openaireDataPage=page;
|
|
|
|
this.openaireDataNum = data[0];
|
|
|
|
this.openaireData = data[1];
|
|
|
|
this.openaireDataStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openaireDataNum == 0){
|
|
|
|
this.openaireDataStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openaireDataStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
private searchOpenaireSoftware (term: string, size : number, page : number) {
|
|
|
|
if(this.DOIs.length > 0 ){
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.LOADING;
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchSoftwareService.searchSoftwareByDois(this.DOIs, null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openaireSoftwarePage=page;
|
|
|
|
this.openaireSoftwareNum = data[0];
|
|
|
|
this.openaireSoftware = data[1];
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openaireSoftwareNum == 0){
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}else{
|
2018-02-05 14:14:59 +01:00
|
|
|
this._searchSoftwareService.searchSoftware('q='+term+'', null, page, size, [], this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
if(data != null) {
|
|
|
|
this.openaireSoftwarePage=page;
|
|
|
|
this.openaireSoftwareNum = data[0];
|
|
|
|
this.openaireSoftware = data[1];
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.DONE;
|
|
|
|
if(this.openaireSoftwareNum == 0){
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.openaireSoftwareStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err.status);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
private getDataciteResults (term: string, size : number, page : number) {
|
2018-02-05 14:14:59 +01:00
|
|
|
console.log("getDataciteResults + "+this.properties.searchDataciteAPIURL)
|
|
|
|
this._searchDataciteService.searchDataciteResults(term, size, page, this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
this.dataciteResults = data.data;
|
|
|
|
this.datacitePage=page;
|
|
|
|
this.dataciteResultsNum = data.meta.total;
|
|
|
|
this.dataciteStatus = this.errorCodes.DONE;
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.dataciteStatus = this.errorCodes.ERROR;
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){
|
|
|
|
|
|
|
|
console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle);
|
|
|
|
var result: ClaimResult = ClaimResult.generateResult(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode);
|
|
|
|
|
|
|
|
|
|
|
|
if (itemSource == 'orcid'){
|
|
|
|
if(result.authors.length ==0 ){
|
|
|
|
result.authors.push(this.authorGivenName + ', '+ this.authorFamilyName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var found:boolean = this.isSelected( result.id);
|
|
|
|
|
|
|
|
this.warningMessage = "";
|
|
|
|
if (!found) {
|
|
|
|
this.selectedResults.push(result);
|
|
|
|
|
|
|
|
UIkit.notification({
|
|
|
|
message : 'A new research result is selected.',
|
|
|
|
status : 'primary',
|
|
|
|
timeout : 1000,
|
|
|
|
pos : 'top-center'
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
this.warningMessage = "Research Data already in selected list";
|
|
|
|
UIkit.notification({
|
|
|
|
message : 'The research result is already on your list.',
|
|
|
|
status : 'warning',
|
|
|
|
timeout : 1000,
|
|
|
|
pos : 'top-center'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchSourceChanged(source){
|
|
|
|
this.searchSource = source;
|
|
|
|
this.activeTab = (source == "openaire" || source == "all")?"openairePub":source;
|
|
|
|
if(this.keyword && this.keyword.length > 0){
|
|
|
|
this.search(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public clickTab(tab){
|
|
|
|
this.activeTab = tab;
|
|
|
|
}
|
|
|
|
}
|