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
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
|
|
|
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
|
|
|
|
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
|
|
|
|
|
|
|
|
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
|
|
|
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
|
|
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|
|
|
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
2018-07-30 16:22:19 +02:00
|
|
|
import {SearchOrpsService} from '../../services/searchOrps.service';
|
2018-11-14 11:38:53 +01:00
|
|
|
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
|
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({
|
|
|
|
selector: 'directLinking',
|
|
|
|
templateUrl: 'directLinking.component.html'
|
|
|
|
})
|
|
|
|
export class DirectLinkingComponent {
|
|
|
|
contexts=[];
|
|
|
|
projects=[];
|
|
|
|
|
|
|
|
results = [];
|
|
|
|
|
|
|
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
|
|
|
/* url Parameters for inline linking */
|
|
|
|
id:string = null; //entity id
|
|
|
|
type:string = null; // entity type (publication or dataset)
|
|
|
|
linkTo:string = null; // entity type (project or context or result)
|
|
|
|
|
2018-07-30 16:22:19 +02:00
|
|
|
entityTypes=["dataset", "publication","software","orp", "project","context"];
|
2017-12-19 13:53:46 +01:00
|
|
|
inlineResult:ClaimResult =null;
|
|
|
|
displayedResult:ClaimResult =null;
|
|
|
|
sub:any =null;
|
|
|
|
show:string="claim"; //{claim,result}
|
|
|
|
validInput:boolean = null;//'true;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
2018-07-25 15:56:02 +02:00
|
|
|
@Input() communityId:string= null;
|
|
|
|
localStoragePrefix:string = "";
|
2018-11-14 11:38:53 +01:00
|
|
|
url=null;
|
2018-02-05 14:14:59 +01:00
|
|
|
|
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
|
|
|
constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
|
|
|
|
private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService,
|
2018-07-30 16:22:19 +02:00
|
|
|
private softwareSearch:SearchSoftwareService,private ORPSearch:SearchOrpsService,
|
2018-11-14 11:38:53 +01:00
|
|
|
private _meta: Meta, private _title: Title, private seoService: SEOService ) {
|
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
|
|
|
|
|
|
|
var title = "OpenAIRE | Direct Linking";
|
|
|
|
|
|
|
|
this._meta.updateTag({content:title},"property='og:title'");
|
|
|
|
this._title.setTitle(title);
|
2018-11-14 11:38:53 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2018-11-14 11:38:53 +01:00
|
|
|
this.url = data.envSpecific.baseLink+this._router.url;
|
2019-02-11 16:03:38 +01:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
2018-02-05 14:14:59 +01:00
|
|
|
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.id = params['id'];
|
|
|
|
this.type = params['type'];
|
|
|
|
this.linkTo = params['linkTo'];
|
|
|
|
if(this.type!=null && this.linkTo!=null){
|
|
|
|
this.type = (this.entityTypes.indexOf(this.type) != -1)? this.type:'publication';
|
|
|
|
this.linkTo = (this.entityTypes.indexOf(this.linkTo) != -1 || this.linkTo == "result")? this.linkTo:'project';
|
|
|
|
this.show = (this.linkTo != "result")?"claim":"result";
|
|
|
|
this.linkType = this.linkTo;
|
|
|
|
var isInlineResult:boolean = false; // is a link result - result
|
2018-07-30 16:22:19 +02:00
|
|
|
if((this.type == "publication" || this.type == "dataset" || this.type == "software") && ((this.linkTo == "publication" || this.linkTo == "dataset" || this.linkTo == "software" || this.linkTo == "orp") || this.linkTo == "result" )){
|
2018-02-15 11:36:12 +01:00
|
|
|
isInlineResult = true;
|
|
|
|
}
|
2018-07-25 15:56:02 +02:00
|
|
|
this.localStoragePrefix = this.type.substr(0,3)+"_"+this.linkTo.substr(0,3)+"_";
|
|
|
|
console.log("\n\n"+this.localStoragePrefix+"\n\n");
|
|
|
|
if(localStorage.getItem(this.localStoragePrefix + "projects")){
|
|
|
|
this.projects = JSON.parse(localStorage.getItem(this.localStoragePrefix + "projects"));
|
|
|
|
}
|
|
|
|
if(localStorage.getItem(this.localStoragePrefix + "contexts")){
|
|
|
|
this.contexts = JSON.parse(localStorage.getItem(this.localStoragePrefix + "contexts"));
|
|
|
|
}
|
|
|
|
if(localStorage.getItem(this.localStoragePrefix + "results")){
|
|
|
|
this.results = JSON.parse(localStorage.getItem(this.localStoragePrefix + "results"));
|
|
|
|
}
|
2018-07-30 16:22:19 +02:00
|
|
|
console.log("\n\nGetting inline entity "+this.type+"\n\n");
|
2017-12-19 13:53:46 +01:00
|
|
|
if(this.type == "project"){
|
|
|
|
this.linkType = "project";
|
|
|
|
this.getProjectById(this.id);
|
|
|
|
}else if(this.type == "publication"){
|
|
|
|
this.getPublicationById(this.id,true);
|
|
|
|
}else if(this.type == "dataset"){
|
|
|
|
this.getDatasetById(this.id,true);
|
|
|
|
}else if(this.type == "software"){
|
|
|
|
this.getSoftwareById(this.id,true);
|
2018-07-30 16:22:19 +02:00
|
|
|
}else if(this.type == "orp"){
|
|
|
|
this.getOrpById(this.id,true);
|
2017-12-19 13:53:46 +01:00
|
|
|
}else{
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
isValidInput(result){
|
|
|
|
if(result == null){
|
|
|
|
return false;
|
|
|
|
}else if(this.type == "project" && this.linkTo != "result"){
|
|
|
|
return false;
|
2018-07-30 16:22:19 +02:00
|
|
|
}else if(["dataset","publication","software", "orp"].indexOf(this.type) != -1 && (["project","context","result"].indexOf(this.linkTo) == -1)){
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
2018-07-30 16:22:19 +02:00
|
|
|
}else if(["project","dataset","publication","software","orp"].indexOf(this.type) == -1){
|
2017-12-19 13:53:46 +01:00
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getProjectById(id:string){
|
2018-02-05 14:14:59 +01:00
|
|
|
this.sub = this.entitySearch.fetchByType(id,"project", this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
console.log(data);
|
|
|
|
var item =data[0];
|
|
|
|
var project: ClaimProject = new ClaimProject();
|
|
|
|
project.funderId = item.funderId;
|
|
|
|
project.funderName = item.funderName;
|
|
|
|
project.projectId = id;
|
|
|
|
project.projectName = item.projectName;
|
|
|
|
project.projectAcronym = item.projectAcronym;
|
|
|
|
project.startDate = item.startDate;
|
|
|
|
project.endDate = item.endDate;
|
|
|
|
project.code = item.code;
|
|
|
|
project.jurisdiction = item.jurisdiction;
|
|
|
|
project.fundingLevel0 = item.fundingLevel0;
|
|
|
|
|
|
|
|
this.projects.push( project);
|
|
|
|
this.validInput = this.isValidInput(project);
|
|
|
|
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
console.log("An error occured")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
getPublicationById(id:string, isInlineResult:boolean){
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
this.sub = this.publicationsSearch.searchPublicationById(id,this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
var item =data[0];
|
|
|
|
var result: ClaimResult = new ClaimResult();
|
|
|
|
result.id=id;
|
|
|
|
result.type="publication";
|
|
|
|
result.source="openaire";
|
|
|
|
result.title = item['title'].name;
|
|
|
|
result.url= item['title'].url;
|
|
|
|
result.result = item;
|
|
|
|
result.accessRights = item['title'].accessMode;
|
|
|
|
result.date = item.year;
|
|
|
|
this.displayedResult = result;
|
|
|
|
if(isInlineResult){
|
|
|
|
this.inlineResult = result;
|
|
|
|
}else{
|
|
|
|
this.results.push( result);
|
|
|
|
}
|
|
|
|
this.validInput = this.isValidInput(result);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
console.log("An error occured")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
getDatasetById(id:string, isInlineResult:boolean){
|
2018-02-05 14:14:59 +01:00
|
|
|
this.sub = this.datasetsSearch.searchDatasetById(id,this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
var item =data[0];
|
|
|
|
var result: ClaimResult = new ClaimResult();
|
|
|
|
result.id=id;
|
|
|
|
result.type="dataset";
|
|
|
|
result.source="openaire";
|
|
|
|
result.title = item['title'].name;
|
|
|
|
result.url= item['title'].url;
|
|
|
|
result.result = item;
|
|
|
|
result.accessRights = item['title'].accessMode;
|
2018-07-30 16:22:19 +02:00
|
|
|
result.embargoEndDate ="";
|
2017-12-19 13:53:46 +01:00
|
|
|
result.date = item.year;
|
|
|
|
this.displayedResult = result;
|
|
|
|
if(isInlineResult){
|
|
|
|
this.inlineResult = result;
|
|
|
|
}else{
|
|
|
|
this.results.push( result);
|
|
|
|
}
|
|
|
|
this.validInput = this.isValidInput(result);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
console.log("An error occured")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
getSoftwareById(id:string, isInlineResult:boolean){
|
2018-02-05 14:14:59 +01:00
|
|
|
this.sub = this.softwareSearch.searchSoftwareById(id,this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
var item =data[0];
|
|
|
|
var result: ClaimResult = new ClaimResult();
|
|
|
|
result.id=id;
|
|
|
|
result.type="software";
|
|
|
|
result.source="openaire";
|
|
|
|
result.title = item['title'].name;
|
|
|
|
result.url= item['title'].url;
|
|
|
|
result.result = item;
|
|
|
|
result.accessRights = item['title'].accessMode;
|
2018-07-30 16:22:19 +02:00
|
|
|
result.embargoEndDate ="";
|
2017-12-19 13:53:46 +01:00
|
|
|
result.date = item.year;
|
|
|
|
this.displayedResult = result;
|
|
|
|
if(isInlineResult){
|
|
|
|
this.inlineResult = result;
|
|
|
|
}else{
|
|
|
|
this.results.push( result);
|
|
|
|
}
|
|
|
|
this.validInput = this.isValidInput(result);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
console.log("An error occured")
|
|
|
|
});
|
|
|
|
}
|
2018-07-30 16:22:19 +02:00
|
|
|
getOrpById(id:string, isInlineResult:boolean){
|
|
|
|
this.sub = this.ORPSearch.searchOrpById(id,this.properties).subscribe(
|
|
|
|
data => {
|
|
|
|
console.log(data)
|
|
|
|
var item =data[0];
|
|
|
|
var result: ClaimResult = new ClaimResult();
|
|
|
|
result.id=id;
|
|
|
|
result.type="other";
|
|
|
|
result.source="openaire";
|
|
|
|
result.title = item['title'].name;
|
|
|
|
result.url= item['title'].url;
|
|
|
|
result.result = item;
|
|
|
|
result.accessRights = item['title'].accessMode;
|
|
|
|
result.embargoEndDate ="";
|
|
|
|
result.date = item.year;
|
|
|
|
this.displayedResult = result;
|
|
|
|
console.log(item)
|
|
|
|
if(isInlineResult){
|
|
|
|
this.inlineResult = result;
|
|
|
|
}else{
|
|
|
|
this.results.push( result);
|
|
|
|
}
|
|
|
|
this.validInput = this.isValidInput(result);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.validInput = this.isValidInput(null);
|
|
|
|
console.log("An error occured")
|
|
|
|
});
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|