[Library|Trunk]

JSONLD changes: 
	Add id in every jsonld
	Home page: 
		remove search action from Organization
		Add description in Organization
		Add Website with search action
	Add Organization and Website in every page
	In every search page add is part of the Website
	In result landing (Type Dataset) when there is no description add title in description
	


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59134 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-07-15 13:59:09 +00:00
parent 2e045b95d3
commit fd27e88386
5 changed files with 57 additions and 30 deletions

View File

@ -1,4 +1,5 @@
export class JsonldDocument { export class JsonldDocument {
id: string;
title: String[]; title: String[];
description: String[]; description: String[];
identifier: Identifier[]; identifier: Identifier[];

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {OpenAireJsonldConverterService} from './service/open-aire-jsonld-converter.service'; import {OpenAireJsonldConverterService} from './service/open-aire-jsonld-converter.service';
import {JsonldDocumentSerializerService} from './service/jsonld-document-serializer.service'; import {JsonldDocumentSerializerService} from './service/jsonld-document-serializer.service';
@ -16,6 +16,7 @@ export class Schema2jsonldComponent {
@Input() name; @Input() name;
@Input() searchAction = true; @Input() searchAction = true;
@Input() type = "result"; @Input() type = "result";
@Input() description;
public json; public json;
constructor(private documentParser: OpenAireJsonldConverterService, constructor(private documentParser: OpenAireJsonldConverterService,
@ -35,14 +36,14 @@ export class Schema2jsonldComponent {
docOvject = this.documentParser.convertDatasource(this.data, this.URL, this.otherURL); docOvject = this.documentParser.convertDatasource(this.data, this.URL, this.otherURL);
this.json = this.documentSerializer.serializeOrganization(docOvject); this.json = this.documentSerializer.serializeOrganization(docOvject);
} else if (this.type == 'home') { } else if (this.type == 'home') {
this.json = this.documentParser.createHome(this.name, this.URL, this.logoURL); this.json = this.documentParser.createHome(this.name, this.URL, this.logoURL, this.description);
} else if (this.type == 'search') { } else if (this.type == 'search') {
this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL, this.searchAction); this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL, this.searchAction, this.description);
} else if (this.type == 'result') { } else if (this.type == 'result') {
docOvject = this.documentParser.convertResult(this.data, this.URL); docOvject = this.documentParser.convertResult(this.data, this.URL);
this.json = this.documentSerializer.serializeDataset(docOvject); this.json = this.documentSerializer.serializeDataset(docOvject);
} else { } else {
this.json = this.documentParser.createSimplePage(this.name, this.URL); this.json = this.documentParser.createSimplePage(this.name, this.URL, this.description);
} }
} }
} }

View File

