1010 *
1111 */
1212
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+ */
1521
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+ }
2231
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+ */
2340/**
2441 * Simple composite functions which produce WOQL queries
2542 */
@@ -34,35 +51,77 @@ WOQLQuery.prototype.star = function (Graph, Subj, Pred, Obj) {
3451 return this . triple ( Subj , Pred , Obj ) ;
3552} ;
3653
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+
3762WOQLQuery . prototype . all = function ( Subj , Pred , Obj , Graph ) {
3863 return this . star ( Graph , Subj , Pred , Obj ) ;
3964} ;
4065
41- WOQLQuery . prototype . lib = function ( ) {
66+ /* WOQLQuery.prototype.lib = function () {
4267 return new WOQLLibrary();
43- } ;
68+ }; */
69+
70+ /**
71+ * @param {string } s
72+ * @returns {object }
73+ * @example
74+ */
4475
4576WOQLQuery . prototype . string = function ( s ) {
4677 return { '@type' : 'xsd:string' , '@value' : String ( s ) } ;
4778} ;
4879
80+ /**
81+ * @param {boolean } tf
82+ * @returns {object }
83+ * @example
84+ */
85+
4986WOQLQuery . prototype . boolean = function ( tf ) {
5087 tf = tf || false ;
5188 return this . literal ( tf , 'boolean' ) ;
5289} ;
5390
91+ /**
92+ * @param {any } s
93+ * @param {string } t
94+ * @returns {object }
95+ * @example
96+ */
5497WOQLQuery . prototype . literal = function ( s , t ) {
5598 t = t . indexOf ( ':' ) === - 1 ? `xsd:${ t } ` : t ;
5699 return { '@type' : t , '@value' : s } ;
57100} ;
58101
102+ /**
103+ * @param {string } s
104+ * @returns {object }
105+ * @example
106+ */
107+
59108WOQLQuery . prototype . iri = function ( s ) {
60109 return {
61110 '@type' : 'NodeValue' ,
62111 node : s ,
63112 } ;
64113} ;
65114
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+
66125WOQLQuery . prototype . update_triple = function ( subject , predicate , new_object , old_object ) {
67126 const tmp_name = old_object || `v:AnyObject__${ this . counter += 1 } ` ;
68127 return this . and (
@@ -104,7 +163,7 @@ WOQLQuery.prototype.update_quad = function (subject, predicate, new_object, grap
104163
105164/**
106165 * Removes all triples from a graph
107- * @param {string } g - optional graph resource identifier
166+ * @param {string } [g] - optional graph resource identifier
108167 */
109168
110169WOQLQuery . prototype . nuke = function ( g ) {
@@ -114,6 +173,16 @@ WOQLQuery.prototype.nuke = function (g) {
114173 return this . triple ( 'v:A' , 'v:B' , 'v:C' ) . delete_triple ( 'v:A' , 'v:B' , 'v:C' ) ;
115174} ;
116175
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+
117186WOQLQuery . prototype . node = function ( node , type ) {
118187 type = type || false ;
119188 if ( type === 'add_quad' ) type = 'AddTriple' ;
@@ -151,6 +220,13 @@ WOQLQuery.prototype._set_context = function (ctxt) {
151220 return this ;
152221} ;
153222
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+
154230WOQLQuery . prototype . insert = function ( id , type , refGraph ) {
155231 refGraph = refGraph || ( this . triple_builder_context ? this . triple_builder_context . graph : false ) ;
156232 if ( refGraph ) {
0 commit comments