JSON-LD:
expand Dataset to use issn, headline, alternativeHeadline for dataset subtitle fix Dataset issue to get the proper value when title is array Add jsonld in search pages with potentialAction search to each page git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@53733 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
7d6f6f5297
commit
ae21b00172
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<schema2jsonld *ngIf="name && logoURL" [URL]="properties.baseLink" [logoURL] = "properties.baseLink+logoURL" type="home" [name]=name></schema2jsonld>
|
<schema2jsonld *ngIf="name && logoURL" [URL]="properties.baseLink+'/search/find'" [logoURL] = "properties.baseLink+logoURL" type="search" [name]=name></schema2jsonld>
|
||||||
|
|
||||||
|
|
||||||
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle" >
|
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle" >
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<schema2jsonld [URL]="properties.baseLink+baseUrl" type="search" [name]=pageTitle></schema2jsonld>
|
||||||
|
|
||||||
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle" >
|
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle" >
|
||||||
<div uk-grid >
|
<div uk-grid >
|
||||||
|
@ -178,7 +179,7 @@
|
||||||
[href]="properties.lastIndexInformationLink" target="_blank">
|
[href]="properties.lastIndexInformationLink" target="_blank">
|
||||||
Last index information
|
Last index information
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<helper class="uk-hidden@m" position="left" styleName="uk-width-1-1@s"></helper>
|
<helper class="uk-hidden@m" position="left" styleName="uk-width-1-1@s"></helper>
|
||||||
<helper class="uk-hidden@m" position="right" styleName="uk-width-1-1@s"></helper>
|
<helper class="uk-hidden@m" position="right" styleName="uk-width-1-1@s"></helper>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,13 +18,14 @@ import {ModalModule} from '../../utils/modal/modal.module';
|
||||||
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
||||||
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
||||||
import {HelperModule} from '../../utils/helper/helper.module';
|
import {HelperModule} from '../../utils/helper/helper.module';
|
||||||
|
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule,
|
CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule,
|
||||||
LoadingModalModule, ReportsServiceModule,
|
LoadingModalModule, ReportsServiceModule,
|
||||||
SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule, HelperModule
|
SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule, HelperModule, Schema2jsonldModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
SearchPageComponent
|
SearchPageComponent
|
||||||
|
|
|
@ -14,6 +14,9 @@ export class Dataset extends JsonldDocument {
|
||||||
citation: Citation[];
|
citation: Citation[];
|
||||||
license: License[];
|
license: License[];
|
||||||
keyword: String[];
|
keyword: String[];
|
||||||
|
issn:String[];
|
||||||
|
headline:String[];
|
||||||
|
alternativeHeadline:String[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Identifier {
|
export interface Identifier {
|
||||||
|
|
|
@ -9,10 +9,10 @@ import { JsonldDocumentSerializerService } from './service/jsonld-document-seria
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class Schema2jsonldComponent {
|
export class Schema2jsonldComponent {
|
||||||
@Input() data;
|
@Input() data; // for project, organization, datasource
|
||||||
@Input() URL;
|
@Input() URL;
|
||||||
@Input() logoURL;
|
@Input() logoURL; // for home, search
|
||||||
@Input() otherURL;
|
@Input() otherURL; //for project, datasource
|
||||||
@Input() name;
|
@Input() name;
|
||||||
@Input() type="result";
|
@Input() type="result";
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ json;
|
||||||
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);
|
||||||
|
}else if(this.type == 'search'){
|
||||||
|
this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL);
|
||||||
}else{
|
}else{
|
||||||
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);
|
||||||
|
|
|
@ -35,6 +35,15 @@ export class JsonldDocumentSerializerService {
|
||||||
buffer["@context"] = "http://schema.org";
|
buffer["@context"] = "http://schema.org";
|
||||||
buffer["@type"] = "Dataset";
|
buffer["@type"] = "Dataset";
|
||||||
this.serializeDocument(doc, buffer);
|
this.serializeDocument(doc, buffer);
|
||||||
|
if(doc.headline){
|
||||||
|
buffer["headline"] = doc.headline;
|
||||||
|
}
|
||||||
|
if(doc.alternativeHeadline){
|
||||||
|
buffer["alternativeHeadline"] = doc.alternativeHeadline;
|
||||||
|
}
|
||||||
|
if(doc.issn){
|
||||||
|
buffer["issn"] = doc.issn;
|
||||||
|
}
|
||||||
|
|
||||||
if (doc.creator && doc.creator.length == 1) {
|
if (doc.creator && doc.creator.length == 1) {
|
||||||
buffer["creator"] = this.buildCreator(doc.creator[0]);
|
buffer["creator"] = this.buildCreator(doc.creator[0]);
|
||||||
|
@ -150,12 +159,22 @@ export class JsonldDocumentSerializerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCreator(item: Person): any {
|
buildCreator(item: Person): any {
|
||||||
return {
|
var person ={};
|
||||||
"@type": "Person",
|
person["@type"] = "Person";
|
||||||
"givenName": item.givenName,
|
if(item.givenName){
|
||||||
"familyName": item.familyName,
|
person["givenName"] = item.givenName;
|
||||||
"name": item.name
|
}
|
||||||
};
|
if(item.familyName){
|
||||||
|
person["familyName"] = item.familyName;
|
||||||
|
}
|
||||||
|
person["name"] = item.name;
|
||||||
|
return person;
|
||||||
|
// return {
|
||||||
|
// "@type": "Person",
|
||||||
|
// "givenName": item.givenName,
|
||||||
|
// "familyName": item.familyName,
|
||||||
|
// "name": item.name
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
|
|
||||||
buildLicense(item: License): any {
|
buildLicense(item: License): any {
|
||||||
|
|
|
@ -29,10 +29,29 @@ export class OpenAireJsonldConverterService {
|
||||||
buffer["sameAs"] = sameAs;
|
buffer["sameAs"] = sameAs;
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
createSearchPage(name, URL, logoURL): any {
|
||||||
|
const buffer = {};
|
||||||
|
buffer["@context"] = "http://schema.org";
|
||||||
|
buffer["@type"] = "Organization";
|
||||||
|
buffer["name"] = name;
|
||||||
|
buffer["url"] = URL;
|
||||||
|
buffer["logo"] = logoURL;
|
||||||
|
const action ={};
|
||||||
|
action["@type"]= "SearchAction";
|
||||||
|
action["target"]= URL+"?keyword={search_term_string}";
|
||||||
|
action["query-input"]= "required name=search_term_string";
|
||||||
|
buffer["potentialAction"] = action;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
convertResult(result: any, URL): Dataset {
|
convertResult(result: any, URL): Dataset {
|
||||||
const doc = new Dataset();
|
const doc = new Dataset();
|
||||||
|
|
||||||
doc.title = this.getTitle(result);
|
doc.title = this.getTitle(result);
|
||||||
|
doc.headline = doc.title;
|
||||||
|
if(this.getSubTitle(result)){
|
||||||
|
doc.alternativeHeadline = this.getSubTitle(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.url = URL;
|
doc.url = URL;
|
||||||
|
@ -76,9 +95,6 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
|
||||||
doc.title = datasource.title.name
|
doc.title = datasource.title.name
|
||||||
doc.identifier = datasource.contractNum;
|
doc.identifier = datasource.contractNum;
|
||||||
doc.legalName = datasource.officialName;
|
doc.legalName = datasource.officialName;
|
||||||
// doc.areaServed = datasource.country;
|
|
||||||
console.log("HERE")
|
|
||||||
console.log(datasource.countries)
|
|
||||||
if(datasource.countries && datasource.countries.length > 0){
|
if(datasource.countries && datasource.countries.length > 0){
|
||||||
doc.areaServed = datasource.countries[0];
|
doc.areaServed = datasource.countries[0];
|
||||||
}
|
}
|
||||||
|
@ -100,11 +116,28 @@ console.log(datasource.countries)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTitle(result: any): String[] {
|
private getTitle(result: any): String[] {
|
||||||
const item = _.get(result, "result.metadata.oaf:entity.oaf:result.title.content", null);
|
const title = _.get(result, "result.metadata.oaf:entity.oaf:result.title", null);
|
||||||
|
if(title && Array.isArray(title) ){
|
||||||
|
return title[0].content;
|
||||||
|
}else{
|
||||||
|
return title.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private getSubTitle(result: any): String[] {
|
||||||
|
const title = _.get(result, "result.metadata.oaf:entity.oaf:result.title", null);
|
||||||
|
if(title && Array.isArray(title) ){
|
||||||
|
if(title[1] && title[1].classid == "subtitle") {
|
||||||
|
return title[1].content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private getISSN(result: any): String[] {
|
||||||
|
const item = _.get(result, "result.metadata.oaf:entity.oaf:result.journal.issn", null);
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
return [item as String];
|
return [item as String];
|
||||||
}
|
}
|
||||||
|
|
||||||
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 null;
|
||||||
|
|
Loading…
Reference in New Issue