@@ -23,16 +23,20 @@ const WOQLQueryExt = require('./woqlQuery');
23
23
// const WOQLLibrary = require('./woqlLibrary');
24
24
25
25
class WOQLQuery extends WOQLQueryExt {
26
- counter = 1 ;
27
-
28
26
// eslint-disable-next-line no-useless-constructor
29
27
constructor ( query ) {
30
28
super ( query ) ;
31
29
}
32
30
}
33
31
34
32
// WOQLQuery.prototype.counter = 1;
35
-
33
+ /**
34
+ * @param {typedef.GraphRef } [Graph] - the resource identifier of a graph possible
35
+ * @param {string|Var } [Subj] - The IRI of a triple’s subject or a variable
36
+ * @param {string|Var } [Pred] - The IRI of a property or a variable
37
+ * @param {string|Var } [Obj] - The IRI of a node or a variable, or a literal
38
+ * @returns {WOQLQuery } - A WOQLQuery which contains the pattern matching expression
39
+ */
36
40
/**
37
41
* Simple composite functions which produce WOQL queries
38
42
*/
@@ -47,6 +51,14 @@ WOQLQuery.prototype.star = function (Graph, Subj, Pred, Obj) {
47
51
return this . triple ( Subj , Pred , Obj ) ;
48
52
} ;
49
53
54
+ /**
55
+ * @param {string|Var } [Subj] - The IRI of a triple’s subject or a variable
56
+ * @param {string|Var } [Pred] - The IRI of a property or a variable
57
+ * @param {string|Var } [Obj] - The IRI of a node or a variable, or a literal
58
+ * @param {typedef.GraphRef } [Graph] - the resource identifier of a graph possible
59
+ * @returns {WOQLQuery } - A WOQLQuery which contains the pattern matching expression
60
+ */
61
+
50
62
WOQLQuery . prototype . all = function ( Subj , Pred , Obj , Graph ) {
51
63
return this . star ( Graph , Subj , Pred , Obj ) ;
52
64
} ;
@@ -55,27 +67,61 @@ WOQLQuery.prototype.all = function (Subj, Pred, Obj, Graph) {
55
67
return new WOQLLibrary();
56
68
}; */
57
69
70
+ /**
71
+ * @param {string } s
72
+ * @returns {object }
73
+ * @example
74
+ */
75
+
58
76
WOQLQuery . prototype . string = function ( s ) {
59
77
return { '@type' : 'xsd:string' , '@value' : String ( s ) } ;
60
78
} ;
61
79
80
+ /**
81
+ * @param {boolean } tf
82
+ * @returns {object }
83
+ * @example
84
+ */
85
+
62
86
WOQLQuery . prototype . boolean = function ( tf ) {
63
87
tf = tf || false ;
64
88
return this . literal ( tf , 'boolean' ) ;
65
89
} ;
66
90
91
+ /**
92
+ * @param {any } s
93
+ * @param {string } t
94
+ * @returns {object }
95
+ * @example
96
+ */
67
97
WOQLQuery . prototype . literal = function ( s , t ) {
68
98
t = t . indexOf ( ':' ) === - 1 ? `xsd:${ t } ` : t ;
69
99
return { '@type' : t , '@value' : s } ;
70
100
} ;
71
101
102
+ /**
103
+ * @param {string } s
104
+ * @returns {object }
105
+ * @example
106
+ */
107
+
72
108
WOQLQuery . prototype . iri = function ( s ) {
73
109
return {
74
110
'@type' : 'NodeValue' ,
75
111
node : s ,
76
112
} ;
77
113
} ;
78
114
115
+ /**
116
+ * Update a pattern matching rule for the triple (Subject, Predicate, oldObjValue) with the
117
+ * new one (Subject, Predicate, newObjValue)
118
+ * @param {string|Var } subject - The IRI of a triple’s subject or a variable
119
+ * @param {string|Var } predicate - The IRI of a property or a variable
120
+ * @param {string|Var } newObjValue - The value to update or a literal
121
+ * @param {string|Var } oldObjValue - The old value of the object
122
+ * @returns {WOQLQuery } A WOQLQuery which contains the a Update Triple Statement
123
+ */
124
+
79
125
WOQLQuery . prototype . update_triple = function ( subject , predicate , new_object , old_object ) {
80
126
const tmp_name = old_object || `v:AnyObject__${ this . counter += 1 } ` ;
81
127
return this . and (
@@ -117,7 +163,7 @@ WOQLQuery.prototype.update_quad = function (subject, predicate, new_object, grap
117
163
118
164
/**
119
165
* Removes all triples from a graph
120
- * @param {string } g - optional graph resource identifier
166
+ * @param {string } [g] - optional graph resource identifier
121
167
*/
122
168
123
169
WOQLQuery . prototype . nuke = function ( g ) {
@@ -127,6 +173,16 @@ WOQLQuery.prototype.nuke = function (g) {
127
173
return this . triple ( 'v:A' , 'v:B' , 'v:C' ) . delete_triple ( 'v:A' , 'v:B' , 'v:C' ) ;
128
174
} ;
129
175
176
+ /**
177
+ *
178
+ * @param {string|Var } node - The IRI of a node or a variable containing an IRI which will
179
+ * be the subject of the builder functions
180
+ * @param {typedef.FuntionType } [type] - Optional type of builder function to build
181
+ * (default is triple)
182
+ * @returns {WOQLQuery } - A WOQLQuery which contains the partial Node pattern matching expression
183
+ * @example
184
+ */
185
+
130
186
WOQLQuery . prototype . node = function ( node , type ) {
131
187
type = type || false ;
132
188
if ( type === 'add_quad' ) type = 'AddTriple' ;
@@ -164,6 +220,13 @@ WOQLQuery.prototype._set_context = function (ctxt) {
164
220
return this ;
165
221
} ;
166
222
223
+ /**
224
+ * @param {string|Var } id - IRI string or variable containing
225
+ * @param {string|Var } type - IRI string or variable containing the IRI of the
226
+ * @param {typedef.GraphRef } [refGraph] - Optional Graph resource identifier
227
+ * @returns {WOQLQuery } A WOQLQuery which contains the insert expression
228
+ */
229
+
167
230
WOQLQuery . prototype . insert = function ( id , type , refGraph ) {
168
231
refGraph = refGraph || ( this . triple_builder_context ? this . triple_builder_context . graph : false ) ;
169
232
if ( refGraph ) {
0 commit comments