Skip to content

Commit 66131de

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents ea1b3d3 + c85055e commit 66131de

File tree

5 files changed

+57
-39
lines changed

5 files changed

+57
-39
lines changed

dist/terminus-client.min.js

Lines changed: 3 additions & 3 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 & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/frameHelper.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ FrameHelper.removeChildren = function (node) {
3030
}
3131
};
3232

33+
FrameHelper.removeElement = function (node) {
34+
if (node) {
35+
node.parentNode.removeChild(node);
36+
}
37+
}
38+
3339
FrameHelper.empty = function (obj) {
3440
// null and undefined are "empty"
3541
if (!obj) return true;

lib/objectFrame.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ ObjectFrame.prototype.getAsFrame = function (prop, parent) {
114114
return ff;
115115
};
116116

117+
ObjectFrame.prototype.getAsFrames = function (prop, parent) {
118+
var frames = [];
119+
for (const prop of Object.keys(this.properties)) {
120+
frames = frames.concat(frames, this.properties[prop].getAsFrames());
121+
}
122+
return frames;
123+
}
124+
117125
ObjectFrame.prototype.isnew = function () {
118126
return this.newDoc;
119127
};
@@ -588,12 +596,12 @@ PropertyFrame.prototype.get = function(){
588596
return gets;
589597
}
590598

591-
592599
PropertyFrame.prototype.clear = function(){
593600
for(var i = 0 ; i<this.values.length; i++){
594601
this.values[i].clear();
595602
}
596603
}
604+
597605
PropertyFrame.prototype.clone = function(){
598606
const cvalues = [];
599607
const cloned = new PropertyFrame(this.predicate, this.cframe, this.parent);

lib/woql.js

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ WOQL.and = function(...queries){ return new WOQLQuery().and(...queries); }
2323
WOQL.not = function(query){ return new WOQLQuery().not(query); }
2424
WOQL.triple = function(a, b, c){ return new WOQLQuery().triple(a, b, c); }
2525
WOQL.quad = function(a, b, c, d){ return new WOQLQuery().quad(a, b, c, d); }
26-
WOQL.eq = function(a, b){ return new WOQLQuery().eq(a, b);}
2726
WOQL.sub = function(a, b){ return new WOQLQuery().sub(a, b); }
2827
WOQL.isa = function(a, b){ return new WOQLQuery().isa(a, b); }
28+
WOQL.eq = function(a, b){ return new WOQLQuery().eq(a, b);}
2929
WOQL.trim = function(a, b){ return new WOQLQuery().trim(a, b); }
3030
WOQL.delete = function(JSON_or_IRI){ return new WOQLQuery().delete(JSON_or_IRI); }
3131
WOQL.delete_triple = function( S, P, O ){ return new WOQLQuery().delete_triple (S, P, O); }
32-
WOQL.add_triple = function( S, P, O ){ return new WOQLQuery().add_triple (S, P, O); }
3332
WOQL.delete_quad = function( S, P, O, G ){ return new WOQLQuery().delete_quad (S, P, O, G); }
33+
WOQL.add_triple = function( S, P, O ){ return new WOQLQuery().add_triple (S, P, O); }
3434
WOQL.add_quad = function( S, P, O, G ){ return new WOQLQuery().add_quad (S, P, O, G);}
3535
WOQL.eval = function(arith, v){ return new WOQLQuery().eval(arith, v);}
3636
WOQL.plus = function(...args){ return new WOQLQuery().plus(...args);}
@@ -49,11 +49,12 @@ WOQL.list = function(vars){ return new WOQLQuery().list(vars); }
4949
//WOQL.value = function(vars){ return new WOQLQuery().list(vars); }
5050
//These ones are special ones for dealing with the schema only...
5151
WOQL.addClass = function(classid, graph){ return new WOQLQuery().addClass(classid, graph); }
52-
WOQL.addProperty = function(propid, graph){ return new WOQLQuery().addProperty(propid, graph); }
52+
WOQL.addProperty = function(propid, type, graph){ return new WOQLQuery().addProperty(propid, type, graph); }
53+
WOQL.deleteClass = function(classid, graph){ return new WOQLQuery().deleteClass(classid, graph); }
54+
WOQL.deleteProperty = function(propid, type, graph){ return new WOQLQuery().deleteProperty(propid, type, graph); }
5355
WOQL.node = function(nodeid, type){ return new WOQLQuery().node(nodeid, type); }
5456

5557

56-
5758
/*
5859
* Beneath here are pseudo predicates - they belong to the javascript object
5960
* but not to the WOQL language
@@ -62,8 +63,6 @@ WOQL.node = function(nodeid, type){ return new WOQLQuery().node(nodeid, type); }
6263
WOQL.query = function(){ return new WOQLQuery(); }
6364
//loads query from json
6465
WOQL.json = function(json){ return new WOQLQuery().json(json); }
65-
//returns a special schema object for terse schema updates
66-
WOQL.schema = function(){ return new WOQLSchema(); }
6766

6867
WOQL.rule = function(){ return new Pattern.FrameRule(); }
6968
//Simple utility function for typechecking
@@ -238,7 +237,6 @@ WOQLQuery.prototype.nspaces = function(n){
238237
return spaces;
239238
}
240239

241-
242240
WOQLQuery.prototype.prettyPrint = function(indent, show_context, q, embed){
243241
if(!embed) this.indent = indent;
244242
q = (q ? q : this.query);
@@ -346,15 +344,6 @@ WOQLQuery.prototype.setPage = function(pagenum){
346344
return this;
347345
}
348346

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-
358347
WOQLQuery.prototype.nextPage = function(){
359348
return this.setPage(this.getPage() + 1);
360349
}
@@ -369,6 +358,17 @@ WOQLQuery.prototype.previousPage = function(){
369358
return this;
370359
}
371360

361+
WOQLQuery.prototype.setPageSize = function(size){
362+
this.setPagingProperty("limit", size);
363+
if(this.hasStart()){
364+
this.setStart(0);
365+
}
366+
else {
367+
this.addStart(0);
368+
}
369+
return this;
370+
}
371+
372372
WOQLQuery.prototype.hasSelect = function(){
373373
return this.getPagingProperty("select");
374374
}
@@ -389,19 +389,16 @@ WOQLQuery.prototype.getSelectVariables = function(q){
389389
}
390390
}
391391

392-
WOQLQuery.prototype.setStart = function(start){
393-
return this.setPagingProperty("start", start);
392+
WOQLQuery.prototype.hasStart = function(){
393+
return (typeof this.getPagingProperty("start") != "undefined");
394394
}
395395

396-
WOQLQuery.prototype.setPageSize = function(size){
397-
this.setPagingProperty("limit", size);
398-
if(this.hasStart()){
399-
this.setStart(0);
400-
}
401-
else {
402-
this.addStart(0);
403-
}
404-
return this;
396+
WOQLQuery.prototype.getStart = function(){
397+
return this.getPagingProperty("start");
398+
}
399+
400+
WOQLQuery.prototype.setStart = function(start){
401+
return this.setPagingProperty("start", start);
405402
}
406403

407404
/*
@@ -477,6 +474,7 @@ WOQLQuery.prototype.when = function(Query, Update){
477474

478475
WOQLQuery.prototype.opt = function(query){
479476
if(query){
477+
q = (query.json ? query.json() : q);
480478
this.cursor["opt"] = [query];
481479
}
482480
else {
@@ -774,6 +772,7 @@ WOQLQuery.prototype.elementMetadata = function(){
774772
WOQL.opt().quad("v:Element", "tcs:tag", "v:Abstract", "db:schema"),
775773
WOQL.opt().quad("v:Element", "rdfs:label", "v:Label", "db:schema"),
776774
WOQL.opt().quad("v:Element", "rdfs:comment", "v:Comment", "db:schema"),
775+
WOQL.opt().quad("v:Element", "rdfs:subClassOf", "v:Parent", "db:schema"),
777776
WOQL.opt().quad("v:Element", "rdfs:domain", "v:Domain", "db:schema"),
778777
WOQL.opt().quad("v:Element", "rdfs:range", "v:Range", "db:schema")
779778
);
@@ -868,36 +867,36 @@ WOQLQuery.prototype.cleanSubject = function(s){
868867
if(typeof s != "string") return s;
869868
if(s.indexOf(":") != -1) return s;
870869
if(this.vocab && this.vocab[s]) return this.vocab[s];
871-
return "v:" + s;
870+
return "doc:" + s;
872871
}
873872

874873
WOQLQuery.prototype.cleanPredicate = function(p){
875874
if(p.indexOf(":") != -1) return p;
876875
if(this.vocab && this.vocab[p]) return this.vocab[p];
877-
return "v:" + p;
876+
return "scm:" + p;
878877
}
879878
WOQLQuery.prototype.cleanType = function(t){
880879
if(t.indexOf(":") != -1) return t;
881880
if(this.vocab && this.vocab[t]) return this.vocab[t];
882-
return "v:" + t;
881+
return "scm:" + t;
883882
}
884883

885884
WOQLQuery.prototype.cleanObject = function(o){
886885
if(typeof o != "string" || o.indexOf(":") != -1) return o;
887886
if(this.vocab && this.vocab[o]) return this.vocab[o];
888-
return "v:" + o;
887+
return { "@value": o, "@language": "en"};
889888
}
890889

891890
WOQLQuery.prototype.cleanGraph = function(g){
892891
if(g.indexOf(":") != -1) return g;
893892
if(this.vocab && this.vocab[g]) return this.vocab[g];
894-
return "v:" + g;
893+
return "db:" + g;
895894
}
896895

897896
WOQLQuery.prototype.cleanClass = function(c){
898897
if(c.indexOf(":") != -1) return c;
899898
if(this.vocab && this.vocab[c]) return this.vocab[c];
900-
return "v:" + c;
899+
return "scm:" + c;
901900
}
902901

903902
/**
@@ -1036,11 +1035,16 @@ TripleBuilder.prototype.max = function(m){
10361035
return this.card(m, "max");
10371036
}
10381037

1038+
TripleBuilder.prototype.cardinality = function(m){
1039+
return this.card(m, "cardinality");
1040+
}
1041+
1042+
10391043
TripleBuilder.prototype.min = function(m){
10401044
return this.card(m, "min");
10411045
}
10421046

1043-
TripleBuilder.prototype.s = function(s){
1047+
TripleBuilder.prototype.node = function(s){
10441048
this.subject = this.query.cleanSubject(s);
10451049
return this;
10461050
}

0 commit comments

Comments
 (0)