UNPKG

data-pipeline-information-system-sparql

Version:

Sparql function to query/update RDF through SPARQL 1.1

53 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var types_1 = require("../Core/types"); function jsonBindings() { var object = objectify.apply(this); var jsonBindings = "(concat('"; jsonBindings += parseJsonRepresentation(object); jsonBindings += "') AS ?object)"; return jsonBindings; } exports.jsonBindings = jsonBindings; function bindings() { return this.attributes .filter(function (attribute) { return attribute.type !== types_1.Type.OBJECT; }) .map(function (attribute) { return attribute.binding; }) .join(' '); } exports.bindings = bindings; function objectify() { var objectRepresentation = {}; return objectRepresentation; } function parseJsonRepresentation(object) { var representation = ''; representation += '{'; representation += Object.keys(object).map(function (key) { var attributeNested = object[key]; var tmpRepresentation; var subRepresentation = '"' + attributeNested.binding.substring(1) + '":'; if (attributeNested.type === types_1.Type.OBJECT && attributeNested.nest) { tmpRepresentation = parseJsonRepresentation(attributeNested.nest); } else { tmpRepresentation = "\"'," + attributeNested.binding + ",'\""; } if (attributeNested.arrayable) { subRepresentation += "[',group_concat(distinct concat(' " + tmpRepresentation + " ');separator=','),']"; } else { subRepresentation += tmpRepresentation; } return subRepresentation; }) .join(','); representation += '}'; return representation; } exports.default = jsonBindings; //# sourceMappingURL=_bindings.js.map