10
10
*
11
11
*/
12
12
13
- const WOQLQuery = require ( './woqlQuery' ) ;
14
- const WOQLLibrary = require ( './woqlLibrary' ) ;
13
+ /**
14
+ * defines the internal functions of the woql query object - the
15
+ * language API is defined in WOQLQuery
16
+ * @module WOQLQuery
17
+ * @constructor
18
+ * @param {object } [query] json-ld query for initialisation
19
+ * @returns {WOQLQuery }
20
+ */
15
21
16
- WOQLQuery . prototype . counter = 1 ;
17
- /* class WOQLQuery extends WOQLQueryImp {
18
- constructor(query) {
19
- super(query)
20
- }
21
- } */
22
+ const WOQLQueryExt = require ( './woqlQuery' ) ;
23
+ // const WOQLLibrary = require('./woqlLibrary');
24
+
25
+ class WOQLQuery extends WOQLQueryExt {
26
+ // eslint-disable-next-line no-useless-constructor
27
+ constructor ( query ) {
28
+ super ( query ) ;
29
+ }
30
+ }
22
31
32
+ // WOQLQuery.prototype.counter = 1;
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
+ */
23
40
/**
24
41
* Simple composite functions which produce WOQL queries
25
42
*/
@@ -34,35 +51,77 @@ WOQLQuery.prototype.star = function (Graph, Subj, Pred, Obj) {
34
51
return this . triple ( Subj , Pred , Obj ) ;
35
52
} ;
36
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
+
37
62
WOQLQuery . prototype . all = function ( Subj , Pred , Obj , Graph ) {
38
63
return this . star ( Graph , Subj , Pred , Obj ) ;
39
64
} ;
40
65
41
- WOQLQuery . prototype . lib = function ( ) {
66
+ /* WOQLQuery.prototype.lib = function () {
42
67
return new WOQLLibrary();
43
- } ;
68
+ }; */
69
+
70
+ /**
71
+ * @param {string } s
72
+ * @returns {object }
73
+ * @example
74
+ */
44
75
45
76
WOQLQuery . prototype . string = function ( s ) {
46
77
return { '@type' : 'xsd:string' , '@value' : String ( s ) } ;
47
78
} ;
48
79
80
+ /**
81
+ * @param {boolean } tf
82
+ * @returns {object }
83
+ * @example
84
+ */
85
+
49
86
WOQLQuery . prototype . boolean = function ( tf ) {
50
87
tf = tf || false ;
51
88
return this . literal ( tf , 'boolean' ) ;
52
89
} ;
53
90
91
+ /**
92
+ * @param {any } s
93
+ * @param {string } t
94
+ * @returns {object }
95
+ * @example
96
+ */
54
97
WOQLQuery . prototype . literal = function ( s , t ) {
55
98
t = t . indexOf ( ':' ) === - 1 ? `xsd:${ t } ` : t ;
56
99
return { '@type' : t , '@value' : s } ;
57
100
} ;
58
101
102
+ /**
103
+ * @param {string } s
104
+ * @returns {object }
105
+ * @example
106
+ */
107
+
59
108
WOQLQuery . prototype . iri = function ( s ) {
60
109
return {
61
110
'@type' : 'NodeValue' ,
62
111
node : s ,
63
112
} ;
64
113
} ;
65
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
+
66
125
WOQLQuery . prototype . update_triple = function ( subject , predicate , new_object , old_object ) {
67
126
const tmp_name = old_object || `v:AnyObject__${ this . counter += 1 } ` ;
68
127
return this . and (
@@ -104,7 +163,7 @@ WOQLQuery.prototype.update_quad = function (subject, predicate, new_object, grap
104
163
105
164
/**
106
165
* Removes all triples from a graph
107
- * @param {string } g - optional graph resource identifier
166
+ * @param {string } [g] - optional graph resource identifier
108
167
*/
109
168
110
169
WOQLQuery . prototype . nuke = function ( g ) {
@@ -114,6 +173,16 @@ WOQLQuery.prototype.nuke = function (g) {
114
173
return this . triple ( 'v:A' , 'v:B' , 'v:C' ) . delete_triple ( 'v:A' , 'v:B' , 'v:C' ) ;
115
174
} ;
116
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
+
117
186
WOQLQuery . prototype . node = function ( node , type ) {
118
187
type = type || false ;
119
188
if ( type === 'add_quad' ) type = 'AddTriple' ;
@@ -151,6 +220,13 @@ WOQLQuery.prototype._set_context = function (ctxt) {
151
220
return this ;
152
221
} ;
153
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
+
154
230
WOQLQuery . prototype . insert = function ( id , type , refGraph ) {
155
231
refGraph = refGraph || ( this . triple_builder_context ? this . triple_builder_context . graph : false ) ;
156
232
if ( refGraph ) {
0 commit comments