Skip to content

Commit afab586

Browse files
added missing function to object frame and fixed woql.js
1 parent 4617c50 commit afab586

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

lib/objectFrame.js

Lines changed: 8 additions & 0 deletions
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
};

lib/woql.js

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ WOQL.list = 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); }
5252
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

@@ -343,15 +345,6 @@ WOQLQuery.prototype.setPage = function(pagenum){
343345
return this;
344346
}
345347

346-
347-
WOQLQuery.prototype.hasStart = function(){
348-
return (typeof this.getPagingProperty("start") != "undefined");
349-
}
350-
351-
WOQLQuery.prototype.getStart = function(){
352-
return this.getPagingProperty("start");
353-
}
354-
355348
WOQLQuery.prototype.nextPage = function(){
356349
return this.setPage(this.getPage() + 1);
357350
}
@@ -366,6 +359,18 @@ WOQLQuery.prototype.previousPage = function(){
366359
return this;
367360
}
368361

362+
WOQLQuery.prototype.setPageSize = function(size){
363+
this.setPagingProperty("limit", size);
364+
if(this.hasStart()){
365+
this.setStart(0);
366+
}
367+
else {
368+
this.addStart(0);
369+
}
370+
return this;
371+
}
372+
373+
369374
WOQLQuery.prototype.hasSelect = function(){
370375
return this.getPagingProperty("select");
371376
}
@@ -386,19 +391,17 @@ WOQLQuery.prototype.getSelectVariables = function(q){
386391
}
387392
}
388393

389-
WOQLQuery.prototype.setStart = function(start){
390-
return this.setPagingProperty("start", start);
394+
395+
WOQLQuery.prototype.hasStart = function(){
396+
return (typeof this.getPagingProperty("start") != "undefined");
391397
}
392398

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

404407
/*
@@ -772,6 +775,7 @@ WOQLQuery.prototype.elementMetadata = function(){
772775
WOQL.opt().quad("v:Element", "tcs:tag", "v:Abstract", "db:schema"),
773776
WOQL.opt().quad("v:Element", "rdfs:label", "v:Label", "db:schema"),
774777
WOQL.opt().quad("v:Element", "rdfs:comment", "v:Comment", "db:schema"),
778+
WOQL.opt().quad("v:Element", "rdfs:subClassOf", "v:Parent", "db:schema"),
775779
WOQL.opt().quad("v:Element", "rdfs:domain", "v:Domain", "db:schema"),
776780
WOQL.opt().quad("v:Element", "rdfs:range", "v:Range", "db:schema")
777781
);
@@ -866,36 +870,36 @@ WOQLQuery.prototype.cleanSubject = function(s){
866870
if(typeof s != "string") return s;
867871
if(s.indexOf(":") != -1) return s;
868872
if(this.vocab && this.vocab[s]) return this.vocab[s];
869-
return "v:" + s;
873+
return "doc:" + s;
870874
}
871875

872876
WOQLQuery.prototype.cleanPredicate = function(p){
873877
if(p.indexOf(":") != -1) return p;
874878
if(this.vocab && this.vocab[p]) return this.vocab[p];
875-
return "v:" + p;
879+
return "scm:" + p;
876880
}
877881
WOQLQuery.prototype.cleanType = function(t){
878882
if(t.indexOf(":") != -1) return t;
879883
if(this.vocab && this.vocab[t]) return this.vocab[t];
880-
return "v:" + t;
884+
return "scm:" + t;
881885
}
882886

883887
WOQLQuery.prototype.cleanObject = function(o){
884888
if(typeof o != "string" || o.indexOf(":") != -1) return o;
885889
if(this.vocab && this.vocab[o]) return this.vocab[o];
886-
return "v:" + o;
890+
return { "@value": o, "@language": "en"};
887891
}
888892

889893
WOQLQuery.prototype.cleanGraph = function(g){
890894
if(g.indexOf(":") != -1) return g;
891895
if(this.vocab && this.vocab[g]) return this.vocab[g];
892-
return "v:" + g;
896+
return "db:" + g;
893897
}
894898

895899
WOQLQuery.prototype.cleanClass = function(c){
896900
if(c.indexOf(":") != -1) return c;
897901
if(this.vocab && this.vocab[c]) return this.vocab[c];
898-
return "v:" + c;
902+
return "scm:" + c;
899903
}
900904

901905
/**
@@ -1043,7 +1047,7 @@ TripleBuilder.prototype.min = function(m){
10431047
return this.card(m, "min");
10441048
}
10451049

1046-
TripleBuilder.prototype.s = function(s){
1050+
TripleBuilder.prototype.node = function(s){
10471051
this.subject = this.query.cleanSubject(s);
10481052
return this;
10491053
}

0 commit comments

Comments
 (0)