2019-07-23 14:23:12 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {SearchCrossrefService} from './service/searchCrossref.service';
|
|
|
|
import {SearchOrcidService} from './service/searchOrcid.service';
|
2019-09-11 11:45:54 +02:00
|
|
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
2019-07-23 14:23:12 +02:00
|
|
|
import {SearchDataciteService} from './service/searchDatacite.service';
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {ClaimEntity, ClaimResult} from './claimHelper.class';
|
|
|
|
import {DOI, StringUtils} from '../../utils/string-utils.class';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class";
|
2021-07-14 13:19:57 +02:00
|
|
|
import {forkJoin, Observable, Subscriber} from 'rxjs';
|
2020-05-14 16:38:50 +02:00
|
|
|
import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component";
|
|
|
|
import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class";
|
2022-04-08 15:55:22 +02:00
|
|
|
import {OpenaireEntities, SearchFields} from "../../utils/properties/searchFields";
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2019-07-23 14:23:12 +02:00
|
|
|
selector: 'claim-result-search-form',
|
|
|
|
templateUrl: 'claimResultSearchForm.component.html',
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
})
|
|
|
|
export class ClaimResultSearchFormComponent {
|
2019-07-23 14:23:12 +02:00
|
|
|
page: number = 1;
|
|
|
|
size: number = 5;
|
|
|
|
source: string = "datacite";
|
|
|
|
type: string = "dataset";
|
|
|
|
showSearchResults: boolean = false;
|
2023-02-15 22:56:16 +01:00
|
|
|
@Input() public centerAlign: boolean = false;
|
2019-07-23 14:23:12 +02:00
|
|
|
@Input() public select: boolean = true;
|
|
|
|
@Input() public keyword: string = '';
|
|
|
|
@Input() public selectedResults: ClaimEntity[];
|
|
|
|
@Input() public properties: EnvProperties;
|
|
|
|
@Input() localStoragePrefix: string = "";
|
2019-07-24 14:46:29 +02:00
|
|
|
@Input() basketLimit;
|
2022-03-16 17:54:22 +01:00
|
|
|
@Input() showOptions;
|
2022-04-08 15:55:22 +02:00
|
|
|
openaireEntities = OpenaireEntities;
|
2019-07-23 14:23:12 +02:00
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
dataciteResults: ClaimEntity[] = [];
|
|
|
|
dataciteResultsNum: number = null;
|
|
|
|
dataciteStatus = this.errorCodes.NONE;
|
|
|
|
datacitePage: number = 1;
|
|
|
|
|
|
|
|
public warningMessage = "";
|
|
|
|
public infoMessage = "";
|
|
|
|
|
|
|
|
public todayDate = '';
|
|
|
|
public nextDate = '';
|
|
|
|
public DOIs: string[] = [];
|
|
|
|
sub: any;
|
|
|
|
public activeTab: string = "openaire";
|
|
|
|
|
|
|
|
|
|
|
|
crossrefResults: ClaimEntity[] = [];
|
|
|
|
crossrefResultsNum: number = null;
|
|
|
|
crossrefPage: number = 1;
|
|
|
|
crossrefStatus: number = this.errorCodes.NONE;
|
|
|
|
|
|
|
|
openaireTypeValues = [
|
|
|
|
{title: "Publications", value: "publication", count: null},
|
|
|
|
{title: "Research Data", value: "dataset", count: null},
|
|
|
|
{title: "Software", value: "software", count: null},
|
|
|
|
{title: "Other research products", value: "other", count: null}];
|
|
|
|
totalOpenaireCount:number = 0;
|
|
|
|
openaireResultsfilters = [];
|
|
|
|
openaireResultsPrevFilters = [];
|
|
|
|
openaireYear = "";
|
|
|
|
|
|
|
|
// public openaireRefineFields: string[] = ["relfunder", "relproject", "resultbestaccessright", "instancetypename", "resultlanguagename", "community"];
|
|
|
|
// public openaireRefineFieldsQuery: string = "&refine=true&fields=relfunder&fields=relproject&fields=resultacceptanceyear&fields=resultbestaccessright&fields=instancetypename&fields=resultlanguagename&fields=community";
|
2020-05-14 16:38:50 +02:00
|
|
|
public openaireRefineFields: string[] = ["resulttypeid","relfunder", "resultbestaccessright", "instancetypename"];
|
|
|
|
public openaireRefineFieldsQuery: string = "&refine=true&fields=resulttypeid&fields=relfunder&fields=resultbestaccessright&fields=instancetypename";
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
// public fieldIdsMap=this.searchFields.RESULT_FIELDS;
|
|
|
|
openaireResults: ClaimEntity[] = [];
|
|
|
|
openaireResultsNum: number;
|
|
|
|
openaireResultsPage: number = 1;
|
|
|
|
openaireResultsStatus: number = this.errorCodes.NONE;
|
2020-05-14 16:38:50 +02:00
|
|
|
// openaireResultsType = "publication";
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
orcidResults: ClaimEntity[];
|
|
|
|
orcidResultsNum: number;
|
|
|
|
totalPages: number;
|
|
|
|
orcidResultsToShow: ClaimEntity[];
|
|
|
|
orcidPage: number = 1;
|
|
|
|
orcidStatus: number = this.errorCodes.NONE;
|
|
|
|
authorId: string;
|
|
|
|
selectAuthorId: string = "0";
|
|
|
|
authorGivenName: string;
|
|
|
|
authorFamilyName: string;
|
|
|
|
|
|
|
|
authorIds: string[];
|
|
|
|
authors = [];
|
|
|
|
|
|
|
|
reloadOpenaire: boolean = true;
|
|
|
|
reloadCrossref: boolean = false;
|
|
|
|
reloadDatacite: boolean = false;
|
|
|
|
reloadOrcid: boolean = false;
|
|
|
|
|
2020-05-14 16:38:50 +02:00
|
|
|
//new search
|
|
|
|
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
|
|
|
filter: null,
|
|
|
|
selected: true,
|
|
|
|
filterId: "resultbestaccessright",
|
|
|
|
value: "Open Access"
|
|
|
|
};
|
|
|
|
|
|
|
|
resultTypes = {publication: true, dataset: true, software: true, other: true};
|
|
|
|
public rangeFilters: RangeFilter[] = [];
|
|
|
|
public searchFields: SearchFields = new SearchFields();
|
|
|
|
public rangeFields:string[][] = this.searchFields.RESULT_RANGE_FIELDS;
|
2019-09-11 11:45:54 +02:00
|
|
|
constructor(private _searchDataciteService: SearchDataciteService,
|
|
|
|
private _searchCrossrefService: SearchCrossrefService,
|
|
|
|
private _searchOrcidService: SearchOrcidService,
|
|
|
|
private _searchResearchResultsService: SearchResearchResultsService) {
|
2019-07-23 14:23:12 +02:00
|
|
|
const myDate = new Date();
|
|
|
|
this.todayDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
|
|
|
|
this.nextDate = (myDate.getFullYear() + 100) + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
|
2020-05-14 16:38:50 +02:00
|
|
|
this.rangeFilters = RangeFilter.parse(this.rangeFields,"result");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
ngOnInit() {
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.keyword != null && this.keyword.length > 0) {
|
|
|
|
this.search(false);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
subscriptions = [];
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
search(keywordChanged) {
|
|
|
|
//uncomment to disable search with no keyword
|
|
|
|
if (this.keyword.length == 0) {
|
|
|
|
this.totalOpenaireCount = 0;
|
|
|
|
this.crossrefResultsNum = null;
|
|
|
|
this.dataciteResultsNum = null;
|
|
|
|
this.openaireResultsNum = null;
|
|
|
|
this.orcidResultsNum = null;
|
|
|
|
this.openaireResults = [];
|
|
|
|
this.crossrefResults = [];
|
|
|
|
this.dataciteResults = [];
|
|
|
|
this.orcidResultsToShow = [];
|
|
|
|
this.showSearchResults = false;
|
|
|
|
return;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
2019-07-23 14:23:12 +02:00
|
|
|
this.showSearchResults = false;
|
|
|
|
if (keywordChanged) {
|
|
|
|
// this.activeTab = "openaire";
|
2017-12-19 13:53:46 +01:00
|
|
|
this.DOIs = DOI.getDOIsFromString(this.keyword);
|
|
|
|
this.reloadOpenaire = true;
|
|
|
|
this.reloadCrossref = true;
|
|
|
|
this.reloadDatacite = true;
|
|
|
|
this.reloadOrcid = true;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.crossrefResultsNum = null;
|
|
|
|
this.dataciteResultsNum = null;
|
|
|
|
this.openaireResultsNum = null;
|
|
|
|
this.orcidResultsNum = null;
|
|
|
|
// this.openaireResultsType = "publication";
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
if (this.reloadOpenaire) {
|
|
|
|
this.openaireResults = [];
|
|
|
|
this.searchOpenaire(this.keyword, this.size, 1, keywordChanged);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.reloadOpenaire = false;
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.reloadCrossref) {
|
2018-05-25 15:07:18 +02:00
|
|
|
this.crossrefResults = [];
|
2019-07-23 14:23:12 +02:00
|
|
|
this.getCrossrefResults(this.keyword, this.size, 1);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.reloadCrossref = false;
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.reloadDatacite) {
|
|
|
|
this.dataciteResults = [];
|
|
|
|
this.searchDatacite(this.keyword, this.size, 1);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.reloadDatacite = false;
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.reloadOrcid) {
|
|
|
|
this.orcidResultsToShow = [];
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchOrcid(this.keyword);
|
|
|
|
this.reloadOrcid = false;
|
|
|
|
}
|
|
|
|
this.showSearchResults = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
searchOpenaire(keyword, size, page, keywordChanged) {
|
2020-05-14 16:38:50 +02:00
|
|
|
this.searchResearchResults("publication", keyword, size, page, true, "publication");
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private getCrossrefResults(term: string, size: number, page: number) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.crossrefStatus = this.errorCodes.LOADING;
|
2019-07-23 14:23:12 +02:00
|
|
|
// this.crossrefResultsNum = null;
|
|
|
|
if (this.DOIs.length > 0) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties, true).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2019-07-23 14:23:12 +02:00
|
|
|
if (data != null) {
|
|
|
|
this.crossrefResults = data[1];
|
|
|
|
this.crossrefPage = page;
|
|
|
|
this.crossrefResultsNum = data[0];
|
|
|
|
if (this.crossrefResultsNum == 0) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
if (data != null) {
|
|
|
|
this.crossrefResults = data[1];
|
|
|
|
this.crossrefPage = page;
|
|
|
|
this.crossrefResultsNum = data[0];
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
// console.log("Crossref " + this.crossrefResultsNum);
|
|
|
|
if (this.crossrefResultsNum == 0) {
|
|
|
|
this.crossrefStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err.status);
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
},
|
2017-12-19 13:53:46 +01:00
|
|
|
err => {
|
2019-07-23 14:23:12 +02:00
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + JSON.stringify(this.DOIs), err);
|
2019-02-18 15:00:43 +01:00
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2019-07-23 14:23:12 +02:00
|
|
|
this.crossrefResults = data[1];
|
|
|
|
this.crossrefPage = page;
|
|
|
|
this.crossrefResultsNum = data[0];
|
2017-12-19 13:53:46 +01:00
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
},
|
2017-12-19 13:53:46 +01:00
|
|
|
err => {
|
2019-02-18 15:00:43 +01:00
|
|
|
//console.log(err.status);
|
2019-07-23 14:23:12 +02:00
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2019-07-23 14:23:12 +02:00
|
|
|
if (data != null) {
|
|
|
|
this.crossrefResults = data[1];
|
|
|
|
this.crossrefPage = page;
|
|
|
|
this.crossrefResultsNum = data[0];
|
|
|
|
this.crossrefStatus = this.errorCodes.DONE;
|
|
|
|
if (this.crossrefResultsNum == 0) {
|
|
|
|
this.crossrefStatus = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
},
|
2017-12-19 13:53:46 +01:00
|
|
|
err => {
|
2019-02-18 15:00:43 +01:00
|
|
|
//console.log(err.status);
|
2019-07-23 14:23:12 +02:00
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.crossrefStatus = this.errorCodes.ERROR;
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:38:50 +02:00
|
|
|
/*private callOpenaireService(term: string, size: number, page: number, mainResults: boolean, type) {
|
2019-07-23 14:23:12 +02:00
|
|
|
if (mainResults) {
|
|
|
|
this.openaireResultsStatus = this.errorCodes.LOADING;
|
|
|
|
this.openaireResultsPrevFilters = this.openaireResultsfilters;
|
|
|
|
}
|
|
|
|
if((mainResults && page==1 )||!mainResults){
|
|
|
|
this.setOpenaireResultsCount(type, null);
|
|
|
|
this.totalOpenaireCount = 0;
|
|
|
|
}
|
|
|
|
if (type == "dataset") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.searchResearchResults("dataset", term, size, page, mainResults, type);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (type == "software") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.searchResearchResults("software", term, size, page, mainResults, type);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (type == "other") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.searchResearchResults("other", term, size, page, mainResults, type);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.searchResearchResults("publication", term, size, page, mainResults, type);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-14 16:38:50 +02:00
|
|
|
}*/
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-16 11:34:49 +02:00
|
|
|
public searchResearchResults(resultType: string, term: string, size: number, page: number, mainResults: boolean, type) {
|
2020-05-14 16:38:50 +02:00
|
|
|
this.openaireResultsStatus = this.errorCodes.LOADING;
|
|
|
|
this.openaireResultsPrevFilters = this.openaireResultsfilters;
|
|
|
|
this.openaireResultsNum = 0;
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchResearchResultsService.advancedSearchResults('publication', this.createOpenaireQueryParams(), page, size, null, this.properties, this.createOpenaireRefineQueryParams(), (page==1 ?this.openaireRefineFields:[]), (page==1 ?this.openaireRefineFieldsQuery:null)).subscribe(
|
2019-09-16 11:34:49 +02:00
|
|
|
data => {
|
|
|
|
this.setOpenaireResults(data, mainResults, page, type);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.setOpenaireResultsError(mainResults, term, err);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-09-16 11:34:49 +02:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
public setOpenaireResults(data, mainResults: boolean, page, type) {
|
|
|
|
if (data != null) {
|
2020-05-14 16:38:50 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
this.openaireResultsPage = page;
|
|
|
|
this.openaireResultsNum = data[0];
|
2020-05-14 16:38:50 +02:00
|
|
|
// this.setOpenaireResultsCount(type, this.openaireResultsNum);
|
2019-07-23 14:23:12 +02:00
|
|
|
if(data[2] && data[2].length > 0){
|
|
|
|
this.openaireResultsfilters = this.checkSelectedFilters(data[2], this.openaireResultsPrevFilters)
|
|
|
|
}
|
2020-08-07 12:27:50 +02:00
|
|
|
this.openaireResults = ClaimResultSearchFormComponent.openaire2ClaimResults(data[1], this.properties);
|
2019-07-23 14:23:12 +02:00
|
|
|
this.openaireResultsStatus = this.errorCodes.DONE;
|
|
|
|
if (this.openaireResultsNum == 0) {
|
|
|
|
this.openaireResultsStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mainResults) {
|
|
|
|
this.openaireResultsStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public setOpenaireResultsError(mainResults: boolean, term, err) {
|
|
|
|
if (mainResults) {
|
|
|
|
this.openaireResultsStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting publications for term: " + term, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
setOpenaireResultsCount(type, count) {
|
|
|
|
if (type == "dataset") {
|
|
|
|
this.openaireTypeValues[1]['count'] = count;
|
|
|
|
} else if (type == "software") {
|
|
|
|
this.openaireTypeValues[2]['count'] = count;
|
|
|
|
} else if (type == "other") {
|
|
|
|
this.openaireTypeValues[3]['count'] = count;
|
|
|
|
} else {
|
|
|
|
this.openaireTypeValues[0]['count'] = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private searchOrcid(term: string) {
|
|
|
|
if (this.DOIs.length > 0 || term.length == 0) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.orcidResultsNum = -1;
|
2017-12-19 13:53:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
|
|
|
this.authorIds = new Array<string>();
|
2019-07-23 14:23:12 +02:00
|
|
|
this.authors = [];
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
this.getOrcidAuthor(term, true);
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
/*private readData(data: any) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.authorIds.push(data[2].path);
|
2019-07-23 14:23:12 +02:00
|
|
|
var author = {};
|
|
|
|
author['id'] = data[2].path;
|
|
|
|
if (data[0] != null) {
|
|
|
|
author['authorGivenName'] = data[0].value;
|
2017-12-19 13:53:46 +01:00
|
|
|
} else {
|
2019-07-23 14:23:12 +02:00
|
|
|
author['authorGivenName'] = "";
|
|
|
|
}
|
|
|
|
if (data[1] != null) {
|
|
|
|
author['authorFamilyName'] = data[1].value;
|
|
|
|
} else {
|
|
|
|
author['authorFamilyName'] = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-05-02 14:26:54 +02:00
|
|
|
this.authors.push(author);
|
2019-07-23 14:23:12 +02:00
|
|
|
}*/
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private getOrcidAuthor(term: string, addId) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.orcidResultsNum = null;
|
|
|
|
//passing structures in order to fill them in service
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchOrcidService.searchOrcidAuthor(StringUtils.URIEncode(term.replace(/\s/g, "")), this.authorIds,
|
2018-05-02 14:26:54 +02:00
|
|
|
this.authors, this.properties, addId).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
if (data != null && data == true && addId) {
|
|
|
|
this.getOrcidResults(0);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
// this.orcidStatus = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
},
|
|
|
|
err => this.errorHandler(err, term)
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private errorHandler(err: any, term: string) {
|
|
|
|
if (err.status == 404) {
|
|
|
|
this.getOrcidAuthors(term);
|
|
|
|
} else {
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
//console.log(err.status);
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting orcid author for term: " + term, err);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private getOrcidAuthors(term: string) {
|
|
|
|
this.orcidResultsNum = null;
|
|
|
|
this.selectAuthorId = "0";
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
|
|
|
//passing structures in order to fill them in service
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchOrcidService.searchOrcidAuthors(StringUtils.URIEncode(term), this.properties).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
this.authorIds = data;
|
|
|
|
if (data != null) {
|
|
|
|
for (let i = 0; i < this.authorIds.length; i++) {
|
|
|
|
this.getOrcidAuthor(this.authorIds[i], (i == 0));
|
|
|
|
}
|
|
|
|
if (this.authorIds.length == 0) {
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
|
|
|
this.orcidResultsNum = -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
2019-02-18 15:00:43 +01:00
|
|
|
//console.log(err.status);
|
2019-07-23 14:23:12 +02:00
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting orcid authors for term: " + term + " and ids: " + JSON.stringify(this.authorIds), err);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private getOrcidResultsById(id) {
|
|
|
|
for (let i = 0; i < this.authors.length; i++) {
|
|
|
|
if (this.authors[i].id == id) {
|
|
|
|
this.getOrcidResults(i);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private getOrcidResults(index) {
|
|
|
|
this.authorGivenName = this.authors[index].authorGivenName;
|
|
|
|
this.authorFamilyName = this.authors[index].authorFamilyName;
|
|
|
|
this.authorId = this.authors[index].id;
|
|
|
|
this.orcidStatus = this.errorCodes.LOADING;
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchOrcidService.searchOrcidPublications(this.authors[index].id, this.properties, true).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
if (data != null) {
|
|
|
|
this.orcidResults = data;
|
|
|
|
this.orcidResultsNum = data.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));
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
this.orcidResultsToShow = this.orcidResults.slice(0, 10);
|
|
|
|
|
|
|
|
this.orcidStatus = this.errorCodes.DONE;
|
|
|
|
if (this.orcidResultsNum == 0) {
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
2018-05-02 14:26:54 +02:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
for (let i = 0; i < this.orcidResults.length; i++) {
|
|
|
|
const entity: ClaimEntity = this.orcidResults[i];
|
|
|
|
if (!entity.result.authors) {
|
|
|
|
entity.result.authors = [];
|
|
|
|
}
|
|
|
|
entity.result.authors.push(this.authorFamilyName + ', ' + this.authorGivenName);
|
|
|
|
if (entity.result.DOI != null) {
|
|
|
|
this.enhanceInfoFromDOI(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.orcidResultsNum = 0;
|
|
|
|
this.totalPages = 0;
|
|
|
|
this.orcidStatus = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err.status);
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting orcid publications for author id: " + this.authors[index].id, err);
|
|
|
|
this.orcidStatus = this.errorCodes.ERROR;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private enhanceInfoFromDOI(entity: ClaimEntity) {
|
|
|
|
|
|
|
|
if (entity.result.DOI != null) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties, true).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
if (data != null && data[0] > 0 && data[1]) {
|
|
|
|
let crossrefResult: ClaimEntity = data[1][0];
|
|
|
|
if (entity.title == null || entity.title == "") {
|
|
|
|
entity.title = crossrefResult.title;
|
|
|
|
}
|
|
|
|
if (crossrefResult.result.authors) {
|
|
|
|
entity.result.authors = [];
|
|
|
|
for (let i = 0; i < crossrefResult.result.authors.length; i++) {
|
|
|
|
entity.result.authors.push(crossrefResult.result.authors[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (entity.result.journal == null || entity.result.journal == "") {
|
|
|
|
entity.result.journal = crossrefResult.result.journal;
|
|
|
|
}
|
|
|
|
if (entity.result.publisher == null || entity.result.publisher == "") {
|
|
|
|
entity.result.publisher = crossrefResult.result.publisher;
|
|
|
|
}
|
|
|
|
if (entity.result.date == null || entity.result.date == "") {
|
|
|
|
entity.result.date = crossrefResult.result.date;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + entity['DOI'], err);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private crossrefPageChange($event) {
|
|
|
|
this.crossrefPage = $event.value;
|
|
|
|
this.crossrefResults = [];
|
|
|
|
this.getCrossrefResults(this.keyword, this.size, this.crossrefPage);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private orcidPageChange($event) {
|
|
|
|
this.orcidPage = $event.value;
|
|
|
|
this.orcidResultsToShow = [];
|
|
|
|
this.orcidResultsToShow = this.orcidResults.slice(($event.value - 1) * this.size, $event.value * this.size);
|
|
|
|
}
|
2018-05-03 11:58:30 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private openaireResultsPageChange($event) {
|
|
|
|
this.openaireResultsPage = $event.value;
|
|
|
|
this.openaireResults = [];
|
|
|
|
this.searchOpenaire(this.keyword, this.size, this.openaireResultsPage, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
datacitePageChange($event) {
|
|
|
|
this.datacitePage = $event.value;
|
|
|
|
this.dataciteResults = [];
|
|
|
|
this.searchDatacite(this.keyword, 10, this.datacitePage);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
2018-05-03 11:58:30 +02:00
|
|
|
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private searchDatacite(term: string, size: number, page: number) {
|
|
|
|
this.getDataciteResults(term, size, page);
|
|
|
|
this.warningMessage = "";
|
|
|
|
this.infoMessage = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
createOpenaireQueryParams():string {
|
|
|
|
let query = "";
|
2020-05-14 16:38:50 +02:00
|
|
|
/* if (this.DOIs.length > 0) {
|
2019-07-23 14:23:12 +02:00
|
|
|
let doisParams = "";
|
|
|
|
for (let i = 0; i < this.DOIs.length; i++) {
|
|
|
|
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + this.DOIs[i] + '"';
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
query += doisParams;
|
|
|
|
} else if(this.keyword.length > 0){
|
|
|
|
query += "q=" + StringUtils.quote(StringUtils.URIEncode(this.keyword));
|
2020-05-14 16:38:50 +02:00
|
|
|
}*/
|
|
|
|
if(this.keyword.length>0){
|
|
|
|
query+=NewSearchPageComponent.createKeywordQuery("result",this.keyword,"q","=");
|
|
|
|
}
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
createOpenaireRefineQueryParams():string {
|
|
|
|
let allFqs = "";
|
2019-07-23 14:23:12 +02:00
|
|
|
if(this.openaireYear.length > 0 ){
|
2020-05-14 16:38:50 +02:00
|
|
|
allFqs+='&fq=resultacceptanceyear exact \"'+this.openaireYear+'\"'
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
for (let filter of this.openaireResultsfilters){
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
let count_selected=0;
|
|
|
|
let fq = "";
|
|
|
|
for (let value of filter.values){
|
|
|
|
if(value.selected == true){
|
|
|
|
count_selected++;
|
|
|
|
fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + (StringUtils.quote(value.id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(count_selected > 0){
|
|
|
|
fq="&fq="+StringUtils.URIEncode(fq);
|
|
|
|
allFqs += fq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
for (let i=0; i<this.rangeFilters.length; i++){
|
|
|
|
let filter = this.rangeFilters[i];
|
|
|
|
//selectedFromValue, selectedToValue, equalityOp, equalityOpFrom, equalityOpTo, filterOp ){
|
|
|
|
allFqs+= NewSearchPageComponent.createRangeFilterQuery(this.rangeFields[i],filter.selectedFromValue, filter.selectedToValue, " within ", ">=" ,"<=", "and" )
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.resultTypes.publication && this.resultTypes.dataset && this.resultTypes.software && this.resultTypes.other){
|
|
|
|
allFqs += "&type=results";
|
|
|
|
}else{
|
|
|
|
if(this.resultTypes.publication) {
|
|
|
|
allFqs += "&type=publications";
|
|
|
|
}
|
|
|
|
if(this.resultTypes.dataset) {
|
|
|
|
allFqs += "&type=datasets";
|
|
|
|
}
|
|
|
|
if(this.resultTypes.software) {
|
|
|
|
allFqs += "&type=software";
|
|
|
|
}
|
|
|
|
if(this.resultTypes.other) {
|
|
|
|
allFqs += "&type=other";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return allFqs;
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-07 12:27:50 +02:00
|
|
|
public static openaire2ClaimResults(data, properties): ClaimEntity[] {
|
2019-07-23 14:23:12 +02:00
|
|
|
const claimResults = [];
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
let item = data[i];
|
|
|
|
let entity: ClaimEntity = new ClaimEntity();
|
|
|
|
entity.result = new ClaimResult();
|
|
|
|
entity.result.publisher = (item.publisher && item.publisher != "") ? item.publisher : null;
|
|
|
|
entity.result.journal = null;
|
|
|
|
entity.result.DOI = null;
|
|
|
|
entity.id = item.id;
|
|
|
|
entity.title = item.title.name;
|
2019-10-16 12:18:32 +02:00
|
|
|
let prefixUrl = "";
|
2020-08-07 12:27:50 +02:00
|
|
|
if(item.entityType == "publication"){
|
2019-10-16 12:18:32 +02:00
|
|
|
prefixUrl = properties.searchLinkToPublication;
|
2020-08-07 12:27:50 +02:00
|
|
|
}else if(item.entityType == "dataset"){
|
2019-10-16 12:18:32 +02:00
|
|
|
prefixUrl = properties.searchLinkToDataset;
|
2020-08-07 12:27:50 +02:00
|
|
|
}else if(item.entityType == "software"){
|
2019-10-16 12:18:32 +02:00
|
|
|
prefixUrl = properties.searchLinkToSoftwareLanding;
|
2020-08-07 12:27:50 +02:00
|
|
|
}else if(item.entityType == "other"){
|
2019-10-16 12:18:32 +02:00
|
|
|
prefixUrl = properties.searchLinkToOrp;
|
|
|
|
}
|
|
|
|
entity.result.url = prefixUrl + entity.id;
|
2019-07-23 14:23:12 +02:00
|
|
|
entity.result.source = String("openaire");
|
|
|
|
entity.result.date = (item.year && item.year != "") ? item.year : null;
|
2020-03-12 11:46:02 +01:00
|
|
|
entity.result.accessRights = (item.title && item.title.accessMode) ? String(item.title.accessMode) : "";
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2020-08-07 12:27:50 +02:00
|
|
|
entity.type = item.entityType;
|
2019-07-23 14:23:12 +02:00
|
|
|
entity.result.embargoEndDate = (item.embargoEndDate && item.embargoEndDate != "") ? item.embargoEndDate : entity.result.embargoEndDate;
|
|
|
|
if (item.publisher && item.publisher.length > 0) {
|
|
|
|
entity.result.publisher = item.publisher;
|
|
|
|
}
|
|
|
|
entity.result.record = item;
|
|
|
|
if (item.authors) {
|
|
|
|
entity.result.authors = [];
|
|
|
|
for (let author of item.authors) {
|
|
|
|
entity.result.authors.push(author.fullName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
claimResults.push(entity);
|
|
|
|
}
|
|
|
|
return claimResults;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private getDataciteResults(term: string, size: number, page: number) {
|
|
|
|
this.dataciteStatus = this.errorCodes.LOADING;
|
|
|
|
if (this.DOIs.length > 0) {
|
2019-08-27 15:19:58 +02:00
|
|
|
let doiObservables: Array<Observable<any>> = new Array();
|
|
|
|
for(let doi of this.DOIs){
|
|
|
|
let ob = this._searchDataciteService.getDataciteResultByDOI(doi, this.properties, true);
|
|
|
|
doiObservables.push(ob);
|
|
|
|
|
|
|
|
}
|
2021-07-14 13:19:57 +02:00
|
|
|
this.subscriptions.push(forkJoin(doiObservables).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
2019-08-27 15:19:58 +02:00
|
|
|
//if DOI not found or an error occured the result will be null -- remove null values
|
|
|
|
for(let result of data){
|
|
|
|
if(result){
|
|
|
|
this.dataciteResults.push(result)
|
|
|
|
}
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
this.datacitePage = page;
|
2019-08-27 15:19:58 +02:00
|
|
|
this.dataciteResultsNum = this.dataciteResults.length;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.dataciteStatus = this.errorCodes.DONE;
|
|
|
|
if (this.dataciteResultsNum == 0) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
this.dataciteResults = data[1];
|
|
|
|
this.datacitePage = page;
|
|
|
|
this.dataciteResultsNum = data[0];
|
|
|
|
this.dataciteStatus = this.errorCodes.DONE;
|
|
|
|
if (this.dataciteResultsNum == 0) {
|
|
|
|
this.dataciteStatus = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2018-07-30 16:22:19 +02:00
|
|
|
},
|
2019-07-23 14:23:12 +02:00
|
|
|
err => {
|
2018-07-30 16:22:19 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
this.dataciteStatus = this.errorCodes.ERROR;
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err);
|
2020-11-11 15:43:13 +01:00
|
|
|
}));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2019-08-27 15:19:58 +02:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
|
|
|
|
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2019-07-23 14:23:12 +02:00
|
|
|
this.dataciteResults = data[1];
|
|
|
|
this.datacitePage = page;
|
|
|
|
this.dataciteResultsNum = data[0];
|
|
|
|
// console.log("Datacite " + this.dataciteResultsNum);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.dataciteStatus = this.errorCodes.DONE;
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.dataciteResultsNum == 0) {
|
|
|
|
this.dataciteStatus = this.errorCodes.NONE;
|
2018-10-17 14:10:30 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.dataciteStatus = this.errorCodes.ERROR;
|
2019-02-18 15:00:43 +01:00
|
|
|
//console.log(err);
|
2019-07-23 14:23:12 +02:00
|
|
|
ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 16:38:50 +02:00
|
|
|
public openaireTypeChanged() {
|
|
|
|
// this.openaireResultsType = type;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.reloadOpenaire = true;
|
|
|
|
this.openaireYear = "";
|
|
|
|
this.openaireResultsfilters = [];
|
|
|
|
this.search(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
public yearChanged() {
|
|
|
|
this.reloadOpenaire = true;
|
|
|
|
this.search(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public clickTab(tab) {
|
|
|
|
this.activeTab = tab;
|
|
|
|
// this.search(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static handleError(message: string, error) {
|
|
|
|
console.error("Claim Result Search Form (component): " + message, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
//OpenaireFilters:
|
|
|
|
|
|
|
|
getSelectedValues(filter): any {
|
|
|
|
var selected = [];
|
|
|
|
if (filter.countSelectedValues > 0) {
|
|
|
|
for (var i = 0; i < filter.values.length; i++) {
|
|
|
|
if (filter.values[i].selected) {
|
|
|
|
selected.push(filter.values[i]);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
return selected;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private removeFilter(value: Value, filter: Filter) {
|
|
|
|
filter.countSelectedValues--;
|
|
|
|
if (value.selected == true) {
|
|
|
|
value.selected = false;
|
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
// this.search(false);
|
|
|
|
this.filterChanged(null);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
public countFilters(): number {
|
|
|
|
let filters = 0;
|
|
|
|
for (let filter of this.openaireResultsfilters) {
|
|
|
|
if (filter.countSelectedValues > 0) {
|
|
|
|
filters += filter.countSelectedValues;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
for (let filter of this.rangeFilters) {
|
|
|
|
if (filter.selectedFromValue || filter.selectedToValue) {
|
|
|
|
filters += 1;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
return filters;
|
|
|
|
}
|
|
|
|
|
|
|
|
private clearFilters() {
|
|
|
|
for (let i = 0; i < this.openaireResultsfilters.length; i++) {
|
|
|
|
for (let j = 0; j < this.openaireResultsfilters[i].countSelectedValues; j++) {
|
|
|
|
if (this.openaireResultsfilters[i].values[j].selected) {
|
|
|
|
this.openaireResultsfilters[i].values[j].selected = false;
|
|
|
|
}
|
|
|
|
this.openaireResultsfilters[i].countSelectedValues = 0;
|
|
|
|
}
|
2019-02-18 15:00:43 +01:00
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
for(let filter of this.rangeFilters){
|
|
|
|
this.removeRangeFilter(filter);
|
|
|
|
}
|
|
|
|
this.filterChanged(null);
|
|
|
|
}
|
|
|
|
dateFilterChanged(filter:RangeFilter) {
|
|
|
|
if (filter.selectedFromValue && filter.selectedToValue) {
|
|
|
|
filter.selectedFromAndToValues = filter.selectedFromValue + "-" + filter.selectedToValue;
|
|
|
|
} else if (filter.selectedFromValue) {
|
|
|
|
filter.selectedFromAndToValues = "From " + filter.selectedFromValue;
|
|
|
|
} else if (filter.selectedToValue) {
|
|
|
|
filter.selectedFromAndToValues = "Until " + filter.selectedToValue;
|
|
|
|
}
|
|
|
|
this.filterChanged(null);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
filterChanged($event) {
|
|
|
|
// console.log("filterChanged");
|
|
|
|
this.reloadOpenaire = true;
|
|
|
|
this.search(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
public checkSelectedFilters(filters:Filter[], prevFilters:Filter[]){
|
|
|
|
for(let i=0; i< filters.length ; i++){
|
|
|
|
let filter:Filter = filters[i];
|
|
|
|
filter.countSelectedValues = 0;
|
|
|
|
let prevFilterSelectedValues:string[] = [];
|
|
|
|
for(let j=0; j< prevFilters.length ; j++){
|
|
|
|
if(filters[i].filterId == prevFilters[j].filterId){
|
|
|
|
if(prevFilters[j].countSelectedValues >0){
|
|
|
|
for(let filterValue of prevFilters[j].values) {
|
|
|
|
if(filterValue.selected){
|
|
|
|
prevFilterSelectedValues.push(filterValue.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(let filterValue of filter.values) {
|
|
|
|
if(prevFilterSelectedValues.indexOf(filterValue.id) > -1) {
|
|
|
|
filterValue.selected = true;
|
|
|
|
filter.countSelectedValues++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return filters;
|
|
|
|
}
|
|
|
|
countTotalPages(totalResults: number): number {
|
|
|
|
let totalPages:any = totalResults/(this.size);
|
|
|
|
if(!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
|
|
|
}
|
|
|
|
return totalPages;
|
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
/* getTotalOpenaireNumber():number{
|
2019-07-23 14:23:12 +02:00
|
|
|
let count = 0;
|
|
|
|
for(let i=0; i<this.openaireResultsType.length; i++){
|
|
|
|
if(this.openaireResultsType[i]["count]"]!=null){
|
|
|
|
count+= this.openaireResultsType[i]["count]"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
2020-05-14 16:38:50 +02:00
|
|
|
}*/
|
|
|
|
/* public _formatName(value, number){
|
2019-07-23 17:11:53 +02:00
|
|
|
let maxLineLength = 29;
|
|
|
|
//1 space after checkbox
|
|
|
|
//3 space before number + parenthesis
|
|
|
|
if(number && value.length+number.toLocaleString().length +1 +3> maxLineLength){
|
|
|
|
return value.substr(0, (maxLineLength- 3 -4 - number.toLocaleString().length))+'...';
|
|
|
|
}else if(!number && value.length + 1 > maxLineLength){
|
|
|
|
return value.substr(0, (maxLineLength- 3 -1 ))+'...';
|
|
|
|
}
|
|
|
|
return value;
|
2020-05-14 16:38:50 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
public removeRangeFilter(filter: RangeFilter) {
|
|
|
|
filter.selectedFromValue = null;
|
|
|
|
filter.selectedToValue = null;
|
|
|
|
filter.selectedFromAndToValues = null;
|
|
|
|
this.filterChanged(null);
|
2019-07-23 17:11:53 +02:00
|
|
|
}
|
2020-05-14 16:38:50 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|