2019-07-23 14:23:12 +02:00
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {ClaimEntity, ClaimProject, ShowOptions} from '../claim-utils/claimHelper.class';
|
|
|
|
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
|
2019-09-11 11:45:54 +02:00
|
|
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
2019-07-23 14:23:12 +02:00
|
|
|
import {LinkingGenericComponent} from "../linking/linkingGeneric.component";
|
|
|
|
import {ClaimResultSearchFormComponent} from "../claim-utils/claimResultSearchForm.component";
|
2020-11-11 15:43:13 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-11-18 17:06:27 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
import {OpenaireEntities} from "../../utils/properties/searchFields";
|
2022-06-03 12:01:55 +02:00
|
|
|
import {StringUtils} from "../../utils/string-utils.class";
|
2023-03-16 12:57:33 +01:00
|
|
|
import {ClaimProjectsSearchFormComponent} from "../claim-utils/claimProjectSearchForm.component";
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2019-07-23 14:23:12 +02:00
|
|
|
selector: 'directLinking',
|
|
|
|
templateUrl: 'directLinking.component.html'
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
export class DirectLinkingComponent {
|
2019-07-23 14:23:12 +02:00
|
|
|
@ViewChild(LinkingGenericComponent) linking: LinkingGenericComponent;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
results: ClaimEntity[] = [];
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
// linkType: string = "project"; // link type (selected in home page) : project, context, software, etc
|
2017-12-19 13:53:46 +01:00
|
|
|
/* url Parameters for inline linking */
|
2019-07-23 14:23:12 +02:00
|
|
|
id: string = null; //entity id
|
|
|
|
type: string = null; // entity type (publication or dataset)
|
|
|
|
// linkTo: string = null; // entity type (project or context or entity)
|
|
|
|
// linkToEntities: string[] = [];
|
|
|
|
showOptions:ShowOptions = new ShowOptions();
|
|
|
|
validEntityTypes = ["dataset", "publication", "software", "orp", "project", "context"];
|
|
|
|
sources: ClaimEntity[] = [];
|
|
|
|
inlineEntity: ClaimEntity = null;
|
|
|
|
validInput: boolean = null;//'true;
|
|
|
|
properties: EnvProperties;
|
|
|
|
@Input() communityId: string = null;
|
|
|
|
localStoragePrefix: string = "";
|
|
|
|
constructor(private _router: Router, private route: ActivatedRoute,private entitySearch:EntitiesSearchService,
|
2019-09-11 11:45:54 +02:00
|
|
|
private _searchResearchResultsService: SearchResearchResultsService) {}
|
2020-11-11 15:43:13 +01:00
|
|
|
subscriptions = [];
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
ngOnInit() {
|
2020-11-18 17:06:27 +01:00
|
|
|
this.properties = properties;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
2019-07-23 14:23:12 +02:00
|
|
|
this.id = params['id'];
|
|
|
|
this.type = params['type'];
|
|
|
|
this.showOptions.linkTo = params['linkTo'];
|
|
|
|
if (this.type != null && this.showOptions.linkTo != null) {
|
|
|
|
this.type = (this.validEntityTypes.indexOf(this.type) != -1) ? this.type : 'publication';
|
|
|
|
this.showOptions.linkTo = (this.validEntityTypes.indexOf(this.showOptions.linkTo) != -1 || this.showOptions.linkTo == "result") ? this.showOptions.linkTo : 'project';
|
|
|
|
this.localStoragePrefix = (this.communityId ? (this.communityId + "_") : '') + this.type.substr(0, 3) + "_" + this.showOptions.linkTo.substr(0, 3) + "_";
|
|
|
|
|
|
|
|
if (localStorage.getItem(this.localStoragePrefix + "results")) {
|
|
|
|
this.results = JSON.parse(localStorage.getItem(this.localStoragePrefix + "results"));
|
|
|
|
}
|
|
|
|
if (localStorage.getItem(this.localStoragePrefix + "sources")) {
|
|
|
|
this.sources = JSON.parse(localStorage.getItem(this.localStoragePrefix + "sources"));
|
|
|
|
}
|
|
|
|
//console.log("\n\nGetting inline entity "+this.type+"\n\n");
|
|
|
|
if (this.type == "project") {
|
|
|
|
// this.linkType = "project";
|
|
|
|
this.getProjectById(this.id);
|
|
|
|
} else if (this.type == "publication") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.getResearchResultById("publication", this.id);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (this.type == "dataset") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.getResearchResultById("dataset", this.id);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (this.type == "software") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.getResearchResultById("software", this.id);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (this.type == "orp") {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.getResearchResultById("other", this.id);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
}
|
|
|
|
//set which entities it is allowed to link to.
|
|
|
|
// add first the
|
|
|
|
if(this.type == "project"){
|
|
|
|
this.showOptions.linkToEntities = ["result"];
|
|
|
|
this.showOptions.linkTo = "result";
|
|
|
|
}else{
|
|
|
|
// entity type (project or context or entity)
|
|
|
|
if(this.showOptions.linkTo == "project"){
|
|
|
|
this.showOptions.linkToEntities = ["project","context" ,"result"];
|
|
|
|
}else if(this.showOptions.linkTo == "context"){
|
|
|
|
this.showOptions.linkToEntities = ["context","project", "result" ];
|
|
|
|
}else{
|
|
|
|
this.showOptions.linkTo = "result";
|
|
|
|
this.showOptions.linkToEntities = ["result","project","context" ];
|
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
|
|
|
} else {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
isValidInput(result: ClaimEntity) {
|
|
|
|
if (result == null) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (this.type == "project" && this.showOptions.linkTo != "result") {
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (["dataset", "publication", "software", "orp"].indexOf(this.type) != -1 && (["project", "context", "result"].indexOf(this.showOptions.linkTo) == -1)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (["project", "dataset", "publication", "software", "orp"].indexOf(this.type) == -1) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
2017-12-19 13:53:46 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
getProjectById(id: string) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this.entitySearch.fetchByType(id,"project", this.properties).subscribe(
|
2019-07-23 14:23:12 +02:00
|
|
|
data => {
|
|
|
|
this.createClaimEntity(data, "project");
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
//console.log("An error occured")
|
|
|
|
this.handleError("Error getting project by id: " + id, 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-09-16 11:34:49 +02:00
|
|
|
getResearchResultById(resultType: string, id: string) {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchResearchResultsService.searchById(resultType, id, this.properties).subscribe(data => {
|
2019-09-16 11:34:49 +02:00
|
|
|
this.createClaimEntity(data, resultType);
|
2019-07-23 14:23:12 +02:00
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
//console.log("An error occured")
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
this.handleError("Error getting "+this.getEntityName(resultType, false)+" by id: " + id, err);
|
2020-11-11 15:43:13 +01:00
|
|
|
}));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
createClaimEntity(data, type: string) {
|
|
|
|
let results: ClaimEntity[] =[] ;
|
|
|
|
if(type =="project"){
|
|
|
|
let project = data[0];
|
|
|
|
let entity:ClaimEntity = new ClaimEntity();
|
|
|
|
entity.id = project.id;
|
|
|
|
entity.type = "project";
|
|
|
|
entity.title = project.projectName;
|
|
|
|
entity.project = new ClaimProject();
|
2023-03-01 10:59:48 +01:00
|
|
|
entity.project.url = properties.searchLinkToProject + entity.id;
|
2019-07-23 14:23:12 +02:00
|
|
|
entity.project.acronym = project.projectAcronym;
|
|
|
|
entity.project.code = project.code;
|
|
|
|
entity.project.endDate = project.endDate;
|
|
|
|
entity.project.funderId = project.funderId;
|
|
|
|
entity.project.funderName = project.funderName;
|
|
|
|
entity.project.fundingLevel0 = project.fundingLevel0;
|
|
|
|
entity.project.jurisdiction = project.jurisdiction;
|
|
|
|
entity.project.startDate = project.startDate;
|
|
|
|
this.inlineEntity = entity;
|
|
|
|
}else{
|
2020-08-10 17:14:48 +02:00
|
|
|
results = ClaimResultSearchFormComponent.openaire2ClaimResults(data, this.properties);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (results.length > 0) {
|
|
|
|
this.inlineEntity = results[0]
|
|
|
|
}
|
|
|
|
this.validInput = this.isValidInput(this.inlineEntity);
|
|
|
|
}
|
2019-02-18 15:00:43 +01:00
|
|
|
|
|
|
|
private handleError(message: string, error) {
|
2019-07-23 14:23:12 +02:00
|
|
|
console.error("Direct Linking Page: " + message, error);
|
2019-02-18 15:00:43 +01:00
|
|
|
}
|
2019-09-16 11:34:49 +02:00
|
|
|
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
private getEntityName (entityType:string, plural:boolean) {
|
2022-06-03 12:01:55 +02:00
|
|
|
return StringUtils.getEntityName(entityType, plural);
|
2019-09-16 11:34:49 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|