added support for raw mumps array format

This commit is contained in:
george 2012-04-04 18:45:35 +00:00
parent 24f9415112
commit af30ebada4
2 changed files with 18 additions and 3 deletions

View File

@ -108,8 +108,8 @@ qparse(qrtn,zquery) ; parses the query
q
;
getGraph(zrtn,zgrf,form) ; get all triples in graph zgrf
; forms planned: "rdf" "json" "array" "turtle" "triples"
; forms supported: "rdf" "json" "array"
; forms planned: "rdf" "json" "array" "turtle" "triples" "raw"
; forms supported: "rdf" "json" "array" "raw"
I '$D(form) S form="rdf"
N ZIENS,ZTRIP
D TING^C0XF2N(.ZIENS,zgrf)
@ -118,6 +118,7 @@ getGraph(zrtn,zgrf,form) ; get all triples in graph zgrf
I form="json" d jsonout(.zrtn,.ZTRIP) q ; what follows is else
i form="rdf" d rdfout^C0XRDF(.zrtn,.ZTRIP) q ;
i form="array" d arrayout^C0XGET1(.zrtn,.ZTRIP) q ;
i form="raw" d rawout^C0XGET1(.zrtn,.ZTRIP) q ;
W !,"Form not supported: ",form
Q
;
@ -156,7 +157,8 @@ triples(triplertn,sub,pred,obj,graph,form,fary) ; returns triples
;
i form="json" d jsonout(.triplertn,.zrary) q ; what follows is 'else'
i form="rdf" d rdfout^C0XRDF(.triplertn,.zrary) q ;
i form="array" d arrayout(.triplertn,.zrary) q ;
i form="array" d arrayout(.triplertn,.zrary) q ;
i form="raw" d rawout(.triplertn,.zrary) q ;
w !,"form not supported: ",form
q
;
@ -282,6 +284,17 @@ arrayout(rtn,zary) ; output an array of triples
. . s zcnt=zcnt+1
q
;
rawout(rtn,zary) ; output a mumps array of triples
;
s zrsub=""
;s zcnt=1
f s zrsub=$o(zary(zrsub)) q:zrsub="" d ; organized by subject
. s zzz=""
. f s zzz=$o(zary(zrsub,zzz)) q:zzz="" d ; pred and obj
. . s rtn(zrsub,$p(zzz,"^",1))=$p(zzz,"^",2)
. . ;s zcnt=zcnt+1
q
;
strings(zrary,zinary) ; convert pointers to strings
;
k zrary

View File

@ -42,6 +42,8 @@ DASSERT(ZARY,ZPRED,ZOBJ)
. N ZA,ZB,ZC
. S ZA=$P(ZPRED,":",1)
. S ZB=$P(ZPRED,":",2)
. I $E(ZB,1,1)="/" D ;
. . S ZB=$P(ZB,"/",2) ; handling gpltest:/note situations
. S ZC=C0XVOC(ZA)
. I ZOBJ["nodeID:" D Q ;
. . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""" rdf:nodeID="""_$$EXT^C0XUTIL(ZOBJ)_"""/>")