data-pipeline-information-system-sparql
Version:
Sparql function to query/update RDF through SPARQL 1.1
19 lines (16 loc) • 674 B
text/typescript
import jsonpointer from 'json-pointer'
import SparqlAttribute from './SparqlAttribute'
import SparqlTask from '../Core/SparqlTask'
export function getAttribute(rootReference: string, pointer: string) {
let path = jsonpointer.parse(pointer);
let nestedPath = [...path];
nestedPath.pop();
let model = SparqlTask.sparqlObjects[rootReference];
let attribute: SparqlAttribute = new SparqlAttribute(model);
while (path.length > 0) {
attribute = model.dictionify()[<string>path.shift()];
model = SparqlTask.sparqlObjects[attribute.reference];
}
return {nestedPath : nestedPath, attribute: attribute};
}
export default getAttribute