Changeset 1368 for fmts/trunk/p/C0XGET1.m
- Timestamp:
- Feb 27, 2012, 11:51:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XGET1.m
r1367 r1368 83 83 s qrtn(1)=q1_"^"_q2_"^"_q3 ; more lines to come later 84 84 q 85 ; 86 getGraph(zrtn,zgrf,form) ; get all triples in graph zgrf 87 ; forms planned: "rdf" "json" "array" "turtle" "triples" 88 ; forms supported: "rdf" "json" "array" 89 I '$D(form) S form="rdf" 90 N ZIENS,ZTRIP 91 D TING^C0XF2N(.ZIENS,zgrf) 92 I '$D(ZIENS) Q ; 93 D ien2tary(.ZTRIP,"ZIENS") 94 I form="json" d jsonout(.zrtn,.ZTRIP) q ; what follows is else 95 i form="rdf" d rdfout^C0XRDF(.zrtn,.ZTRIP) q ; 96 i form="array" d arrayout^C0XGET1(.zrtn,.ZTRIP) q ; 97 W !,"Form not supported: ",form 98 Q 85 99 ; 86 100 rpctrip(rtn,query,limit,offset) ; rpc to access triples with a query … … 101 115 q 102 116 ; 103 triples(triplertn,sub,pred,obj,graph,f ary) ; returns triples117 triples(triplertn,sub,pred,obj,graph,form,fary) ; returns triples 104 118 I '$D(fary) D ; 105 119 . D INITFARY^C0XF2N("C0XFARY") 106 120 . S fary="C0XFARY" 107 121 D USEFARY^C0XF2N(fary) 122 I '$D(form) S form="json" 108 123 k triplertn ; start with a clean return 109 124 n zsub,zpred,zobj,zgraph,tmprtn … … 116 131 d ien2tary(.zrary,"tmprtn") ; convert to triples 117 132 ; 118 d rdfout^C0XRDF(.triplertn,.zrary) q ; 119 i REPLYFMT="JSON" d jsonout(.triplertn,.zrary) q ; what follows is 'else' 120 ; 121 ; if no reply format is found we just output an array of triples 133 i form="json" d jsonout(.triplertn,.zrary) q ; what follows is 'else' 134 i form="rdf" d rdfout^C0XRDF(.triplertn,.zrary) q ; 135 i form="array" d arrayout(.triplertn,.zrary) q ; 136 w !,"form not supported: ",form 137 q 138 ; 139 arrayout(rtn,zary) ; output an array of triples 122 140 ; 123 141 s zrsub="" 124 142 s zcnt=1 125 f s zrsub=$o(z rary(zrsub)) q:zrsub="" d ; organized by subject143 f s zrsub=$o(zary(zrsub)) q:zrsub="" d ; organized by subject 126 144 . s zzz="" 127 . f s zzz=$o(z rary(zrsub,zzz)) q:zzz="" d ; pred and obj128 . . s triplertn(zcnt)=zrsub_"^"_zzz145 . f s zzz=$o(zary(zrsub,zzz)) q:zzz="" d ; pred and obj 146 . . s rtn(zcnt)=zrsub_"^"_zzz 129 147 . . s zcnt=zcnt+1 130 148 q
Note:
See TracChangeset
for help on using the changeset viewer.