Skip to content

Commit c11dd0f

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents 25d0551 + d56a385 commit c11dd0f

File tree

8 files changed

+396
-121
lines changed

8 files changed

+396
-121
lines changed

dist/terminus-client.min.js

Lines changed: 3 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/terminus-client.min.js.map

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/objectFrame.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,13 @@ PropertyFrame.prototype.first = function () {
661661
}
662662
};
663663

664-
<<<<<<< HEAD
665-
PropertyFrame.prototype.renderValues = function () {
666-
const sortedVals = this.sortValues();
667-
const vals = [];
668-
for (let i = 0; i < sortedVals.length; i++) {
669-
if (sortedVals[i].render) {
670-
const rend = sortedVals[i].render(sortedVals[i]);
671-
if (rend) vals.push(rend);
672-
=======
673664
PropertyFrame.prototype.renderValues = function(){
674665
var sortedVals = this.sortValues();
675666
var vals = [];
676667
for(var i = 0; i<sortedVals.length; i++){
677668
if(sortedVals[i] && sortedVals[i].render){
678669
var rend = sortedVals[i].render(sortedVals[i]);
679670
if(rend) vals.push(rend);
680-
>>>>>>> 4617c50289151c0411b50a5c0cdda19ceeb4e6b8
681671
}
682672
}
683673
return vals;

lib/woql.js

Lines changed: 41 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ WOQLQuery.prototype.loadDefaultVocabulary = function(){
9494
vocab.type = "rdf:type";
9595
vocab.label = "rdfs:label";
9696
vocab.Class = "owl:Class";
97+
vocab.DatatypeProperty = "owl:DatatypeProperty";
98+
vocab.ObjectProperty = "owl:ObjectProperty";
99+
vocab.Entity = "tcs:Entity";
100+
vocab.Document = "tcs:Document";
101+
vocab.Relationship = "tcs:Relationship";
102+
vocab.temporality = "tcs:temporality";
103+
vocab.geotemporality = "tcs:geotemporality";
104+
vocab.geography = "tcs:geography";
105+
vocab.abstract = "tcs:abstract";
97106
vocab.comment = "rdfs:comment";
98107
vocab.range = "rdfs:range";
99108
vocab.domain = "rdfs:domain";
@@ -275,15 +284,15 @@ WOQLQuery.prototype.prettyPrint = function(indent, show_context, q, embed){
275284
str += "(\n" + this.nspaces(indent) + "WOQL." + clauses.join(",\n"+ this.nspaces(indent) + "WOQL.") + "\n" + this.nspaces(indent - this.indent) + ")";
276285

277286
}
278-
else if(typeof val[val.length-1] == "object" ){
287+
else if(typeof val[val.length-1] == "object" && typeof val[val.length-1]['@value'] == "undefined"){
279288
var nvals = []
280289
for(var i = 0; i<val.length-1; i++){
281290
if(key == "limit" || key == "start"){
282291
nvals.push(val[i]);
283292
}
284293
else {
285294
if(typeof val[i] == "string"){
286-
nvals.push('"' + self.unclean(val[i]) + '"');
295+
nvals.push(self.unclean(val[i]));
287296
}
288297
else if(typeof val[i] == "object"){
289298
nvals.push(JSON.stringify(val[i]));
@@ -295,8 +304,8 @@ WOQLQuery.prototype.prettyPrint = function(indent, show_context, q, embed){
295304
}
296305
if(nvals.length){
297306
str += unclean(nvals);
298-
if(key == "from") str += ")\n .";
299-
else str +=").";
307+
if(key == "from") str += "\n .";
308+
else str +=".";
300309
}
301310
if (nvals.length) {
302311
str += `(${nvals.join(',')}`;
@@ -345,20 +354,7 @@ WOQLQuery.prototype.setPage = function (pagenum) {
345354
return this;
346355
};
347356

348-
<<<<<<< HEAD
349-
350-
WOQLQuery.prototype.hasStart = function () {
351-
return (typeof this.getPagingProperty('start') !== 'undefined');
352-
};
353-
354-
WOQLQuery.prototype.getStart = function () {
355-
return this.getPagingProperty('start');
356-
};
357-
358-
WOQLQuery.prototype.nextPage = function () {
359-
=======
360357
WOQLQuery.prototype.nextPage = function(){
361-
>>>>>>> c85055e6384aa4c834e1a014093ad63850781f8f
362358
return this.setPage(this.getPage() + 1);
363359
};
364360

@@ -372,13 +368,8 @@ WOQLQuery.prototype.previousPage = function () {
372368
return this;
373369
};
374370

375-
<<<<<<< HEAD
376-
WOQLQuery.prototype.hasSelect = function () {
377-
return this.getPagingProperty('select');
378-
};
379-
=======
380371
WOQLQuery.prototype.setPageSize = function(size){
381-
this.setPagingProperty("limit", size);
372+
this.setPagingProperty("limit", size);
382373
if(this.hasStart()){
383374
this.setStart(0);
384375
}
@@ -389,9 +380,8 @@ WOQLQuery.prototype.setPageSize = function(size){
389380
}
390381

391382
WOQLQuery.prototype.hasSelect = function(){
392-
return this.getPagingProperty("select");
383+
return this.getPagingProperty("select");
393384
}
394-
>>>>>>> c85055e6384aa4c834e1a014093ad63850781f8f
395385

396386
WOQLQuery.prototype.getSelectVariables = function (q) {
397387
q = (q || this.query);
@@ -409,21 +399,6 @@ WOQLQuery.prototype.getSelectVariables = function (q) {
409399
}
410400
};
411401

412-
<<<<<<< HEAD
413-
WOQLQuery.prototype.setStart = function(start){
414-
return this.setPagingProperty("start", start);
415-
}
416-
417-
WOQLQuery.prototype.setPageSize = function (size) {
418-
this.setPagingProperty('limit', size);
419-
if (this.hasStart()) {
420-
this.setStart(0);
421-
} else {
422-
this.addStart(0);
423-
}
424-
return this;
425-
};
426-
=======
427402
WOQLQuery.prototype.hasStart = function(){
428403
return (typeof this.getPagingProperty("start") != "undefined");
429404
}
@@ -433,9 +408,8 @@ WOQLQuery.prototype.getStart = function(){
433408
}
434409

435410
WOQLQuery.prototype.setStart = function(start){
436-
return this.setPagingProperty("start", start);
411+
return this.setPagingProperty("start", start);
437412
}
438-
>>>>>>> c85055e6384aa4c834e1a014093ad63850781f8f
439413

440414
/*
441415
* Called to indicate an update that is the last chainable element in a query
@@ -508,8 +482,8 @@ WOQLQuery.prototype.when = function (Query, Update) {
508482

509483
WOQLQuery.prototype.opt = function(query){
510484
if(query){
511-
q = (query.json ? query.json() : q);
512-
this.cursor["opt"] = [query];
485+
var q = ((typeof query.json == "function") ? query.json() : query);
486+
this.cursor["opt"] = [q];
513487
}
514488
else {
515489
this.cursor['opt'] = [{}];
@@ -690,8 +664,9 @@ WOQLQuery.prototype.addClass = function(c, graph){
690664
}
691665

692666
WOQLQuery.prototype.addProperty = function(p, t, g){
693-
if(p && t){
694-
graph = (g ? this.cleanGraph(g) : "db:schema");
667+
t = (t ? t : "xsd:string");
668+
if(p){
669+
var graph = (g ? this.cleanGraph(g) : "db:schema");
695670
p = (p.indexOf(":") == -1) ? "scm:" + p : p;
696671
t = (t.indexOf(":") == -1) ? this.cleanType(t) : t ;
697672
var tc = this.cursor;
@@ -799,22 +774,13 @@ WOQLQuery.prototype.propertyMetadata = function(){
799774

800775
WOQLQuery.prototype.elementMetadata = function () {
801776
return this.and(
802-
<<<<<<< HEAD
803-
WOQL.quad('v:Element', 'rdf:type', 'v:Type', 'db:schema'),
804-
WOQL.opt().quad('v:Element', 'tcs:tag', 'v:Abstract', 'db:schema'),
805-
WOQL.opt().quad('v:Element', 'rdfs:label', 'v:Label', 'db:schema'),
806-
WOQL.opt().quad('v:Element', 'rdfs:comment', 'v:Comment', 'db:schema'),
807-
WOQL.opt().quad('v:Element', 'rdfs:domain', 'v:Domain', 'db:schema'),
808-
WOQL.opt().quad('v:Element', 'rdfs:range', 'v:Range', 'db:schema')
809-
=======
810777
WOQL.quad("v:Element", "rdf:type", "v:Type", "db:schema"),
811778
WOQL.opt().quad("v:Element", "tcs:tag", "v:Abstract", "db:schema"),
812779
WOQL.opt().quad("v:Element", "rdfs:label", "v:Label", "db:schema"),
813780
WOQL.opt().quad("v:Element", "rdfs:comment", "v:Comment", "db:schema"),
814781
WOQL.opt().quad("v:Element", "rdfs:subClassOf", "v:Parent", "db:schema"),
815782
WOQL.opt().quad("v:Element", "rdfs:domain", "v:Domain", "db:schema"),
816783
WOQL.opt().quad("v:Element", "rdfs:range", "v:Range", "db:schema")
817-
>>>>>>> c85055e6384aa4c834e1a014093ad63850781f8f
818784
);
819785
};
820786

@@ -948,12 +914,15 @@ function TripleBuilder(type, cursor, s, query){
948914
this.type = type;
949915
this.cursor = cursor;
950916
this.subject = query.cleanSubject(s);
951-
this.graph = false;
917+
this.g = false;
952918
this.query = query;//the containing query
953919
}
954920

955921
TripleBuilder.prototype.graph = function(g){
956-
this.graph = g;
922+
this.g = this.query.cleanGraph(g);
923+
if(this.type == "triple") this.type = "quad";
924+
if(this.type == "add_triple") this.type = "add_quad";
925+
if(this.type == "delete_triple") this.type = "delete_quad";
957926
return this;
958927
};
959928

@@ -972,8 +941,8 @@ TripleBuilder.prototype.addPO = function(p, o, g){
972941
else {
973942
evstr += o;
974943
}
975-
if(ttype.substring(ttype.length-4) == "quad"){
976-
var g = (g ? g : (this.graph ? this.graph : "db:schema"));
944+
if(ttype.substring(ttype.length-4) == "quad" || this.g){
945+
var g = (g ? g : (this.g ? this.g : "db:schema"));
977946
evstr += ", '" + g + "'";
978947
}
979948
evstr += ")";
@@ -1013,13 +982,19 @@ TripleBuilder.prototype.isa = function(s){
1013982
return this.addEntry(unit);
1014983
}
1015984

985+
TripleBuilder.prototype.domain = function(d){
986+
d = this.query.cleanClass(d);
987+
var x = this.addPO('rdfs:domain',d);
988+
return x;
989+
}
990+
991+
1016992
TripleBuilder.prototype.sub = function(s){
1017993
s = this.query.cleanClass(s);
1018994
var unit = new WOQLQuery.sub(this.subject, s);
1019995
return this.addEntry(unit);
1020996
}
1021997

1022-
1023998
TripleBuilder.prototype.label = function(l, lang){
1024999
lang = (lang ? lang : "en");
10251000
var x = this.addPO('rdfs:label', {"@value": l, "@language": lang});
@@ -1031,9 +1006,14 @@ TripleBuilder.prototype.comment = function(c, lang){
10311006
return this.addPO('rdfs:comment', {"@value": c, "@language": lang});
10321007
}
10331008

1009+
TripleBuilder.prototype.property = function(p,val){
1010+
p = this.query.cleanPredicate(p);
1011+
return this.addPO(p, val);
1012+
}
1013+
10341014
TripleBuilder.prototype.parent = function(...p){
10351015
for(var i = 0 ; i<p.length; i++){
1036-
pn = this.query.cleanClass(p[i]);
1016+
var pn = this.query.cleanClass(p[i]);
10371017
this.addPO('rdfs:subClassOf', pn);
10381018
}
10391019
return this;

lib/woqlResult.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ const FrameHelper = require('./frameHelper');
22

33
function WOQLResult(results, query, config) {
44
this.bindings = results.bindings;
5-
this.query = query;
5+
if(query.constructor.name == "WOQLQuery"){
6+
this.query = query;
7+
}
8+
else {
9+
this.query = query.query;
10+
}
611
this.cursor = 0;
712
if (!(config && config.no_compress)) {
813
const context = (config && config.context ? config.context : false);
@@ -23,17 +28,18 @@ WOQLResult.prototype.compress = function (context) {
2328
this.bindings[i][nprop] = nval;
2429
}
2530
}
26-
};
31+
return this;
32+
}
2733

2834
WOQLResult.prototype.first = function () {
2935
this.cursor = 0;
3036
return this.bindings[0];
3137
};
3238

33-
WOQLResult.prototype.last = function () {
34-
this.curor = this.bindings.length - 1;
35-
return this.bindings[this.bindings.length - 1];
36-
};
39+
WOQLResult.prototype.last = function(){
40+
this.cursor = this.bindings.length-1;
41+
return this.bindings[this.bindings.length-1];
42+
}
3743

3844
WOQLResult.prototype.next = function () {
3945
const res = this.bindings[this.cursor];
@@ -62,10 +68,12 @@ WOQLResult.prototype.compareValues = function(a, b, asc_or_desc){
6268
}
6369
};
6470

65-
66-
WOQLResult.prototype.sort = function (key, asc_or_desc) {
67-
this.bindings.sort((a, b) => this.compareValues(a[key], b[key], asc_or_desc));
68-
};
71+
WOQLResult.prototype.sort = function(key, asc_or_desc){
72+
this.bindings.sort((a, b) => {
73+
return this.compareValues(a[key], b[key], asc_or_desc);
74+
});
75+
this;
76+
}
6977

7078
WOQLResult.prototype.getVariableList = function () {
7179
if (this.bindings && this.bindings[0]) {

package-lock.json

Lines changed: 14 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"babel-loader": "^8.0.6",
2222
"chai": "^4.2.0",
2323
"chai-json-equal": "0.0.1",
24-
"coveralls": "^3.0.6",
24+
"coveralls": "^3.0.9",
2525
"cross-env": "^5.2.1",
2626
"eslint": "^5.16.0",
2727
"eslint-config-airbnb": "^17.1.1",

0 commit comments

Comments
 (0)