Page MenuHomec4science

rdf-editor-component.component.ts
No OneTemporary

File Metadata

Created
Tue, Apr 16, 14:30

rdf-editor-component.component.ts

import { Component, OnInit } from '@angular/core';
import * as N3 from "node_modules/n3/src";
import {CrossrefEditorDataServiceService} from '../crossref-editor-data-service.service';
import {Subscription} from 'rxjs';
@Component({
selector: 'app-rdf-editor-component',
templateUrl: './rdf-editor-component.component.html',
styleUrls: ['./rdf-editor-component.component.scss']
})
export class RdfEditorComponentComponent implements OnInit {
nodeSub: Subscription;
textGeneseWriter;
textGeneseTriples: string;
constructor( public dataService: CrossrefEditorDataServiceService) {
}
ngOnInit() {
this.textGeneseWriter = new N3.Writer({ prefixes: { data: 'http://rdfh.ch/projects/0068#' } });
this.nodeSub = this.dataService.clickedNodeEvent.subscribe(node => {
this.writeSthToTextGenese(node.iri);
//...
this.checkOutTextGenese();
});
}
writeSthToTextGenese(iri, prefix?: any) {
const {DataFactory} = N3;
const {namedNode, literal, defaultGraph, quad} = DataFactory;
const newIri = iri+'textgenese_0'
this.textGeneseWriter.addQuad(
namedNode(newIri),
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
namedNode('tln:textGenese!!!')
);
}
checkOutTextGenese() {
this.textGeneseWriter.end((error, result) => {
console.log('typeof ', typeof result, ' result ', result);
this.textGeneseTriples = result;
});
}
}

Event Timeline