import { LayoutData, SerializedDiagram } from '../../editor/serializedDiagram'; import { Dictionary, ElementModel } from '../model'; import { GraphBuilder } from './graphBuilder'; import { SparqlDataProvider } from './sparqlDataProvider'; const DEFAULT_PREFIX = `PREFIX rdfs: PREFIX rdf: PREFIX owl: ` + '\n\n'; export class SparqlGraphBuilder { graphBuilder: GraphBuilder; constructor(public dataProvider: SparqlDataProvider) { this.graphBuilder = new GraphBuilder(dataProvider); } getGraphFromConstruct(constructQuery: string): Promise<{ preloadedElements: Dictionary; diagram: SerializedDiagram; }> { const query = DEFAULT_PREFIX + constructQuery; return this.dataProvider.executeSparqlConstruct(query) .then(graph => this.graphBuilder.getGraphFromRDFGraph(graph)); } }