- Timestamp:
- Feb 27, 2012, 11:51:28 PM (13 years ago)
- Location:
- fmts/trunk/p
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XF2N.m
r1367 r1368 596 596 Q 597 597 ; 598 DELGRAPH(ZGRF,FARY) ; delete a graph from the triplestore 599 ; (doesn't delete strings) 600 ; 601 I '$D(FARY) D ; 602 . D INITFARY("C0XFARY") 603 . S FARY="C0XFARY" 604 D USEFARY(FARY) 605 N ZGRAPH 606 D TING(.ZGRAPH,ZGRF,FARY) 607 I '$D(ZGRAPH) D Q ; 608 . W !,"NO TRIPLES IN GRAPH" 609 K C0XFDA 610 N ZI S ZI="" 611 F S ZI=$O(ZGRAPH(ZI)) Q:ZI="" D ; 612 . S C0XFDA(C0XTFN,ZI_",",.01)="@" 613 D UPDIE(.C0XFDA) 614 Q 615 ; 616 TING(ZRTN,ZGRF,FARY) ; return the iens for graph ZGRF 617 ; ZRTN is passed by reference 618 I '$D(FARY) D ; 619 . D INITFARY("C0XFARY") 620 . S FARY="C0XFARY" 621 D USEFARY(FARY) 622 K ZRTN 623 N ZI,ZG S ZI="" 624 S ZG=$$IENOF(ZGRF) 625 I ZG="" D Q ; 626 . W !,"ERROR GRAPH NOT FOUND" 627 I '$D(@C0XTN@("G",ZG)) Q ; 628 F S ZI=$O(@C0XTN@("G",ZG,ZI)) Q:ZI="" D ; 629 . S ZRTN(ZI)="" 630 Q 631 ; 598 632 SWUPDIE(ZFDA) ; SWITCH BETWEEN UPDIE AND BULKLOAD 599 633 . I $G(BLKLOAD) D ; bulk load -
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 -
fmts/trunk/p/C0XRDF.m
r1367 r1368 39 39 I ZPRED[":" D Q ; 40 40 . I ZPRED="rdf:type" D Q ; 41 . . D ADD(ZARY,"rdf:type rdf:Resource="""_ ZOBJ_"""/>")42 . N ZA,ZB 41 . . D ADD(ZARY,"rdf:type rdf:Resource="""_$$EXT^C0XUTIL(ZOBJ)_"""/>") 42 . N ZA,ZB,ZC 43 43 . S ZA=$P(ZPRED,":",1) 44 44 . S ZB=$P(ZPRED,":",2) 45 . D ADD(ZARY,"<"_ZA_" xmlns="""_ZB_""">"_ZOBJ_"</"_ZA_">") 45 . S ZC=C0XVOC(ZA) 46 . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""">"_$$EXT^C0XUTIL(ZOBJ)_"</"_ZB_">") 46 47 Q 47 48 ; … … 70 71 f s zi=$o(zary(zi)) q:zi="" d ; for each subject 71 72 . n zii s zii="" 72 . D DICTSTART("rdfout", zi)73 . D DICTSTART("rdfout",$$EXT^C0XUTIL(zi)) 73 74 . f s zii=$o(zary(zi,zii)) q:zii="" d ; for each pred^obj pair 74 75 . . d DASSERT("rdfout",$p(zii,"^",1),$p(zii,"^",2))
Note:
See TracChangeset
for help on using the changeset viewer.