UNPKG

data-pipeline-information-system-sparql

Version:

Sparql function to query/update RDF through SPARQL 1.1

57 lines 2.13 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var common_1 = require("./common"); var getter_1 = __importDefault(require("../SparqlAttribute/getter")); var _bound_1 = require("./_bound"); var ARITHMETIC_SYMBOL; (function (ARITHMETIC_SYMBOL) { ARITHMETIC_SYMBOL["EQUAL"] = "="; ARITHMETIC_SYMBOL["GREATER"] = ">="; ARITHMETIC_SYMBOL["LOWER"] = "<="; })(ARITHMETIC_SYMBOL = exports.ARITHMETIC_SYMBOL || (exports.ARITHMETIC_SYMBOL = {})); function arithmetic_filter(arithmetic_symbol, reference, definition, json_pointer, value) { var incremented_definition = common_1.copy(definition); var _a = __assign({}, getter_1.default(reference, json_pointer)), attribute = _a.attribute, nestedPath = _a.nestedPath; var pointerToDefinition = incremented_definition; nestedPath.forEach(function (path) { pointerToDefinition = pointerToDefinition.subQuery[path]; }); var operation = { type: 'operation', operator: arithmetic_symbol, args: ['?' + attribute.name, "\"" + value + "\""] }; var arithmetic; ; if (attribute.optional) { arithmetic = { type: 'filter', expression: _bound_1.prependBound(operation, attribute.name) }; } else { arithmetic = { type: 'filter', expression: operation }; } pointerToDefinition.query.where.push(arithmetic); return incremented_definition; } exports.arithmetic_filter = arithmetic_filter; exports.default = arithmetic_filter; //# sourceMappingURL=arithmetic_filter.js.map