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:
argiro.kokogiannaki 2018-11-13 13:01:38 +00:00
parent 7d6f6f5297
commit ae21b00172
7 changed files with 76 additions and 17 deletions

View File

@ -18,7 +18,7 @@
</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" >

View File

@ -22,6 +22,7 @@
</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 uk-grid >
@ -178,7 +179,7 @@
[href]="properties.lastIndexInformationLink" target="_blank">
Last index information
</a>
<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>
</div>

View File

@ -18,13 +18,14 @@ import {ModalModule} from '../../utils/modal/modal.module';
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
import {HelperModule} from '../../utils/helper/helper.module';
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
@NgModule({
imports: [
CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule,
LoadingModalModule, ReportsServiceModule,
SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule, HelperModule
SearchPagingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule, HelperModule, Schema2jsonldModule
],
declarations: [
SearchPageComponent

View File

@ -14,6 +14,9 @@ export class Dataset extends JsonldDocument {
citation: Citation[];
license: License[];
keyword: String[];
issn:String[];
headline:String[];
alternativeHeadline:String[];
}
export interface Identifier {

View File

@ -9,10 +9,10 @@ import { JsonldDocumentSerializerService } from './service/jsonld-document-seria
`
})
export class Schema2jsonldComponent {
@Input() data;
@Input() data; // for project, organization, datasource
@Input() URL;
@Input() logoURL;
@Input() otherURL;
@Input() logoURL; // for home, search
@Input() otherURL; //for project, datasource
@Input() name;
@Input() type="result";
@ -35,6 +35,8 @@ json;
this.json = this.documentSerializer.serializeOrganization(docOvject);
}else if(this.type == 'home'){
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{
docOvject = this.documentParser.convertResult(this.data, this.URL);
this.json = this.documentSerializer.serializeDataset(docOvject);

View File

@ -35,6 +35,15 @@ export class JsonldDocumentSerializerService {
buffer["@context"] = "http://schema.org";
buffer["@type"] = "Dataset";
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) {
buffer["creator"] = this.buildCreator(doc.creator[0]);
@ -150,12 +159,22 @@ export class JsonldDocumentSerializerService {
}
buildCreator(item: Person): any {
return {
"@type": "Person",
"givenName": item.givenName,
"familyName": item.familyName,
"name": item.name
};
var person ={};
person["@type"] = "Person";
if(item.givenName){
person["givenName"] = item.givenName;
}
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 {

View File

@ -29,10 +29,29 @@ export class OpenAireJsonldConverterService {
buffer["sameAs"] = sameAs;
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 {
const doc = new Dataset();
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.identifier = this.getIdentifier(result);
doc.url = URL;
@ -76,9 +95,6 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
doc.title = datasource.title.name
doc.identifier = datasource.contractNum;
doc.legalName = datasource.officialName;
// doc.areaServed = datasource.country;
console.log("HERE")
console.log(datasource.countries)
if(datasource.countries && datasource.countries.length > 0){
doc.areaServed = datasource.countries[0];
}
@ -100,11 +116,28 @@ console.log(datasource.countries)
}
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;
return [item as String];
}
private getDescription(result: any): String[] {
const item = _.get(result, "result.metadata.oaf:entity.oaf:result.description", null);
if (!item) return null;