@ -24,6 +24,7 @@ export class JsonldDocumentSerializerService {
serializeDocument(doc:JsonldDocument, buffer):any{ serializeDocument(doc:JsonldDocument, buffer):any{
buffer["@context"] = "http://schema.org"; buffer["@context"] = "http://schema.org";
buffer["@id"] = doc.id;
this.serializeName(doc, buffer); this.serializeName(doc, buffer);
this.serializeDescription(doc, buffer); this.serializeDescription(doc, buffer);
this.serializeIdentifier(doc, buffer); this.serializeIdentifier(doc, buffer);

View File

@ -1,57 +1,80 @@
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { JsonldDocument, Identifier, Person, License, Citation, Dataset, Organization } from "../model/jsonld-document"; import { JsonldDocument, Identifier, Person, License, Citation, Dataset, Organization } from "../model/jsonld-document";
import * as _ from "lodash"; import * as _ from "lodash";
import {properties} from "../../../../../environments/environment";
@Injectable() @Injectable()
export class OpenAireJsonldConverterService { export class OpenAireJsonldConverterService {
constructor() { }
createHome(name, URL, logoURL): any { constructor() {
const buffer = {};
buffer["@context"] = "http://schema.org"; }
buffer["@type"] = "Organization";
buffer["name"] = name; createHome(name, URL, logoURL, description:string = null): any {
buffer["url"] = URL; const organization = {};
buffer["logo"] = logoURL; const searchPage = {};
organization["@context"] = "http://schema.org";
organization["@id"] = properties.baseLink+"/#organization";
organization["@type"] = "Organization";
organization["name"] = name;
organization["url"] = properties.baseLink;
organization["logo"] = logoURL;
if(description){
organization["description"] = description;
}
const sameAs =["https://www.openaire.eu",
"https://www.facebook.com/groups/openaire/",
"https://www.twitter.com/OpenAIRE_eu",
"https://www.linkedin.com/groups/OpenAIRE-3893548",
"https://www.slideshare.net/OpenAIRE_eu",
"https://www.youtube.com/channel/UChFYqizc-S6asNjQSoWuwjw"];
organization["sameAs"] = sameAs;
searchPage["@context"] = "http://schema.org";
searchPage["@id"] = properties.baseLink+"/#search";
searchPage["@type"] = "Website";
searchPage["name"] = name;
searchPage["url"] = properties.baseLink+"/search/find/";
searchPage["logo"] = logoURL;
const action ={}; const action ={};
action["@type"]= "SearchAction"; action["@type"]= "SearchAction";
action["target"]= URL+"/search/find/?keyword={search_term_string}"; action["@id"]= properties.baseLink+"/#search-action";
action["target"]= properties.baseLink+"/search/find/?fv0={search_term_string}&f0=q";
action["query-input"]= "required name=search_term_string"; action["query-input"]= "required name=search_term_string";
buffer["potentialAction"] = action; searchPage["potentialAction"] = action;
const sameAs =["https://www.openaire.eu", return [organization, searchPage];
"https://www.facebook.com/groups/openaire/",
"https://www.twitter.com/OpenAIRE_eu",
"https://www.linkedin.com/groups/OpenAIRE-3893548",
"https://www.slideshare.net/OpenAIRE_eu",
"https://www.youtube.com/channel/UChFYqizc-S6asNjQSoWuwjw"];
buffer["sameAs"] = sameAs;
return buffer;
} }
createSimplePage(name, URL): any { createSimplePage(name, URL, description:string = null): any {
const buffer = {}; const buffer = {};
buffer["@context"] = "http://schema.org"; buffer["@context"] = "http://schema.org";
buffer["@type"] = "WebPage"; buffer["@type"] = "WebPage";
buffer["name"] = name; buffer["name"] = name;
buffer["url"] = URL; buffer["url"] = URL;
if(description){
buffer["description"] = description;
} buffer["@id"] = URL;
return buffer; return buffer;
} }
createSearchPage(name, URL, logoURL, searchAction:boolean = true): any { createSearchPage(name, URL, logoURL, searchAction:boolean = true, description:string = null): any {
const buffer = {}; const buffer = {};
buffer["@context"] = "http://schema.org"; buffer["@context"] = "http://schema.org";
buffer["@type"] = "SearchResultsPage"; buffer["@type"] = "SearchResultsPage";
buffer["name"] = name; buffer["name"] = name;
if(description){
buffer["description"] = description;
}
buffer["url"] = URL; buffer["url"] = URL;
buffer["@id"] = URL;
buffer["logo"] = logoURL; buffer["logo"] = logoURL;
if(searchAction){ buffer["isPartOf"] = properties.baseLink+"/#search";
/*if(searchAction){
const action ={}; const action ={};
action["@type"]= "SearchAction"; action["@type"]= "SearchAction";
action["target"]= URL+"?keyword={search_term_string}"; action["target"]= URL+"?keyword={search_term_string}";
action["query-input"]= "required name=search_term_string"; action["query-input"]= "required name=search_term_string";
buffer["potentialAction"] = action; buffer["potentialAction"] = action;
} }*/
return buffer; return buffer;
} }
convertResult(result: any, URL): Dataset { convertResult(result: any, URL): Dataset {
@ -65,6 +88,7 @@ export class OpenAireJsonldConverterService {
doc.issn = this.getISSN(result); doc.issn = this.getISSN(result);
doc.description = this.getDescription(result); doc.description = this.getDescription(result);
doc.identifier = this.getIdentifier(result); doc.identifier = this.getIdentifier(result);
doc.id = URL
doc.url = URL; doc.url = URL;
doc.sameAs = this.getSameAs(result); doc.sameAs = this.getSameAs(result);
doc.creator = this.getCreator(result); doc.creator = this.getCreator(result);
@ -150,7 +174,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
} }
private getDescription(result: any): String[] { private getDescription(result: any): String[] {
const item = _.get(result, "result.metadata.oaf:entity.oaf:result.description", null); const item = _.get(result, "result.metadata.oaf:entity.oaf:result.description", null);
if (!item) return null; if (!item) return this.getTitle(result);
let descr = Array.isArray(item) ? item[0]:item; let descr = Array.isArray(item) ? item[0]:item;
return [(descr.substring(0,4997)+(descr.substring(0,4997).length == 4997?'...':'')) as String]; return [(descr.substring(0,4997)+(descr.substring(0,4997).length == 4997?'...':'')) as String];
} }

View File

@ -1,7 +1,7 @@
<!-- Before title --> <!-- Before title -->
<div uk-grid> <div uk-grid>
<div class="uk-width-1-1"> <div class="uk-width-1-1">
<!-- deposit website URL --> <!-- deposit searchPage URL -->
<span class="uk-width-expand uk-flex-right"> <span class="uk-width-expand uk-flex-right">
<a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit" <a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit"
class=" zenodoButton uk-float-right uk-button portal-button uk-padding uk-padding-remove-vertical uk-margin-small-left"> class=" zenodoButton uk-float-right uk-button portal-button uk-padding uk-padding-remove-vertical uk-margin-small-left">