rdflib 2.2.35 → 2.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -2
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +57 -82
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -103
- package/esm/default-graph.js +13 -30
- package/esm/empty.js +8 -23
- package/esm/factories/canonical-data-factory.js +33 -29
- package/esm/factories/extended-term-factory.js +18 -13
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1366 -1651
- package/esm/formula.js +631 -736
- package/esm/index.js +31 -48
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +38 -86
- package/esm/literal.js +120 -154
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1009 -1086
- package/esm/named-node.js +69 -96
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -96
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +15 -16
- package/esm/rdfaparser.js +775 -841
- package/esm/rdfxmlparser.js +348 -364
- package/esm/serialize.js +2 -2
- package/esm/serializer.js +835 -877
- package/esm/statement.js +52 -71
- package/esm/store.js +853 -957
- package/esm/types.js +21 -21
- package/esm/update-manager.js +965 -1100
- package/esm/updates-via.js +104 -132
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +4 -5
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +32 -55
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +57 -80
- package/lib/class-order.js +1 -1
- package/lib/collection.js +70 -101
- package/lib/default-graph.js +14 -29
- package/lib/empty.js +9 -22
- package/lib/factories/canonical-data-factory.js +35 -31
- package/lib/factories/extended-term-factory.js +18 -13
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +9 -11
- package/lib/fetcher.js +1375 -1654
- package/lib/formula.js +632 -735
- package/lib/index.js +80 -84
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +47 -87
- package/lib/literal.js +121 -153
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1012 -1090
- package/lib/named-node.js +70 -95
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +73 -94
- package/lib/node.js +1 -1
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +20 -18
- package/lib/rdfaparser.js +778 -843
- package/lib/rdfxmlparser.js +351 -365
- package/lib/serialize.js +2 -2
- package/lib/serializer.js +840 -880
- package/lib/statement.js +55 -73
- package/lib/store.js +860 -958
- package/lib/types.js +21 -21
- package/lib/update-manager.js +970 -1102
- package/lib/updates-via.js +107 -132
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +8 -9
- package/lib/utils.js +6 -6
- package/lib/variable.js +35 -57
- package/lib/xsd.js +2 -2
- package/package.json +2 -2
- package/src/n3parser.js +1 -1
- package/src/serializer.js +1 -1
- package/src/update-manager.ts +2 -1
- package/.babelrc +0 -20
package/lib/store.js
CHANGED
|
@@ -7,15 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
Object.defineProperty(exports, "defaultGraphURI", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function
|
|
10
|
+
get: function () {
|
|
11
11
|
return _canonicalDataFactory.defaultGraphURI;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
15
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
21
16
|
var _canonicalDataFactory = require("./factories/canonical-data-factory");
|
|
@@ -29,17 +24,11 @@ var _query = require("./query");
|
|
|
29
24
|
var _types = require("./types");
|
|
30
25
|
var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
31
26
|
var _index = require("./index");
|
|
32
|
-
var
|
|
27
|
+
var _serialize = _interopRequireDefault(require("./serialize"));
|
|
33
28
|
var _blankNode = _interopRequireDefault(require("./blank-node"));
|
|
34
29
|
var _defaultGraph = _interopRequireDefault(require("./default-graph"));
|
|
35
30
|
var _literal = _interopRequireDefault(require("./literal"));
|
|
36
|
-
|
|
37
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
38
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
39
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
40
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
41
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
42
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* Identity management and indexing for RDF
|
|
31
|
+
/* Identity management and indexing for RDF
|
|
43
32
|
*
|
|
44
33
|
* This file provides IndexedFormula a formula (set of triples) which
|
|
45
34
|
* indexed by predicate, subject and object.
|
|
@@ -54,8 +43,11 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
54
43
|
* 2019 Converted to typescript
|
|
55
44
|
*
|
|
56
45
|
*
|
|
57
|
-
*/
|
|
58
|
-
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/** @module store */
|
|
49
|
+
|
|
50
|
+
const owlNamespaceURI = 'http://www.w3.org/2002/07/owl#';
|
|
59
51
|
// var link_ns = 'http://www.w3.org/2007/ont/link#'
|
|
60
52
|
|
|
61
53
|
// Handle Functional Property
|
|
@@ -98,7 +90,7 @@ function handleRDFType(formula, subj, pred, obj, why) {
|
|
|
98
90
|
/**
|
|
99
91
|
* Indexed Formula aka Store
|
|
100
92
|
*/
|
|
101
|
-
|
|
93
|
+
class IndexedFormula extends _formula.default {
|
|
102
94
|
/**
|
|
103
95
|
* Creates a new formula
|
|
104
96
|
* @param features - What sort of automatic processing to do? Array of string
|
|
@@ -108,1080 +100,990 @@ var IndexedFormula = exports.default = /*#__PURE__*/function (_Formula) {
|
|
|
108
100
|
* @param [opts.rdfArrayRemove] - Function which removes statements from the store
|
|
109
101
|
* @param [opts.dataCallback] - Callback when a statement is added to the store, will not trigger when adding duplicates
|
|
110
102
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
(0, _classCallCheck2.default)(this, IndexedFormula);
|
|
115
|
-
_this = _callSuper(this, IndexedFormula, [undefined, undefined, undefined, undefined, opts]);
|
|
103
|
+
constructor(features) {
|
|
104
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
105
|
+
super(undefined, undefined, undefined, undefined, opts);
|
|
116
106
|
// IN future - allow pass array of statements to constructor
|
|
117
107
|
/**
|
|
118
108
|
* An UpdateManager initialised to this store
|
|
119
109
|
*/
|
|
120
|
-
(0, _defineProperty2.default)(
|
|
110
|
+
(0, _defineProperty2.default)(this, "updater", void 0);
|
|
121
111
|
/**
|
|
122
112
|
* Dictionary of namespace prefixes
|
|
123
113
|
*/
|
|
124
|
-
(0, _defineProperty2.default)(
|
|
114
|
+
(0, _defineProperty2.default)(this, "namespaces", void 0);
|
|
125
115
|
/** Map of iri predicates to functions to call when adding { s type X } */
|
|
126
|
-
(0, _defineProperty2.default)(
|
|
116
|
+
(0, _defineProperty2.default)(this, "classActions", void 0);
|
|
127
117
|
/** Map of iri predicates to functions to call when getting statement with {s X o} */
|
|
128
|
-
(0, _defineProperty2.default)(
|
|
118
|
+
(0, _defineProperty2.default)(this, "propertyActions", void 0);
|
|
129
119
|
/** Redirect to lexically smaller equivalent symbol */
|
|
130
|
-
(0, _defineProperty2.default)(
|
|
120
|
+
(0, _defineProperty2.default)(this, "redirections", void 0);
|
|
131
121
|
/** Reverse mapping to redirection: aliases for this */
|
|
132
|
-
(0, _defineProperty2.default)(
|
|
122
|
+
(0, _defineProperty2.default)(this, "aliases", void 0);
|
|
133
123
|
/** Redirections we got from HTTP */
|
|
134
|
-
(0, _defineProperty2.default)(
|
|
124
|
+
(0, _defineProperty2.default)(this, "HTTPRedirects", void 0);
|
|
135
125
|
/** Array of statements with this X as subject */
|
|
136
|
-
(0, _defineProperty2.default)(
|
|
126
|
+
(0, _defineProperty2.default)(this, "subjectIndex", void 0);
|
|
137
127
|
/** Array of statements with this X as predicate */
|
|
138
|
-
(0, _defineProperty2.default)(
|
|
128
|
+
(0, _defineProperty2.default)(this, "predicateIndex", void 0);
|
|
139
129
|
/** Array of statements with this X as object */
|
|
140
|
-
(0, _defineProperty2.default)(
|
|
130
|
+
(0, _defineProperty2.default)(this, "objectIndex", void 0);
|
|
141
131
|
/** Array of statements with X as provenance */
|
|
142
|
-
(0, _defineProperty2.default)(
|
|
143
|
-
(0, _defineProperty2.default)(
|
|
144
|
-
(0, _defineProperty2.default)(
|
|
145
|
-
(0, _defineProperty2.default)(
|
|
146
|
-
(0, _defineProperty2.default)(
|
|
132
|
+
(0, _defineProperty2.default)(this, "whyIndex", void 0);
|
|
133
|
+
(0, _defineProperty2.default)(this, "index", void 0);
|
|
134
|
+
(0, _defineProperty2.default)(this, "features", void 0);
|
|
135
|
+
(0, _defineProperty2.default)(this, "_universalVariables", void 0);
|
|
136
|
+
(0, _defineProperty2.default)(this, "_existentialVariables", void 0);
|
|
147
137
|
/** Function to remove quads from the store arrays with */
|
|
148
|
-
(0, _defineProperty2.default)(
|
|
138
|
+
(0, _defineProperty2.default)(this, "rdfArrayRemove", void 0);
|
|
149
139
|
/** Callbacks which are triggered after a statement has been added to the store */
|
|
150
|
-
(0, _defineProperty2.default)(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
140
|
+
(0, _defineProperty2.default)(this, "dataCallbacks", void 0);
|
|
141
|
+
this.propertyActions = {};
|
|
142
|
+
this.classActions = {};
|
|
143
|
+
this.redirections = [];
|
|
144
|
+
this.aliases = [];
|
|
145
|
+
this.HTTPRedirects = [];
|
|
146
|
+
this.subjectIndex = [];
|
|
147
|
+
this.predicateIndex = [];
|
|
148
|
+
this.objectIndex = [];
|
|
149
|
+
this.whyIndex = [];
|
|
150
|
+
this.index = [this.subjectIndex, this.predicateIndex, this.objectIndex, this.whyIndex];
|
|
151
|
+
this.namespaces = {}; // Dictionary of namespace prefixes
|
|
152
|
+
this.features = features || [// By default, devs do not expect these features.
|
|
163
153
|
// See https://github.com/linkeddata/rdflib.js/issues/458
|
|
164
154
|
// 'sameAs',
|
|
165
155
|
// 'InverseFunctionalProperty',
|
|
166
156
|
// 'FunctionalProperty',
|
|
167
157
|
];
|
|
168
|
-
|
|
158
|
+
this.rdfArrayRemove = opts.rdfArrayRemove || _utilsJs.RDFArrayRemove;
|
|
169
159
|
if (opts.dataCallback) {
|
|
170
|
-
|
|
160
|
+
this.dataCallbacks = [opts.dataCallback];
|
|
171
161
|
}
|
|
172
|
-
|
|
173
|
-
return _this;
|
|
162
|
+
this.initPropertyActions(this.features);
|
|
174
163
|
}
|
|
175
164
|
|
|
176
165
|
/**
|
|
177
166
|
* Gets the URI of the default graph
|
|
178
167
|
*/
|
|
179
|
-
(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
value:
|
|
183
|
-
/**
|
|
184
|
-
* Gets this graph with the bindings substituted
|
|
185
|
-
* @param bindings The bindings
|
|
186
|
-
*/
|
|
187
|
-
function substitute(bindings) {
|
|
188
|
-
var statementsCopy = this.statements.map(function (ea) {
|
|
189
|
-
return ea.substitute(bindings);
|
|
190
|
-
});
|
|
191
|
-
var y = new IndexedFormula();
|
|
192
|
-
y.add(statementsCopy);
|
|
193
|
-
return y;
|
|
194
|
-
}
|
|
168
|
+
static get defaultGraphURI() {
|
|
169
|
+
return _canonicalDataFactory.defaultGraphURI;
|
|
170
|
+
}
|
|
195
171
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Gets this graph with the bindings substituted
|
|
174
|
+
* @param bindings The bindings
|
|
175
|
+
*/
|
|
176
|
+
substitute(bindings) {
|
|
177
|
+
var statementsCopy = this.statements.map(function (ea) {
|
|
178
|
+
return ea.substitute(bindings);
|
|
179
|
+
});
|
|
180
|
+
var y = new IndexedFormula();
|
|
181
|
+
y.add(statementsCopy);
|
|
182
|
+
return y;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Add a callback which will be triggered after a statement has been added to the store.
|
|
187
|
+
* @param cb
|
|
188
|
+
*/
|
|
189
|
+
addDataCallback(cb) {
|
|
190
|
+
if (!this.dataCallbacks) {
|
|
191
|
+
this.dataCallbacks = [];
|
|
207
192
|
}
|
|
193
|
+
this.dataCallbacks.push(cb);
|
|
194
|
+
}
|
|
208
195
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// log.info("Found deletable " + st)
|
|
240
|
-
return sts[0];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
if (bad.length) {
|
|
244
|
-
// console.log('Could not find to delete ' + bad.length + 'statements')
|
|
245
|
-
// console.log('despite ' + targetKB.statementsMatching(bad[0].subject, bad[0].predicate)[0])
|
|
246
|
-
return patchCallback('Could not find to delete: ' + bad.join('\n or '));
|
|
196
|
+
/**
|
|
197
|
+
* Apply a set of statements to be deleted and to be inserted
|
|
198
|
+
*
|
|
199
|
+
* @param patch - The set of statements to be deleted and to be inserted
|
|
200
|
+
* @param target - The name of the document to patch
|
|
201
|
+
* @param patchCallback - Callback to be called when patching is complete
|
|
202
|
+
*/
|
|
203
|
+
applyPatch(patch, target, patchCallback) {
|
|
204
|
+
var targetKB = this;
|
|
205
|
+
var ds;
|
|
206
|
+
var binding = null;
|
|
207
|
+
function doPatch(onDonePatch) {
|
|
208
|
+
if (patch['delete']) {
|
|
209
|
+
ds = patch['delete'];
|
|
210
|
+
// console.log(bindingDebug(binding))
|
|
211
|
+
// console.log('ds before substitute: ' + ds)
|
|
212
|
+
if (binding) ds = ds.substitute(binding);
|
|
213
|
+
// console.log('applyPatch: delete: ' + ds)
|
|
214
|
+
ds = ds.statements;
|
|
215
|
+
var bad = [];
|
|
216
|
+
var ds2 = ds.map(function (st) {
|
|
217
|
+
// Find the actual statements in the store
|
|
218
|
+
var sts = targetKB.statementsMatching(st.subject, st.predicate, st.object, target);
|
|
219
|
+
if (sts.length === 0) {
|
|
220
|
+
// log.info("NOT FOUND deletable " + st)
|
|
221
|
+
bad.push(st);
|
|
222
|
+
return null;
|
|
223
|
+
} else {
|
|
224
|
+
// log.info("Found deletable " + st)
|
|
225
|
+
return sts[0];
|
|
247
226
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// log.info("doPatch insert "+patch['insert'])
|
|
254
|
-
ds = patch['insert'];
|
|
255
|
-
if (binding) ds = ds.substitute(binding);
|
|
256
|
-
ds = ds.statements;
|
|
257
|
-
ds.map(function (st) {
|
|
258
|
-
st.graph = target;
|
|
259
|
-
targetKB.add(st.subject, st.predicate, st.object, st.graph);
|
|
260
|
-
});
|
|
227
|
+
});
|
|
228
|
+
if (bad.length) {
|
|
229
|
+
// console.log('Could not find to delete ' + bad.length + 'statements')
|
|
230
|
+
// console.log('despite ' + targetKB.statementsMatching(bad[0].subject, bad[0].predicate)[0])
|
|
231
|
+
return patchCallback('Could not find to delete: ' + bad.join('\n or '));
|
|
261
232
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (patch.where) {
|
|
265
|
-
// log.info("Processing WHERE: " + patch.where + '\n')
|
|
266
|
-
var query = new _query.Query('patch');
|
|
267
|
-
query.pat = patch.where;
|
|
268
|
-
query.pat.statements.map(function (st) {
|
|
269
|
-
st.graph = (0, _index.namedNode)(target.value);
|
|
233
|
+
ds2.map(function (st) {
|
|
234
|
+
targetKB.remove(st);
|
|
270
235
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
if (bindingsFound.length > 1) {
|
|
282
|
-
return patchCallback('Patch ambiguous. No patch done.');
|
|
283
|
-
}
|
|
284
|
-
binding = bindingsFound[0];
|
|
285
|
-
doPatch(patchCallback);
|
|
236
|
+
}
|
|
237
|
+
if (patch['insert']) {
|
|
238
|
+
// log.info("doPatch insert "+patch['insert'])
|
|
239
|
+
ds = patch['insert'];
|
|
240
|
+
if (binding) ds = ds.substitute(binding);
|
|
241
|
+
ds = ds.statements;
|
|
242
|
+
ds.map(function (st) {
|
|
243
|
+
st.graph = target;
|
|
244
|
+
targetKB.add(st.subject, st.predicate, st.object, st.graph);
|
|
286
245
|
});
|
|
287
|
-
} else {
|
|
288
|
-
doPatch(patchCallback);
|
|
289
246
|
}
|
|
247
|
+
onDonePatch();
|
|
290
248
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
249
|
+
if (patch.where) {
|
|
250
|
+
// log.info("Processing WHERE: " + patch.where + '\n')
|
|
251
|
+
var query = new _query.Query('patch');
|
|
252
|
+
query.pat = patch.where;
|
|
253
|
+
query.pat.statements.map(function (st) {
|
|
254
|
+
st.graph = (0, _index.namedNode)(target.value);
|
|
255
|
+
});
|
|
256
|
+
//@ts-ignore TODO: add sync property to Query when converting Query to typescript
|
|
257
|
+
query.sync = true;
|
|
258
|
+
var bindingsFound = [];
|
|
259
|
+
targetKB.query(query, function onBinding(binding) {
|
|
260
|
+
bindingsFound.push(binding);
|
|
261
|
+
// console.log(' got a binding: ' + bindingDebug(binding))
|
|
262
|
+
}, targetKB.fetcher, function onDone() {
|
|
263
|
+
if (bindingsFound.length === 0) {
|
|
264
|
+
return patchCallback('No match found to be patched:' + patch.where);
|
|
265
|
+
}
|
|
266
|
+
if (bindingsFound.length > 1) {
|
|
267
|
+
return patchCallback('Patch ambiguous. No patch done.');
|
|
268
|
+
}
|
|
269
|
+
binding = bindingsFound[0];
|
|
270
|
+
doPatch(patchCallback);
|
|
271
|
+
});
|
|
272
|
+
} else {
|
|
273
|
+
doPatch(patchCallback);
|
|
303
274
|
}
|
|
275
|
+
}
|
|
304
276
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
277
|
+
/**
|
|
278
|
+
* N3 allows for declaring blank nodes, this function enables that support
|
|
279
|
+
*
|
|
280
|
+
* @param x The blank node to be declared, supported in N3
|
|
281
|
+
*/
|
|
282
|
+
declareExistential(x) {
|
|
283
|
+
if (!this._existentialVariables) this._existentialVariables = [];
|
|
284
|
+
this._existentialVariables.push(x);
|
|
285
|
+
return x;
|
|
286
|
+
}
|
|
313
287
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}]; // sameAs -> equate & don't add to index
|
|
321
|
-
}
|
|
322
|
-
if ((0, _utils.ArrayIndexOf)(features, 'InverseFunctionalProperty') >= 0) {
|
|
323
|
-
this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode("".concat(owlNamespaceURI, "InverseFunctionalProperty")))] = [function (formula, subj, pred, obj, addFn) {
|
|
324
|
-
// yes subj not pred!
|
|
325
|
-
return formula.newPropertyAction(subj, handleIFP);
|
|
326
|
-
}]; // IFP -> handleIFP, do add to index
|
|
327
|
-
}
|
|
328
|
-
if ((0, _utils.ArrayIndexOf)(features, 'FunctionalProperty') >= 0) {
|
|
329
|
-
this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode("".concat(owlNamespaceURI, "FunctionalProperty")))] = [function (formula, subj, proj, obj, addFn) {
|
|
330
|
-
return formula.newPropertyAction(subj, handleFP);
|
|
331
|
-
}]; // FP => handleFP, do add to index
|
|
332
|
-
}
|
|
333
|
-
}
|
|
288
|
+
/**
|
|
289
|
+
* @param features
|
|
290
|
+
*/
|
|
291
|
+
initPropertyActions(features) {
|
|
292
|
+
// If the predicate is #type, use handleRDFType to create a typeCallback on the object
|
|
293
|
+
this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'))] = [handleRDFType];
|
|
334
294
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
295
|
+
// Assumption: these terms are not redirected @@fixme
|
|
296
|
+
if ((0, _utils.ArrayIndexOf)(features, 'sameAs') >= 0) {
|
|
297
|
+
this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${owlNamespaceURI}sameAs`))] = [function (formula, subj, pred, obj, why) {
|
|
298
|
+
// log.warn("Equating "+subj.uri+" sameAs "+obj.uri); //@@
|
|
299
|
+
formula.equate(subj, obj);
|
|
300
|
+
return true; // true if statement given is NOT needed in the store
|
|
301
|
+
}]; // sameAs -> equate & don't add to index
|
|
302
|
+
}
|
|
303
|
+
if ((0, _utils.ArrayIndexOf)(features, 'InverseFunctionalProperty') >= 0) {
|
|
304
|
+
this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${owlNamespaceURI}InverseFunctionalProperty`))] = [function (formula, subj, pred, obj, addFn) {
|
|
305
|
+
// yes subj not pred!
|
|
306
|
+
return formula.newPropertyAction(subj, handleIFP);
|
|
307
|
+
}]; // IFP -> handleIFP, do add to index
|
|
308
|
+
}
|
|
309
|
+
if ((0, _utils.ArrayIndexOf)(features, 'FunctionalProperty') >= 0) {
|
|
310
|
+
this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${owlNamespaceURI}FunctionalProperty`))] = [function (formula, subj, proj, obj, addFn) {
|
|
311
|
+
return formula.newPropertyAction(subj, handleFP);
|
|
312
|
+
}]; // FP => handleFP, do add to index
|
|
341
313
|
}
|
|
314
|
+
}
|
|
342
315
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.add(subj.statements);
|
|
316
|
+
/** @deprecated Use {add} instead */
|
|
317
|
+
addStatement(st) {
|
|
318
|
+
this.add(st.subject, st.predicate, st.object, st.graph);
|
|
319
|
+
return this.statements.length;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Adds a triple (quad) to the store.
|
|
324
|
+
*
|
|
325
|
+
* @param subj - The thing about which the fact a relationship is asserted.
|
|
326
|
+
* Also accepts a statement or an array of Statements.
|
|
327
|
+
* @param pred - The relationship which is asserted
|
|
328
|
+
* @param obj - The object of the relationship, e.g. another thing or a value. If passed a string, this will become a literal.
|
|
329
|
+
* @param why - The document in which the triple (S,P,O) was or will be stored on the web
|
|
330
|
+
* @returns The statement added to the store, or the store
|
|
331
|
+
*/
|
|
332
|
+
add(subj, pred, obj, why) {
|
|
333
|
+
var i;
|
|
334
|
+
if (arguments.length === 1) {
|
|
335
|
+
if (subj instanceof Array) {
|
|
336
|
+
for (i = 0; i < subj.length; i++) {
|
|
337
|
+
this.add(subj[i]);
|
|
366
338
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (!why) {
|
|
372
|
-
// system generated
|
|
373
|
-
why = this.fetcher ? this.fetcher.appNode : this.rdfFactory.defaultGraph();
|
|
374
|
-
}
|
|
375
|
-
if (typeof subj == 'string') {
|
|
376
|
-
subj = this.rdfFactory.namedNode(subj);
|
|
377
|
-
}
|
|
378
|
-
pred = _node.default.fromValue(pred);
|
|
379
|
-
var objNode = _node.default.fromValue(obj);
|
|
380
|
-
why = _node.default.fromValue(why);
|
|
381
|
-
if (!(0, _terms.isRDFlibSubject)(subj)) {
|
|
382
|
-
throw new Error('Subject is not a subject type');
|
|
383
|
-
}
|
|
384
|
-
if (!(0, _terms.isRDFlibPredicate)(pred)) {
|
|
385
|
-
throw new Error("Predicate ".concat(pred, " is not a predicate type"));
|
|
386
|
-
}
|
|
387
|
-
if (!(0, _terms.isRDFlibObject)(objNode)) {
|
|
388
|
-
throw new Error("Object ".concat(objNode, " is not an object type"));
|
|
389
|
-
}
|
|
390
|
-
if (!(0, _terms.isGraph)(why)) {
|
|
391
|
-
throw new Error("Why is not a graph type");
|
|
339
|
+
} else if ((0, _terms.isQuad)(subj)) {
|
|
340
|
+
this.add(subj.subject, subj.predicate, subj.object, subj.graph);
|
|
341
|
+
} else if ((0, _terms.isStore)(subj)) {
|
|
342
|
+
this.add(subj.statements);
|
|
392
343
|
}
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
var actions;
|
|
347
|
+
var st;
|
|
348
|
+
if (!why) {
|
|
349
|
+
// system generated
|
|
350
|
+
why = this.fetcher ? this.fetcher.appNode : this.rdfFactory.defaultGraph();
|
|
351
|
+
}
|
|
352
|
+
if (typeof subj == 'string') {
|
|
353
|
+
subj = this.rdfFactory.namedNode(subj);
|
|
354
|
+
}
|
|
355
|
+
pred = _node.default.fromValue(pred);
|
|
356
|
+
const objNode = _node.default.fromValue(obj);
|
|
357
|
+
why = _node.default.fromValue(why);
|
|
358
|
+
if (!(0, _terms.isRDFlibSubject)(subj)) {
|
|
359
|
+
throw new Error('Subject is not a subject type');
|
|
360
|
+
}
|
|
361
|
+
if (!(0, _terms.isRDFlibPredicate)(pred)) {
|
|
362
|
+
throw new Error(`Predicate ${pred} is not a predicate type`);
|
|
363
|
+
}
|
|
364
|
+
if (!(0, _terms.isRDFlibObject)(objNode)) {
|
|
365
|
+
throw new Error(`Object ${objNode} is not an object type`);
|
|
366
|
+
}
|
|
367
|
+
if (!(0, _terms.isGraph)(why)) {
|
|
368
|
+
throw new Error("Why is not a graph type");
|
|
369
|
+
}
|
|
370
|
+
//@ts-ignore This is not used internally
|
|
371
|
+
if (this.predicateCallback) {
|
|
393
372
|
//@ts-ignore This is not used internally
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
for (i = 0; i < actions.length; i++) {
|
|
405
|
-
done = done || actions[i](this, subj, pred, objNode, why);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
if (this.holds(subj, pred, objNode, why)) {
|
|
409
|
-
// Takes time but saves duplicates
|
|
410
|
-
// console.log('rdflib: Ignoring dup! {' + subj + ' ' + pred + ' ' + obj + ' ' + why + '}')
|
|
411
|
-
return null; // @@better to return self in all cases?
|
|
373
|
+
this.predicateCallback(this, pred, why);
|
|
374
|
+
}
|
|
375
|
+
// Action return true if the statement does not need to be added
|
|
376
|
+
var predHash = this.id(this.canon(pred));
|
|
377
|
+
actions = this.propertyActions[predHash]; // Predicate hash
|
|
378
|
+
var done = false;
|
|
379
|
+
if (actions) {
|
|
380
|
+
// alert('type: '+typeof actions +' @@ actions='+actions)
|
|
381
|
+
for (i = 0; i < actions.length; i++) {
|
|
382
|
+
done = done || actions[i](this, subj, pred, objNode, why);
|
|
412
383
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
384
|
+
}
|
|
385
|
+
if (this.holds(subj, pred, objNode, why)) {
|
|
386
|
+
// Takes time but saves duplicates
|
|
387
|
+
// console.log('rdflib: Ignoring dup! {' + subj + ' ' + pred + ' ' + obj + ' ' + why + '}')
|
|
388
|
+
return null; // @@better to return self in all cases?
|
|
389
|
+
}
|
|
390
|
+
// If we are tracking provenance, every thing should be loaded into the store
|
|
391
|
+
// if (done) return this.rdfFactory.quad(subj, pred, obj, why)
|
|
392
|
+
// Don't put it in the store
|
|
393
|
+
// still return this statement for owl:sameAs input
|
|
394
|
+
var hash = [this.id(this.canon(subj)), predHash, this.id(this.canon(objNode)), this.id(this.canon(why))];
|
|
395
|
+
// @ts-ignore this will fail if you pass a collection and the factory does not allow Collections
|
|
396
|
+
st = this.rdfFactory.quad(subj, pred, objNode, why);
|
|
397
|
+
for (i = 0; i < 4; i++) {
|
|
398
|
+
var ix = this.index[i];
|
|
399
|
+
var h = hash[i];
|
|
400
|
+
if (!ix[h]) {
|
|
401
|
+
ix[h] = [];
|
|
427
402
|
}
|
|
403
|
+
ix[h].push(st); // Set of things with this as subject, etc
|
|
404
|
+
}
|
|
428
405
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
try {
|
|
435
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
436
|
-
var callback = _step.value;
|
|
437
|
-
callback(st);
|
|
438
|
-
}
|
|
439
|
-
} catch (err) {
|
|
440
|
-
_iterator.e(err);
|
|
441
|
-
} finally {
|
|
442
|
-
_iterator.f();
|
|
443
|
-
}
|
|
406
|
+
// log.debug("ADDING {"+subj+" "+pred+" "+objNode+"} "+why)
|
|
407
|
+
this.statements.push(st);
|
|
408
|
+
if (this.dataCallbacks) {
|
|
409
|
+
for (const callback of this.dataCallbacks) {
|
|
410
|
+
callback(st);
|
|
444
411
|
}
|
|
445
|
-
return st;
|
|
446
412
|
}
|
|
413
|
+
return st;
|
|
414
|
+
}
|
|
447
415
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Returns the symbol with canonical URI as smushed
|
|
418
|
+
* @param term - An RDF node
|
|
419
|
+
*/
|
|
420
|
+
canon(term) {
|
|
421
|
+
if (!term) {
|
|
422
|
+
// @@ TODO Should improve this to return proper value - doing this to keep it backward compatible
|
|
423
|
+
return term;
|
|
424
|
+
}
|
|
425
|
+
const y = this.redirections[this.id(term)];
|
|
426
|
+
if (y) {
|
|
427
|
+
return y;
|
|
428
|
+
}
|
|
429
|
+
switch (term.termType) {
|
|
430
|
+
case _types.BlankNodeTermType:
|
|
431
|
+
return new _blankNode.default(term.value);
|
|
432
|
+
case _types.CollectionTermType:
|
|
457
433
|
return term;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
switch (term.termType) {
|
|
464
|
-
case _types.BlankNodeTermType:
|
|
465
|
-
return new _blankNode.default(term.value);
|
|
466
|
-
case _types.CollectionTermType:
|
|
467
|
-
return term;
|
|
434
|
+
// non-RDF/JS type, should just need to cast
|
|
435
|
+
case _types.DefaultGraphTermType:
|
|
436
|
+
return new _defaultGraph.default();
|
|
437
|
+
case _types.EmptyTermType:
|
|
468
438
|
// non-RDF/JS type, should just need to cast
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
case _types.VariableTermType:
|
|
482
|
-
return new _variable.default(term.value);
|
|
483
|
-
default:
|
|
484
|
-
throw new Error("Term Type not recognized for canonization: ".concat(term.termType));
|
|
485
|
-
}
|
|
439
|
+
return term;
|
|
440
|
+
case _types.GraphTermType:
|
|
441
|
+
// non-RDF/JS type, should just need to cast
|
|
442
|
+
return term;
|
|
443
|
+
case _types.LiteralTermType:
|
|
444
|
+
return new _literal.default(term.value, term.language, term.datatype);
|
|
445
|
+
case _types.NamedNodeTermType:
|
|
446
|
+
return new _namedNode.default(term.value);
|
|
447
|
+
case _types.VariableTermType:
|
|
448
|
+
return new _variable.default(term.value);
|
|
449
|
+
default:
|
|
450
|
+
throw new Error(`Term Type not recognized for canonization: ${term.termType}`);
|
|
486
451
|
}
|
|
452
|
+
}
|
|
487
453
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
this.
|
|
495
|
-
for (var
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
// @ts-ignore should this pass an array or a single statement? checkStateMentsList expects an array.
|
|
500
|
-
this.checkStatementList(ix[key], p);
|
|
501
|
-
}
|
|
454
|
+
/**
|
|
455
|
+
* Checks this formula for consistency
|
|
456
|
+
*/
|
|
457
|
+
check() {
|
|
458
|
+
this.checkStatementList(this.statements);
|
|
459
|
+
for (var p = 0; p < 4; p++) {
|
|
460
|
+
var ix = this.index[p];
|
|
461
|
+
for (var key in ix) {
|
|
462
|
+
if (ix.hasOwnProperty(key)) {
|
|
463
|
+
// @ts-ignore should this pass an array or a single statement? checkStateMentsList expects an array.
|
|
464
|
+
this.checkStatementList(ix[key], p);
|
|
502
465
|
}
|
|
503
466
|
}
|
|
504
467
|
}
|
|
468
|
+
}
|
|
505
469
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
var
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (a[i].subject.equals(x.subject) && a[i].predicate.equals(x.predicate) && a[i].object.equals(x.object) && a[i].why.equals(x.graph)) {
|
|
526
|
-
return true;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
for (var p = 0; p < 4; p++) {
|
|
531
|
-
var c = this.canon(term[p]);
|
|
532
|
-
var h = this.id(c);
|
|
533
|
-
if (!this.index[p][h]) {
|
|
534
|
-
// throw new Error('No ' + name[p] + ' index for statement ' + st + '@' + st.why + origin)
|
|
535
|
-
} else {
|
|
536
|
-
if (!arrayContains(this.index[p][h], st)) {
|
|
537
|
-
// throw new Error('Index for ' + name[p] + ' does not have statement ' + st + '@' + st.why + origin)
|
|
538
|
-
}
|
|
470
|
+
/**
|
|
471
|
+
* Checks a list of statements for consistency
|
|
472
|
+
* @param sts - The list of statements to check
|
|
473
|
+
* @param from - An index with the array ['subject', 'predicate', 'object', 'why']
|
|
474
|
+
*/
|
|
475
|
+
checkStatementList(sts, from) {
|
|
476
|
+
if (from === undefined) {
|
|
477
|
+
from = 0;
|
|
478
|
+
}
|
|
479
|
+
var names = ['subject', 'predicate', 'object', 'why'];
|
|
480
|
+
var origin = ' found in ' + names[from] + ' index.';
|
|
481
|
+
var st;
|
|
482
|
+
for (var j = 0; j < sts.length; j++) {
|
|
483
|
+
st = sts[j];
|
|
484
|
+
var term = [st.subject, st.predicate, st.object, st.graph];
|
|
485
|
+
var arrayContains = function (a, x) {
|
|
486
|
+
for (var i = 0; i < a.length; i++) {
|
|
487
|
+
if (a[i].subject.equals(x.subject) && a[i].predicate.equals(x.predicate) && a[i].object.equals(x.object) && a[i].why.equals(x.graph)) {
|
|
488
|
+
return true;
|
|
539
489
|
}
|
|
540
490
|
}
|
|
541
|
-
|
|
542
|
-
|
|
491
|
+
};
|
|
492
|
+
for (var p = 0; p < 4; p++) {
|
|
493
|
+
var c = this.canon(term[p]);
|
|
494
|
+
var h = this.id(c);
|
|
495
|
+
if (!this.index[p][h]) {
|
|
496
|
+
// throw new Error('No ' + name[p] + ' index for statement ' + st + '@' + st.why + origin)
|
|
497
|
+
} else {
|
|
498
|
+
if (!arrayContains(this.index[p][h], st)) {
|
|
499
|
+
// throw new Error('Index for ' + name[p] + ' does not have statement ' + st + '@' + st.why + origin)
|
|
500
|
+
}
|
|
543
501
|
}
|
|
544
502
|
}
|
|
503
|
+
if (!arrayContains(this.statements, st)) {
|
|
504
|
+
throw new Error('Statement list does not statement ' + st + '@' + st.graph + origin);
|
|
505
|
+
}
|
|
545
506
|
}
|
|
507
|
+
}
|
|
546
508
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
509
|
+
/**
|
|
510
|
+
* Closes this formula (and return it)
|
|
511
|
+
*/
|
|
512
|
+
close() {
|
|
513
|
+
return this;
|
|
514
|
+
}
|
|
515
|
+
compareTerms(u1, u2) {
|
|
516
|
+
// Keep compatibility with downstream classOrder changes
|
|
517
|
+
if (Object.prototype.hasOwnProperty.call(u1, "compareTerm")) {
|
|
518
|
+
return u1.compareTerm(u2);
|
|
554
519
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
value: function compareTerms(u1, u2) {
|
|
558
|
-
// Keep compatibility with downstream classOrder changes
|
|
559
|
-
if (Object.prototype.hasOwnProperty.call(u1, "compareTerm")) {
|
|
560
|
-
return u1.compareTerm(u2);
|
|
561
|
-
}
|
|
562
|
-
if (_classOrder.default[u1.termType] < _classOrder.default[u2.termType]) {
|
|
563
|
-
return -1;
|
|
564
|
-
}
|
|
565
|
-
if (_classOrder.default[u1.termType] > _classOrder.default[u2.termType]) {
|
|
566
|
-
return +1;
|
|
567
|
-
}
|
|
568
|
-
if (u1.value < u2.value) {
|
|
569
|
-
return -1;
|
|
570
|
-
}
|
|
571
|
-
if (u1.value > u2.value) {
|
|
572
|
-
return +1;
|
|
573
|
-
}
|
|
574
|
-
return 0;
|
|
520
|
+
if (_classOrder.default[u1.termType] < _classOrder.default[u2.termType]) {
|
|
521
|
+
return -1;
|
|
575
522
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}, {
|
|
585
|
-
key: "copyTo",
|
|
586
|
-
value: function copyTo(template, target, flags) {
|
|
587
|
-
if (!flags) flags = [];
|
|
588
|
-
var statList = this.statementsMatching(template);
|
|
589
|
-
if ((0, _utils.ArrayIndexOf)(flags, 'two-direction') !== -1) {
|
|
590
|
-
statList.concat(this.statementsMatching(undefined, undefined, template));
|
|
591
|
-
}
|
|
592
|
-
for (var i = 0; i < statList.length; i++) {
|
|
593
|
-
var st = statList[i];
|
|
594
|
-
switch (st.object.termType) {
|
|
595
|
-
case 'NamedNode':
|
|
596
|
-
this.add(target, st.predicate, st.object);
|
|
597
|
-
break;
|
|
598
|
-
case 'Literal':
|
|
599
|
-
case 'BlankNode':
|
|
600
|
-
// @ts-ignore Collections can appear here
|
|
601
|
-
case 'Collection':
|
|
602
|
-
// @ts-ignore Possible bug: copy is not available on Collections
|
|
603
|
-
this.add(target, st.predicate, st.object.copy(this));
|
|
604
|
-
}
|
|
605
|
-
if ((0, _utils.ArrayIndexOf)(flags, 'delete') !== -1) {
|
|
606
|
-
this.remove(st);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
523
|
+
if (_classOrder.default[u1.termType] > _classOrder.default[u2.termType]) {
|
|
524
|
+
return +1;
|
|
525
|
+
}
|
|
526
|
+
if (u1.value < u2.value) {
|
|
527
|
+
return -1;
|
|
528
|
+
}
|
|
529
|
+
if (u1.value > u2.value) {
|
|
530
|
+
return +1;
|
|
609
531
|
}
|
|
532
|
+
return 0;
|
|
533
|
+
}
|
|
610
534
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
var
|
|
626
|
-
|
|
627
|
-
|
|
535
|
+
/**
|
|
536
|
+
* replaces @template with @target and add appropriate triples
|
|
537
|
+
* removes no triples by default and is a one-direction replication
|
|
538
|
+
* @param template node to copy
|
|
539
|
+
* @param target node to copy to
|
|
540
|
+
* @param flags Whether or not to do a two-directional copy and/or delete triples
|
|
541
|
+
*/
|
|
542
|
+
copyTo(template, target, flags) {
|
|
543
|
+
if (!flags) flags = [];
|
|
544
|
+
var statList = this.statementsMatching(template);
|
|
545
|
+
if ((0, _utils.ArrayIndexOf)(flags, 'two-direction') !== -1) {
|
|
546
|
+
statList.concat(this.statementsMatching(undefined, undefined, template));
|
|
547
|
+
}
|
|
548
|
+
for (var i = 0; i < statList.length; i++) {
|
|
549
|
+
var st = statList[i];
|
|
550
|
+
switch (st.object.termType) {
|
|
551
|
+
case 'NamedNode':
|
|
552
|
+
this.add(target, st.predicate, st.object);
|
|
553
|
+
break;
|
|
554
|
+
case 'Literal':
|
|
555
|
+
case 'BlankNode':
|
|
556
|
+
// @ts-ignore Collections can appear here
|
|
557
|
+
case 'Collection':
|
|
558
|
+
// @ts-ignore Possible bug: copy is not available on Collections
|
|
559
|
+
this.add(target, st.predicate, st.object.copy(this));
|
|
628
560
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
if (d < 0) {
|
|
632
|
-
// u1 less than u2
|
|
633
|
-
return this.replaceWith(u2, u1);
|
|
634
|
-
} else {
|
|
635
|
-
return this.replaceWith(u1, u2);
|
|
561
|
+
if ((0, _utils.ArrayIndexOf)(flags, 'delete') !== -1) {
|
|
562
|
+
this.remove(st);
|
|
636
563
|
}
|
|
637
564
|
}
|
|
565
|
+
}
|
|
638
566
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
567
|
+
/**
|
|
568
|
+
* Simplify graph in store when we realize two identifiers are equivalent
|
|
569
|
+
* We replace the bigger with the smaller.
|
|
570
|
+
* @param u1in The first node
|
|
571
|
+
* @param u2in The second node
|
|
572
|
+
*/
|
|
573
|
+
equate(u1in, u2in) {
|
|
574
|
+
// log.warn("Equating "+u1+" and "+u2); // @@
|
|
575
|
+
// @@JAMBO Must canonicalize the uris to prevent errors from a=b=c
|
|
576
|
+
// 03-21-2010
|
|
577
|
+
const u1 = this.canon(u1in);
|
|
578
|
+
const u2 = this.canon(u2in);
|
|
579
|
+
var d = this.compareTerms(u1, u2);
|
|
580
|
+
if (!d) {
|
|
581
|
+
return true; // No information in {a = a}
|
|
648
582
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
* kb.length // -> 0
|
|
657
|
-
* ```
|
|
658
|
-
* @returns {Number}
|
|
659
|
-
*/
|
|
660
|
-
}, {
|
|
661
|
-
key: "length",
|
|
662
|
-
get: function get() {
|
|
663
|
-
return this.statements.length;
|
|
583
|
+
// var big
|
|
584
|
+
// var small
|
|
585
|
+
if (d < 0) {
|
|
586
|
+
// u1 less than u2
|
|
587
|
+
return this.replaceWith(u2, u1);
|
|
588
|
+
} else {
|
|
589
|
+
return this.replaceWith(u1, u2);
|
|
664
590
|
}
|
|
591
|
+
}
|
|
665
592
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
*/
|
|
675
|
-
}, {
|
|
676
|
-
key: "match",
|
|
677
|
-
value: function match(subject, predicate, object, graph) {
|
|
678
|
-
return this.statementsMatching(_node.default.fromValue(subject), _node.default.fromValue(predicate), _node.default.fromValue(object), _node.default.fromValue(graph));
|
|
679
|
-
}
|
|
593
|
+
/**
|
|
594
|
+
* Creates a new empty indexed formula
|
|
595
|
+
* Only applicable for IndexedFormula, but TypeScript won't allow a subclass to override a property
|
|
596
|
+
* @param features The list of features
|
|
597
|
+
*/
|
|
598
|
+
formula(features) {
|
|
599
|
+
return new IndexedFormula(features);
|
|
600
|
+
}
|
|
680
601
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
602
|
+
/**
|
|
603
|
+
* Returns the number of statements contained in this IndexedFormula.
|
|
604
|
+
* (Getter proxy to this.statements).
|
|
605
|
+
* Usage:
|
|
606
|
+
* ```
|
|
607
|
+
* var kb = rdf.graph()
|
|
608
|
+
* kb.length // -> 0
|
|
609
|
+
* ```
|
|
610
|
+
* @returns {Number}
|
|
611
|
+
*/
|
|
612
|
+
get length() {
|
|
613
|
+
return this.statements.length;
|
|
614
|
+
}
|
|
691
615
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Returns any quads matching the given arguments.
|
|
618
|
+
* Standard RDFJS spec method for Source objects, implemented as an
|
|
619
|
+
* alias to `statementsMatching()`
|
|
620
|
+
* @param subject The subject
|
|
621
|
+
* @param predicate The predicate
|
|
622
|
+
* @param object The object
|
|
623
|
+
* @param graph The graph that contains the statement
|
|
624
|
+
*/
|
|
625
|
+
match(subject, predicate, object, graph) {
|
|
626
|
+
return this.statementsMatching(_node.default.fromValue(subject), _node.default.fromValue(predicate), _node.default.fromValue(object), _node.default.fromValue(graph));
|
|
627
|
+
}
|
|
704
628
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
// log.debug("newPropertyAction: "+pred)
|
|
714
|
-
var hash = this.id(pred);
|
|
715
|
-
if (!this.propertyActions[hash]) {
|
|
716
|
-
this.propertyActions[hash] = [];
|
|
717
|
-
}
|
|
718
|
-
this.propertyActions[hash].push(action);
|
|
719
|
-
// Now apply the function to to statements already in the store
|
|
720
|
-
var toBeFixed = this.statementsMatching(undefined, pred, undefined);
|
|
721
|
-
var done = false;
|
|
722
|
-
for (var i = 0; i < toBeFixed.length; i++) {
|
|
723
|
-
// NOT optimized - sort toBeFixed etc
|
|
724
|
-
done = done || action(this, toBeFixed[i].subject, pred, toBeFixed[i].object);
|
|
725
|
-
}
|
|
726
|
-
return done;
|
|
727
|
-
}
|
|
629
|
+
/**
|
|
630
|
+
* Find out whether a given URI is used as symbol in the formula
|
|
631
|
+
* @param uri The URI to look for
|
|
632
|
+
*/
|
|
633
|
+
mentionsURI(uri) {
|
|
634
|
+
var hash = '<' + uri + '>';
|
|
635
|
+
return !!this.subjectIndex[hash] || !!this.objectIndex[hash] || !!this.predicateIndex[hash];
|
|
636
|
+
}
|
|
728
637
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
this._universalVariables.push(x);
|
|
740
|
-
return x;
|
|
741
|
-
}
|
|
638
|
+
/**
|
|
639
|
+
* Existentials are BNodes - something exists without naming
|
|
640
|
+
* @param uri An URI
|
|
641
|
+
*/
|
|
642
|
+
newExistential(uri) {
|
|
643
|
+
if (!uri) return this.bnode();
|
|
644
|
+
var x = this.sym(uri);
|
|
645
|
+
// @ts-ignore x should be blanknode, but is namedNode.
|
|
646
|
+
return this.declareExistential(x);
|
|
647
|
+
}
|
|
742
648
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
649
|
+
/**
|
|
650
|
+
* Adds a new property action
|
|
651
|
+
* @param pred the predicate that the function should be triggered on
|
|
652
|
+
* @param action the function that should trigger
|
|
653
|
+
*/
|
|
654
|
+
newPropertyAction(pred, action) {
|
|
655
|
+
// log.debug("newPropertyAction: "+pred)
|
|
656
|
+
var hash = this.id(pred);
|
|
657
|
+
if (!this.propertyActions[hash]) {
|
|
658
|
+
this.propertyActions[hash] = [];
|
|
748
659
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
key: "nextSymbol",
|
|
757
|
-
value: function nextSymbol(doc) {
|
|
758
|
-
for (var i = 0;; i++) {
|
|
759
|
-
var uri = doc.value + '#n' + i;
|
|
760
|
-
if (!this.mentionsURI(uri)) return this.sym(uri);
|
|
761
|
-
}
|
|
660
|
+
this.propertyActions[hash].push(action);
|
|
661
|
+
// Now apply the function to to statements already in the store
|
|
662
|
+
var toBeFixed = this.statementsMatching(undefined, pred, undefined);
|
|
663
|
+
var done = false;
|
|
664
|
+
for (var i = 0; i < toBeFixed.length; i++) {
|
|
665
|
+
// NOT optimized - sort toBeFixed etc
|
|
666
|
+
done = done || action(this, toBeFixed[i].subject, pred, toBeFixed[i].object);
|
|
762
667
|
}
|
|
668
|
+
return done;
|
|
669
|
+
}
|
|
763
670
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
671
|
+
/**
|
|
672
|
+
* Creates a new universal node
|
|
673
|
+
* Universals are Variables
|
|
674
|
+
* @param uri An URI
|
|
675
|
+
*/
|
|
676
|
+
newUniversal(uri) {
|
|
677
|
+
var x = this.sym(uri);
|
|
678
|
+
if (!this._universalVariables) this._universalVariables = [];
|
|
679
|
+
this._universalVariables.push(x);
|
|
680
|
+
return x;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// convenience function used by N3 parser
|
|
684
|
+
variable(name) {
|
|
685
|
+
return new _variable.default(name);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Find an unused id for a file being edited: return a symbol
|
|
690
|
+
* (Note: Slow iff a lot of them -- could be O(log(k)) )
|
|
691
|
+
* @param doc A document named node
|
|
692
|
+
*/
|
|
693
|
+
nextSymbol(doc) {
|
|
694
|
+
for (var i = 0;; i++) {
|
|
695
|
+
var uri = doc.value + '#n' + i;
|
|
696
|
+
if (!this.mentionsURI(uri)) return this.sym(uri);
|
|
776
697
|
}
|
|
698
|
+
}
|
|
777
699
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
700
|
+
/**
|
|
701
|
+
* Query this store asynchronously, return bindings in callback
|
|
702
|
+
*
|
|
703
|
+
* @param myQuery The query to be run
|
|
704
|
+
* @param callback Function to call when bindings
|
|
705
|
+
* @param Fetcher | null If you want the query to do link following
|
|
706
|
+
* @param onDone OBSOLETE - do not use this // @@ Why not ?? Called when query complete
|
|
707
|
+
*/
|
|
708
|
+
query(myQuery, callback, fetcher, onDone) {
|
|
709
|
+
return _query.indexedFormulaQuery.call(this, myQuery, callback, fetcher, onDone);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Query this store synchronously and return bindings
|
|
714
|
+
*
|
|
715
|
+
* @param myQuery The query to be run
|
|
716
|
+
*/
|
|
717
|
+
querySync(myQuery) {
|
|
718
|
+
var results = [];
|
|
719
|
+
function saveBinginds(bindings) {
|
|
720
|
+
results.push(bindings);
|
|
721
|
+
}
|
|
722
|
+
function onDone() {
|
|
723
|
+
done = true;
|
|
801
724
|
}
|
|
725
|
+
var done = false;
|
|
726
|
+
// @ts-ignore TODO: Add .sync to Query
|
|
727
|
+
myQuery.sync = true;
|
|
728
|
+
_query.indexedFormulaQuery.call(this, myQuery, saveBinginds, null, onDone);
|
|
729
|
+
if (!done) {
|
|
730
|
+
throw new Error('Sync query should have called done function');
|
|
731
|
+
}
|
|
732
|
+
return results;
|
|
733
|
+
}
|
|
802
734
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
for (var i = 0; i < st.length; i++) {
|
|
812
|
-
this.remove(st[i]);
|
|
813
|
-
}
|
|
814
|
-
return this;
|
|
815
|
-
}
|
|
816
|
-
if ((0, _terms.isStore)(st)) {
|
|
817
|
-
return this.remove(st.statements);
|
|
818
|
-
}
|
|
819
|
-
var sts = this.statementsMatching(st.subject, st.predicate, st.object, st.graph);
|
|
820
|
-
if (!sts.length) {
|
|
821
|
-
throw new Error('Statement to be removed is not on store: ' + st);
|
|
735
|
+
/**
|
|
736
|
+
* Removes one or multiple statement(s) from this formula
|
|
737
|
+
* @param st - A Statement or array of Statements to remove
|
|
738
|
+
*/
|
|
739
|
+
remove(st) {
|
|
740
|
+
if (st instanceof Array) {
|
|
741
|
+
for (var i = 0; i < st.length; i++) {
|
|
742
|
+
this.remove(st[i]);
|
|
822
743
|
}
|
|
823
|
-
this.removeStatement(sts[0]);
|
|
824
744
|
return this;
|
|
825
745
|
}
|
|
746
|
+
if ((0, _terms.isStore)(st)) {
|
|
747
|
+
return this.remove(st.statements);
|
|
748
|
+
}
|
|
749
|
+
var sts = this.statementsMatching(st.subject, st.predicate, st.object, st.graph);
|
|
750
|
+
if (!sts.length) {
|
|
751
|
+
throw new Error('Statement to be removed is not on store: ' + st);
|
|
752
|
+
}
|
|
753
|
+
this.removeStatement(sts[0]);
|
|
754
|
+
return this;
|
|
755
|
+
}
|
|
826
756
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
for (var i = 0; i < sts.length; i++) {
|
|
838
|
-
this.removeStatement(sts[i]);
|
|
839
|
-
}
|
|
840
|
-
this.removeMatches(doc, null, null);
|
|
841
|
-
return this;
|
|
757
|
+
/**
|
|
758
|
+
* Removes all statements in a doc, along with the related metadata including request/response/status
|
|
759
|
+
* @param doc - The document / graph
|
|
760
|
+
*/
|
|
761
|
+
removeDocument(doc) {
|
|
762
|
+
this.removeMetadata(doc);
|
|
763
|
+
// remove document
|
|
764
|
+
var sts = this.statementsMatching(undefined, undefined, undefined, doc).slice(); // Take a copy as this is the actual index
|
|
765
|
+
for (var i = 0; i < sts.length; i++) {
|
|
766
|
+
this.removeStatement(sts[i]);
|
|
842
767
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.removeStatement(sts[i]);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
// response items list
|
|
866
|
-
var response = this.any(request, this.sym("".concat(linkNamespaceURI, "response")), null, meta);
|
|
867
|
-
if (response != undefined) {
|
|
868
|
-
sts = this.statementsMatching(response, null, null, meta).slice();
|
|
869
|
-
for (var i = 0; i < sts.length; i++) {
|
|
870
|
-
this.removeStatement(sts[i]);
|
|
871
|
-
}
|
|
768
|
+
this.removeMatches(doc, null, null);
|
|
769
|
+
return this;
|
|
770
|
+
}
|
|
771
|
+
removeMetadata(doc) {
|
|
772
|
+
const meta = this.sym('chrome://TheCurrentSession'); // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
|
|
773
|
+
const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#';
|
|
774
|
+
// remove status/response/request metadata
|
|
775
|
+
const requests = this.statementsMatching(undefined, this.sym(`${linkNamespaceURI}requestedURI`), this.rdfFactory.literal(doc.value), meta).map(st => st.subject);
|
|
776
|
+
for (var r = 0; r < requests.length; r++) {
|
|
777
|
+
const request = requests[r];
|
|
778
|
+
if (request != undefined) {
|
|
779
|
+
// removeMatches unresolved issue with collection https://github.com/linkeddata/rdflib.js/issues/631
|
|
780
|
+
let sts;
|
|
781
|
+
// status collection
|
|
782
|
+
const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta);
|
|
783
|
+
if (status != undefined) {
|
|
784
|
+
sts = this.statementsMatching(status, this.sym(`${linkNamespaceURI}status`), null, meta).slice();
|
|
785
|
+
for (var i = 0; i < sts.length; i++) {
|
|
786
|
+
this.removeStatement(sts[i]);
|
|
872
787
|
}
|
|
873
|
-
|
|
874
|
-
|
|
788
|
+
}
|
|
789
|
+
// response items list
|
|
790
|
+
const response = this.any(request, this.sym(`${linkNamespaceURI}response`), null, meta);
|
|
791
|
+
if (response != undefined) {
|
|
792
|
+
sts = this.statementsMatching(response, null, null, meta).slice();
|
|
875
793
|
for (var i = 0; i < sts.length; i++) {
|
|
876
794
|
this.removeStatement(sts[i]);
|
|
877
795
|
}
|
|
878
796
|
}
|
|
797
|
+
// request triples
|
|
798
|
+
sts = this.statementsMatching(request, null, null, meta).slice();
|
|
799
|
+
for (var i = 0; i < sts.length; i++) {
|
|
800
|
+
this.removeStatement(sts[i]);
|
|
801
|
+
}
|
|
879
802
|
}
|
|
880
|
-
this.removeMatches(this.sym(doc.value), null, null, meta); // content-type
|
|
881
|
-
return this;
|
|
882
803
|
}
|
|
804
|
+
this.removeMatches(this.sym(doc.value), null, null, meta); // content-type
|
|
805
|
+
return this;
|
|
806
|
+
}
|
|
883
807
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
for (i = 0; i < statements.length; i++) this.remove(statements[i]);
|
|
905
|
-
}
|
|
808
|
+
/**
|
|
809
|
+
* Remove all statements matching args (within limit) *
|
|
810
|
+
* @param subj The subject
|
|
811
|
+
* @param pred The predicate
|
|
812
|
+
* @param obj The object
|
|
813
|
+
* @param why The graph that contains the statement
|
|
814
|
+
* @param limit The number of statements to remove
|
|
815
|
+
*/
|
|
816
|
+
removeMany(subj, pred, obj, why, limit) {
|
|
817
|
+
// log.debug("entering removeMany w/ subj,pred,obj,why,limit = " + subj +", "+ pred+", " + obj+", " + why+", " + limit)
|
|
818
|
+
var sts = this.statementsMatching(subj, pred, obj, why, false);
|
|
819
|
+
// This is a subtle bug that occurred in updateCenter.js too.
|
|
820
|
+
// The fact is, this.statementsMatching returns this.whyIndex instead of a copy of it
|
|
821
|
+
// but for perfromance consideration, it's better to just do that
|
|
822
|
+
// so make a copy here.
|
|
823
|
+
var statements = [];
|
|
824
|
+
for (var i = 0; i < sts.length; i++) statements.push(sts[i]);
|
|
825
|
+
if (limit) statements = statements.slice(0, limit);
|
|
826
|
+
for (i = 0; i < statements.length; i++) this.remove(statements[i]);
|
|
827
|
+
}
|
|
906
828
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
return this;
|
|
919
|
-
}
|
|
829
|
+
/**
|
|
830
|
+
* Remove all matching statements
|
|
831
|
+
* @param subject The subject
|
|
832
|
+
* @param predicate The predicate
|
|
833
|
+
* @param object The object
|
|
834
|
+
* @param graph The graph that contains the statement
|
|
835
|
+
*/
|
|
836
|
+
removeMatches(subject, predicate, object, graph) {
|
|
837
|
+
this.removeMany(subject, predicate, object, graph);
|
|
838
|
+
return this;
|
|
839
|
+
}
|
|
920
840
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
var
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
} else {
|
|
939
|
-
this.rdfArrayRemove(this.index[p][h], st);
|
|
940
|
-
}
|
|
841
|
+
/**
|
|
842
|
+
* Remove a particular statement object from the store
|
|
843
|
+
*
|
|
844
|
+
* @param st - a statement which is already in the store and indexed.
|
|
845
|
+
* Make sure you only use this for these.
|
|
846
|
+
* Otherwise, you should use remove() above.
|
|
847
|
+
*/
|
|
848
|
+
removeStatement(st) {
|
|
849
|
+
// log.debug("entering remove w/ st=" + st)
|
|
850
|
+
var term = [st.subject, st.predicate, st.object, st.graph];
|
|
851
|
+
for (var p = 0; p < 4; p++) {
|
|
852
|
+
var c = this.canon(term[p]);
|
|
853
|
+
var h = this.id(c);
|
|
854
|
+
if (!this.index[p][h]) {
|
|
855
|
+
// log.warn ("Statement removal: no index '+p+': "+st)
|
|
856
|
+
} else {
|
|
857
|
+
this.rdfArrayRemove(this.index[p][h], st);
|
|
941
858
|
}
|
|
942
|
-
this.rdfArrayRemove(this.statements, st);
|
|
943
|
-
return this;
|
|
944
859
|
}
|
|
860
|
+
this.rdfArrayRemove(this.statements, st);
|
|
861
|
+
return this;
|
|
862
|
+
}
|
|
945
863
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
for (var i = 0; i < sts.length; i++) {
|
|
954
|
-
this.remove(sts[i]);
|
|
955
|
-
}
|
|
956
|
-
return this;
|
|
864
|
+
/**
|
|
865
|
+
* Removes statements
|
|
866
|
+
* @param sts The statements to remove
|
|
867
|
+
*/
|
|
868
|
+
removeStatements(sts) {
|
|
869
|
+
for (var i = 0; i < sts.length; i++) {
|
|
870
|
+
this.remove(sts[i]);
|
|
957
871
|
}
|
|
872
|
+
return this;
|
|
873
|
+
}
|
|
958
874
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
var
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
if (!oldlist) {
|
|
971
|
-
return; // none to move
|
|
972
|
-
}
|
|
973
|
-
var newlist = ix[newhash];
|
|
974
|
-
if (!newlist) {
|
|
975
|
-
ix[newhash] = oldlist;
|
|
976
|
-
} else {
|
|
977
|
-
ix[newhash] = oldlist.concat(newlist);
|
|
978
|
-
}
|
|
979
|
-
delete ix[oldhash];
|
|
980
|
-
};
|
|
981
|
-
// the canonical one carries all the indexes
|
|
982
|
-
for (var i = 0; i < 4; i++) {
|
|
983
|
-
moveIndex(this.index[i]);
|
|
875
|
+
/**
|
|
876
|
+
* Replace big with small, obsoleted with obsoleting.
|
|
877
|
+
*/
|
|
878
|
+
replaceWith(big, small) {
|
|
879
|
+
// log.debug("Replacing "+big+" with "+small) // this.id(@@
|
|
880
|
+
var oldhash = this.id(big);
|
|
881
|
+
var newhash = this.id(small);
|
|
882
|
+
var moveIndex = function (ix) {
|
|
883
|
+
var oldlist = ix[oldhash];
|
|
884
|
+
if (!oldlist) {
|
|
885
|
+
return; // none to move
|
|
984
886
|
}
|
|
985
|
-
|
|
986
|
-
if (
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
887
|
+
var newlist = ix[newhash];
|
|
888
|
+
if (!newlist) {
|
|
889
|
+
ix[newhash] = oldlist;
|
|
890
|
+
} else {
|
|
891
|
+
ix[newhash] = oldlist.concat(newlist);
|
|
892
|
+
}
|
|
893
|
+
delete ix[oldhash];
|
|
894
|
+
};
|
|
895
|
+
// the canonical one carries all the indexes
|
|
896
|
+
for (var i = 0; i < 4; i++) {
|
|
897
|
+
moveIndex(this.index[i]);
|
|
898
|
+
}
|
|
899
|
+
this.redirections[oldhash] = small;
|
|
900
|
+
if (big.value) {
|
|
901
|
+
// @@JAMBO: must update redirections,aliases from sub-items, too.
|
|
902
|
+
if (!this.aliases[newhash]) {
|
|
903
|
+
this.aliases[newhash] = [];
|
|
904
|
+
}
|
|
905
|
+
this.aliases[newhash].push(big); // Back link
|
|
906
|
+
if (this.aliases[oldhash]) {
|
|
907
|
+
for (i = 0; i < this.aliases[oldhash].length; i++) {
|
|
908
|
+
this.redirections[this.id(this.aliases[oldhash][i])] = small;
|
|
909
|
+
this.aliases[newhash].push(this.aliases[oldhash][i]);
|
|
1002
910
|
}
|
|
1003
911
|
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
912
|
+
this.add(small, this.sym('http://www.w3.org/2007/ont/link#uri'), big);
|
|
913
|
+
// If two things are equal, and one is requested, we should request the other.
|
|
914
|
+
if (this.fetcher) {
|
|
915
|
+
this.fetcher.nowKnownAs(big, small);
|
|
916
|
+
}
|
|
1008
917
|
}
|
|
918
|
+
moveIndex(this.classActions);
|
|
919
|
+
moveIndex(this.propertyActions);
|
|
920
|
+
// log.debug("Equate done. "+big+" to be known as "+small)
|
|
921
|
+
return true; // true means the statement does not need to be put in
|
|
922
|
+
}
|
|
1009
923
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
924
|
+
/**
|
|
925
|
+
* Return all equivalent URIs by which this is known
|
|
926
|
+
* @param x A named node
|
|
927
|
+
*/
|
|
928
|
+
allAliases(x) {
|
|
929
|
+
var a = this.aliases[this.id(this.canon(x))] || [];
|
|
930
|
+
a.push(this.canon(x));
|
|
931
|
+
return a;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Compare by canonical URI as smushed
|
|
936
|
+
* @param x A named node
|
|
937
|
+
* @param y Another named node
|
|
938
|
+
*/
|
|
939
|
+
sameThings(x, y) {
|
|
940
|
+
if (x.equals(y)) {
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
var x1 = this.canon(x);
|
|
944
|
+
// alert('x1='+x1)
|
|
945
|
+
if (!x1) return false;
|
|
946
|
+
var y1 = this.canon(y);
|
|
947
|
+
// alert('y1='+y1); //@@
|
|
948
|
+
if (!y1) return false;
|
|
949
|
+
return x1.value === y1.value;
|
|
950
|
+
}
|
|
951
|
+
setPrefixForURI(prefix, nsuri) {
|
|
952
|
+
// TODO: This is a hack for our own issues, which ought to be fixed
|
|
953
|
+
// post-release
|
|
954
|
+
// See http://dig.csail.mit.edu/cgi-bin/roundup.cgi/$rdf/issue227
|
|
955
|
+
if (prefix === 'tab' && this.namespaces['tab']) {
|
|
956
|
+
return;
|
|
957
|
+
} // There are files around with long badly generated prefixes like this
|
|
958
|
+
if (prefix.slice(0, 2) === 'ns' || prefix.slice(0, 7) === 'default') {
|
|
959
|
+
return;
|
|
1020
960
|
}
|
|
1021
961
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
* @param y Another named node
|
|
1026
|
-
*/
|
|
1027
|
-
}, {
|
|
1028
|
-
key: "sameThings",
|
|
1029
|
-
value: function sameThings(x, y) {
|
|
1030
|
-
if (x.equals(y)) {
|
|
1031
|
-
return true;
|
|
1032
|
-
}
|
|
1033
|
-
var x1 = this.canon(x);
|
|
1034
|
-
// alert('x1='+x1)
|
|
1035
|
-
if (!x1) return false;
|
|
1036
|
-
var y1 = this.canon(y);
|
|
1037
|
-
// alert('y1='+y1); //@@
|
|
1038
|
-
if (!y1) return false;
|
|
1039
|
-
return x1.value === y1.value;
|
|
962
|
+
// remove any prefix that currently targets nsuri
|
|
963
|
+
for (let existingPrefix in this.namespaces) {
|
|
964
|
+
if (this.namespaces[existingPrefix] == nsuri) delete this.namespaces[existingPrefix];
|
|
1040
965
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
value: function setPrefixForURI(prefix, nsuri) {
|
|
1044
|
-
// TODO: This is a hack for our own issues, which ought to be fixed
|
|
1045
|
-
// post-release
|
|
1046
|
-
// See http://dig.csail.mit.edu/cgi-bin/roundup.cgi/$rdf/issue227
|
|
1047
|
-
if (prefix === 'tab' && this.namespaces['tab']) {
|
|
1048
|
-
return;
|
|
1049
|
-
} // There are files around with long badly generated prefixes like this
|
|
1050
|
-
if (prefix.slice(0, 2) === 'ns' || prefix.slice(0, 7) === 'default') {
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
966
|
+
this.namespaces[prefix] = nsuri;
|
|
967
|
+
}
|
|
1053
968
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
969
|
+
/** Search the Store
|
|
970
|
+
*
|
|
971
|
+
* ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS!
|
|
972
|
+
* @param subj - A node to search for as subject, or if null, a wildcard
|
|
973
|
+
* @param pred - A node to search for as predicate, or if null, a wildcard
|
|
974
|
+
* @param obj - A node to search for as object, or if null, a wildcard
|
|
975
|
+
* @param why - A node to search for as graph, or if null, a wildcard
|
|
976
|
+
* @param justOne - flag - stop when found one rather than get all of them?
|
|
977
|
+
* @returns An array of nodes which match the wildcard position
|
|
978
|
+
*/
|
|
979
|
+
statementsMatching(subj, pred, obj, why, justOne) {
|
|
980
|
+
// log.debug("Matching {"+subj+" "+pred+" "+obj+"}")
|
|
981
|
+
var pat = [subj, pred, obj, why];
|
|
982
|
+
var pattern = [];
|
|
983
|
+
var hash = [];
|
|
984
|
+
var wild = []; // wildcards
|
|
985
|
+
var given = []; // Not wild
|
|
986
|
+
var p;
|
|
987
|
+
var list;
|
|
988
|
+
for (p = 0; p < 4; p++) {
|
|
989
|
+
pattern[p] = this.canon(_node.default.fromValue(pat[p]));
|
|
990
|
+
if (!pattern[p]) {
|
|
991
|
+
wild.push(p);
|
|
992
|
+
} else {
|
|
993
|
+
given.push(p);
|
|
994
|
+
hash[p] = this.id(pattern[p]);
|
|
1057
995
|
}
|
|
1058
|
-
this.namespaces[prefix] = nsuri;
|
|
1059
996
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
*/
|
|
1071
|
-
}, {
|
|
1072
|
-
key: "statementsMatching",
|
|
1073
|
-
value: function statementsMatching(subj, pred, obj, why, justOne) {
|
|
1074
|
-
// log.debug("Matching {"+subj+" "+pred+" "+obj+"}")
|
|
1075
|
-
var pat = [subj, pred, obj, why];
|
|
1076
|
-
var pattern = [];
|
|
1077
|
-
var hash = [];
|
|
1078
|
-
var wild = []; // wildcards
|
|
1079
|
-
var given = []; // Not wild
|
|
1080
|
-
var p;
|
|
1081
|
-
var list;
|
|
1082
|
-
for (p = 0; p < 4; p++) {
|
|
1083
|
-
pattern[p] = this.canon(_node.default.fromValue(pat[p]));
|
|
1084
|
-
if (!pattern[p]) {
|
|
1085
|
-
wild.push(p);
|
|
1086
|
-
} else {
|
|
1087
|
-
given.push(p);
|
|
1088
|
-
hash[p] = this.id(pattern[p]);
|
|
997
|
+
if (given.length === 0) {
|
|
998
|
+
return this.statements;
|
|
999
|
+
}
|
|
1000
|
+
if (given.length === 1) {
|
|
1001
|
+
// Easy too, we have an index for that
|
|
1002
|
+
p = given[0];
|
|
1003
|
+
list = this.index[p][hash[p]];
|
|
1004
|
+
if (list && justOne) {
|
|
1005
|
+
if (list.length > 1) {
|
|
1006
|
+
list = list.slice(0, 1);
|
|
1089
1007
|
}
|
|
1090
1008
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1009
|
+
list = list || [];
|
|
1010
|
+
return list;
|
|
1011
|
+
}
|
|
1012
|
+
// Now given.length is 2, 3 or 4.
|
|
1013
|
+
// We hope that the scale-free nature of the data will mean we tend to get
|
|
1014
|
+
// a short index in there somewhere!
|
|
1015
|
+
var best = 1e10; // really bad
|
|
1016
|
+
var iBest;
|
|
1017
|
+
var i;
|
|
1018
|
+
for (i = 0; i < given.length; i++) {
|
|
1019
|
+
p = given[i]; // Which part we are dealing with
|
|
1020
|
+
list = this.index[p][hash[p]];
|
|
1021
|
+
if (!list) {
|
|
1022
|
+
return []; // No occurrences
|
|
1093
1023
|
}
|
|
1094
|
-
if (
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
list = this.index[p][hash[p]];
|
|
1098
|
-
if (list && justOne) {
|
|
1099
|
-
if (list.length > 1) {
|
|
1100
|
-
list = list.slice(0, 1);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
list = list || [];
|
|
1104
|
-
return list;
|
|
1024
|
+
if (list.length < best) {
|
|
1025
|
+
best = list.length;
|
|
1026
|
+
iBest = i; // (not p!)
|
|
1105
1027
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
|
|
1028
|
+
}
|
|
1029
|
+
// Ok, we have picked the shortest index but now we have to filter it
|
|
1030
|
+
var pBest = given[iBest];
|
|
1031
|
+
var possibles = this.index[pBest][hash[pBest]];
|
|
1032
|
+
var check = given.slice(0, iBest).concat(given.slice(iBest + 1)); // remove iBest
|
|
1033
|
+
var results = [];
|
|
1034
|
+
var parts = ['subject', 'predicate', 'object', 'why'];
|
|
1035
|
+
for (var j = 0; j < possibles.length; j++) {
|
|
1036
|
+
var st = possibles[j];
|
|
1037
|
+
for (i = 0; i < check.length; i++) {
|
|
1038
|
+
// for each position to be checked
|
|
1039
|
+
p = check[i];
|
|
1040
|
+
if (!this.canon(st[parts[p]]).equals(pattern[p])) {
|
|
1041
|
+
st = null;
|
|
1042
|
+
break;
|
|
1121
1043
|
}
|
|
1122
1044
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
var check = given.slice(0, iBest).concat(given.slice(iBest + 1)); // remove iBest
|
|
1127
|
-
var results = [];
|
|
1128
|
-
var parts = ['subject', 'predicate', 'object', 'why'];
|
|
1129
|
-
for (var j = 0; j < possibles.length; j++) {
|
|
1130
|
-
var st = possibles[j];
|
|
1131
|
-
for (i = 0; i < check.length; i++) {
|
|
1132
|
-
// for each position to be checked
|
|
1133
|
-
p = check[i];
|
|
1134
|
-
if (!this.canon(st[parts[p]]).equals(pattern[p])) {
|
|
1135
|
-
st = null;
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
if (st != null) {
|
|
1140
|
-
results.push(st);
|
|
1141
|
-
if (justOne) break;
|
|
1142
|
-
}
|
|
1045
|
+
if (st != null) {
|
|
1046
|
+
results.push(st);
|
|
1047
|
+
if (justOne) break;
|
|
1143
1048
|
}
|
|
1144
|
-
return results;
|
|
1145
1049
|
}
|
|
1050
|
+
return results;
|
|
1051
|
+
}
|
|
1146
1052
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
var
|
|
1158
|
-
|
|
1159
|
-
for (var i = 0; i < terms.length; i++) {
|
|
1160
|
-
res.push(terms[i].uri);
|
|
1161
|
-
}
|
|
1053
|
+
/**
|
|
1054
|
+
* A list of all the URIs by which this thing is known
|
|
1055
|
+
* @param term
|
|
1056
|
+
*/
|
|
1057
|
+
uris(term) {
|
|
1058
|
+
var cterm = this.canon(term);
|
|
1059
|
+
var terms = this.aliases[this.id(cterm)];
|
|
1060
|
+
if (!cterm.value) return [];
|
|
1061
|
+
var res = [cterm.value];
|
|
1062
|
+
if (terms) {
|
|
1063
|
+
for (var i = 0; i < terms.length; i++) {
|
|
1064
|
+
res.push(terms[i].uri);
|
|
1162
1065
|
}
|
|
1163
|
-
return res;
|
|
1164
1066
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
// to those of this IndexedFormula
|
|
1067
|
+
return res;
|
|
1068
|
+
}
|
|
1069
|
+
serialize(base, contentType, provenance, options) {
|
|
1070
|
+
// override Formula.serialize to force the serializer namespace prefixes
|
|
1071
|
+
// to those of this IndexedFormula
|
|
1171
1072
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1073
|
+
// if namespaces are explicitly passed in options, let them override the existing namespaces in this formula
|
|
1074
|
+
const namespaces = options?.namespaces ? {
|
|
1075
|
+
...this.namespaces,
|
|
1076
|
+
...options.namespaces
|
|
1077
|
+
} : {
|
|
1078
|
+
...this.namespaces
|
|
1079
|
+
};
|
|
1080
|
+
options = {
|
|
1081
|
+
...(options || {}),
|
|
1082
|
+
namespaces
|
|
1083
|
+
};
|
|
1084
|
+
return (0, _serialize.default)(provenance, this, base, contentType, undefined, options);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
exports.default = IndexedFormula;
|
|
1186
1088
|
(0, _defineProperty2.default)(IndexedFormula, "handleRDFType", void 0);
|
|
1187
1089
|
IndexedFormula.handleRDFType = handleRDFType;
|