Project

General

Profile

1
import {Component, ElementRef, Input} from '@angular/core';
2
import { OpenAireJsonldConverterService } from './service/open-aire-jsonld-converter.service';
3
import { JsonldDocumentSerializerService } from './service/jsonld-document-serializer.service';
4
@Component({
5
  selector: 'schema2jsonld',
6
  template: `
7
  <ngx-json-ld [json]="json"></ngx-json-ld>
8

    
9
  `
10
})
11
export class Schema2jsonldComponent {
12
@Input() data; // for project, organization, datasource
13
@Input() URL;
14
@Input() logoURL; // for home, search
15
@Input() otherURL; //for project, datasource
16
@Input() name;
17
@Input() type="result";
18

    
19
json;
20
  constructor(	private documentParser: OpenAireJsonldConverterService,
21
		private documentSerializer: JsonldDocumentSerializerService) {
22

    
23
  }
24

    
25
  ngOnInit() {
26
      var docOvject;
27
      if(this.type == 'project'){
28
        docOvject = this.documentParser.convertProject(this.data, this.URL, this.otherURL);
29
        this.json = this.documentSerializer.serializeOrganization(docOvject);
30
      }else if(this.type == 'organization'){
31
        docOvject = this.documentParser.convertOrganization(this.data, this.URL);
32
        this.json = this.documentSerializer.serializeOrganization(docOvject);
33
      }else if(this.type == 'datasource'){
34
        docOvject = this.documentParser.convertDatasource(this.data, this.URL, this.otherURL);
35
        this.json = this.documentSerializer.serializeOrganization(docOvject);
36
      }else if(this.type == 'home'){
37
        this.json = this.documentParser.createHome(this.name, this.URL, this.logoURL);
38
      }else if(this.type == 'search'){
39
        this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL);
40
      }else{
41
        docOvject = this.documentParser.convertResult(this.data, this.URL);
42
        this.json = this.documentSerializer.serializeDataset(docOvject);
43
      }
44

    
45
  }
46

    
47

    
48
}
(1-1/2)