@@ -41,7 +41,6 @@ WOQLQuery.prototype._sg = function(g) {
41
41
WOQLQuery . prototype . add_class = function ( c , graph ) {
42
42
graph = this . _sg ( graph )
43
43
if ( c ) {
44
- c = this . cleanClass ( c , true )
45
44
this . add_quad ( c , 'rdf:type' , 'sys:Class' , graph )
46
45
this . _set_adding_class ( c )
47
46
}
@@ -57,7 +56,7 @@ WOQLQuery.prototype.add_class = function(c, graph) {
57
56
WOQLQuery . prototype . insert_class_data = function ( data , graph ) {
58
57
graph = this . _sg ( graph )
59
58
if ( data . id ) {
60
- const classId = this . cleanClass ( data . id , true )
59
+ const classId = data . id
61
60
this . add_class ( classId , graph )
62
61
if ( data . label ) {
63
62
this . label ( data . label )
@@ -100,7 +99,7 @@ WOQLQuery.prototype.insert_doctype_data = function(data, refGraph) {
100
99
*/
101
100
WOQLQuery . prototype . add_property = function ( p , t , graph ) {
102
101
graph = this . _sg ( graph )
103
- t = t ? this . cleanType ( t , true ) : 'xsd:string'
102
+ t = t ? t : 'xsd:string'
104
103
graph = graph || this . graph
105
104
if ( p ) {
106
105
p = this . cleanPathPredicate ( p )
@@ -131,7 +130,7 @@ WOQLQuery.prototype.insert_property_data = function(data, graph) {
131
130
graph = this . _sg ( graph )
132
131
if ( data . id ) {
133
132
p = this . cleanPathPredicate ( data . id )
134
- t = data . range ? this . cleanType ( data . range , true ) : 'xsd:string'
133
+ t = data . range ? data . range : 'xsd:string'
135
134
this . add_property ( p , t , graph )
136
135
if ( data . label ) {
137
136
this . label ( data . label )
@@ -160,7 +159,6 @@ WOQLQuery.prototype.insert_property_data = function(data, graph) {
160
159
* @returns WOQLQuery object
161
160
*/
162
161
WOQLQuery . prototype . delete_class = function ( c , graph , cvar = 'v:Class' ) {
163
- c = this . cleanClass ( c , true )
164
162
return this . and ( new WOQLQuery ( ) . eq ( c , cvar ) , new WOQLQuery ( ) . _nuke_schema_element ( cvar , graph ) )
165
163
}
166
164
@@ -174,7 +172,6 @@ WOQLQuery.prototype.delete_class = function(c, graph, cvar = 'v:Class') {
174
172
*/
175
173
WOQLQuery . prototype . delete_property = function ( p , graph , propvar ) {
176
174
propvar = propvar || 'v:Property'
177
- p = this . cleanClass ( p , true )
178
175
return this . and (
179
176
new WOQLQuery ( ) . eq ( p , propvar ) ,
180
177
new WOQLQuery ( ) . _nuke_schema_element ( propvar , graph ) ,
@@ -256,130 +253,6 @@ WOQLQuery.prototype.makeEnum = function(client, prop, cls, clslabel, clsdesc, gr
256
253
return new WOQLQuery ( ) . quad ( 'v:Choice' , 'type' , cls , graph )
257
254
}
258
255
259
- //makeEnum(client(), "", "scm:DealType", "Deal Type", "The stage of the deal")
260
-
261
- /**
262
- * Generates a class representing a choice list - an enumerated list of specific options
263
- * @param {string } cls - the id of the choice list class
264
- * @param {string } clslabel - the name of the class
265
- * @param {string } [clsdesc] - description of the class
266
- * @param {Array } choices - an array of choices, with each entry being an array ["choiceid", "choice label", "choice description"]
267
- * @param {string } graph - the id of the graph that the choice list will be written to
268
- * @param {string } parent - the id of a class that this class inherits from (e.g. scm:Enumerated)
269
- */
270
- WOQLQuery . prototype . generateChoiceList = function ( cls , clslabel , clsdesc , choices , graph , parent ) {
271
- graph = this . _sg ( graph )
272
- var clist = [ ]
273
- var listid = '_:' + ( cls . indexOf ( ':' ) == - 1 ? cls : cls . split ( ':' ) [ 1 ] )
274
- const className = this . cleanClass ( cls , true )
275
- var lastid = listid
276
- let wq = new WOQLQuery ( ) . add_class ( className , graph ) . label ( clslabel )
277
- if ( clsdesc ) wq . description ( clsdesc )
278
- if ( parent ) wq . parent ( parent )
279
- var confs = [ wq ]
280
- for ( var i = 0 ; i < choices . length ; i ++ ) {
281
- if ( ! choices [ i ] ) continue
282
- if ( Array . isArray ( choices [ i ] ) ) {
283
- var chid = choices [ i ] [ 0 ]
284
- var clab = choices [ i ] [ 1 ]
285
- var desc = choices [ i ] [ 2 ] || false
286
- } else {
287
- var chid = choices [ i ]
288
- var clab = UTILS . labelFromURL ( chid )
289
- var desc = false
290
- }
291
- let cq = new WOQLQuery ( ) . insert ( chid , className , graph ) . label ( clab )
292
- if ( desc ) cq . description ( desc )
293
- confs . push ( cq )
294
- var nextid = i < choices . length - 1 ? listid + '_' + i : 'rdf:nil'
295
- clist . push ( new WOQLQuery ( ) . add_quad ( lastid , 'rdf:first' , new WOQLQuery ( ) . iri ( chid ) , graph ) )
296
- clist . push ( new WOQLQuery ( ) . add_quad ( lastid , 'rdf:rest' , new WOQLQuery ( ) . iri ( nextid ) , graph ) )
297
- lastid = nextid
298
- }
299
- //do the owl oneof
300
- let oneof = new WOQLQuery ( ) . and (
301
- new WOQLQuery ( ) . add_quad ( className , 'owl:oneOf' , new WOQLQuery ( ) . iri ( listid ) , graph ) ,
302
- ...clist ,
303
- )
304
- return this . and ( ...confs , oneof )
305
- }
306
-
307
- WOQLQuery . prototype . _oneOfList = function ( cls , ids , graph ) {
308
- var listid = '_:' + ( cls . indexOf ( ':' ) == - 1 ? cls : cls . split ( ':' ) [ 1 ] )
309
- var lastid = listid
310
- graph = this . _sg ( graph )
311
- let clist = [ ]
312
- for ( var i = 0 ; i < ids . length ; i ++ ) {
313
- var nextid = i < ids . length - 1 ? listid + '_' + i : 'rdf:nil'
314
- clist . push (
315
- new WOQLQuery ( ) . add_quad ( lastid , 'rdf:first' , new WOQLQuery ( ) . iri ( ids [ i ] ) , graph ) ,
316
- )
317
- clist . push ( new WOQLQuery ( ) . add_quad ( lastid , 'rdf:rest' , new WOQLQuery ( ) . iri ( nextid ) , graph ) )
318
- lastid = nextid
319
- }
320
- return this . and (
321
- new WOQLQuery ( ) . add_quad ( cls , 'owl:oneOf' , new WOQLQuery ( ) . iri ( listid ) , graph ) ,
322
- ...clist ,
323
- )
324
- }
325
-
326
- /**
327
- * @description delete the enum list for a specific enumeration class, but not the class
328
- * @param {string } classId - the enum class id
329
- * @param {string } [graph] - the resource identifier of a schema graph. The Default value id schema/main
330
- * @returns {WOQLQuery } - A WOQLQuery which contains the Delete Choice List Statement
331
- */
332
- WOQLQuery . prototype . deleteChoiceList = function ( classId , graph ) {
333
- graph = this . _sg ( graph )
334
- //if I have to remove multi enum together
335
- const sufVar = Date . now ( )
336
- const vRest = `v:Rest${ sufVar } `
337
- const vClist = `v:Clist${ sufVar } `
338
- const vEntry = `v:Entry${ sufVar } `
339
- const vPath = `v:Path${ sufVar } `
340
- return new WOQLQuery ( ) . and (
341
- new WOQLQuery ( ) . from ( graph ) . and (
342
- new WOQLQuery ( )
343
- . select ( vRest )
344
- . distinct ( vRest )
345
- . triple ( classId , 'owl:oneOf' , vClist )
346
- . path ( vClist , 'rdf:rest+' , vEntry , vPath )
347
- . or (
348
- new WOQLQuery ( ) . triple ( vEntry , 'rdf:first' , vRest ) ,
349
- new WOQLQuery ( )
350
- . triple ( vClist , 'rdf:first' , `v:First${ sufVar } ` )
351
- . eq ( `v:First${ sufVar } ` , vRest ) ,
352
- ) ,
353
- new WOQLQuery ( )
354
- . triple ( vRest , `v:valprop${ sufVar } ` , `v:valval${ sufVar } ` )
355
- . triple ( `v:X${ sufVar } ` , 'rdf:first' , vRest )
356
- . triple ( `v:Y${ sufVar } ` , 'rdf:rest' , `v:valRest${ sufVar } ` )
357
- . triple ( classId , `v:classProp${ sufVar } ` , `v:classPropVal${ sufVar } ` ) ,
358
- ) ,
359
- new WOQLQuery ( )
360
- . delete_quad ( vRest , `v:valprop${ sufVar } ` , `v:valval${ sufVar } ` , graph )
361
- . delete_quad ( `v:X${ sufVar } ` , 'rdf:first' , vRest , graph )
362
- . delete_quad ( `v:Y${ sufVar } ` , 'rdf:rest' , `v:valRest${ sufVar } ` , graph )
363
- . delete_quad ( classId , `v:classProp${ sufVar } ` , `v:classPropVal${ sufVar } ` , graph ) ,
364
- )
365
- }
366
-
367
- /**
368
- * @description update or create an enumeration class. You have to add at least one permitted values in the list
369
- * @param {string } classId - the enum class id
370
- * @param {string } classLabel - the enum class label
371
- * @param {string } [classDesc] - the enum class description
372
- * @param {array } choices - an list of permitted values [[id,label,comment],[id,label,comment]]
373
- * @param {string } [graph] - the resource identifier of a schema graph. The Default value id schema/main
374
- * @returns {WOQLQuery } - A WOQLQuery which contains the Update Enum/Choice Class Statement
375
- */
376
- WOQLQuery . prototype . updateChoiceList = function ( classId , classLabel , classDesc , choices , graph ) {
377
- return new WOQLQuery ( ) . and (
378
- new WOQLQuery ( ) . opt ( new WOQLQuery ( ) . deleteChoiceList ( classId , graph ) ) ,
379
- new WOQLQuery ( ) . generateChoiceList ( classId , classLabel , classDesc , choices , graph ) ,
380
- )
381
- }
382
-
383
256
/**
384
257
* Adds the xdd datataypes to the graph
385
258
*/
0 commit comments