implemented PUTGRAF

This commit is contained in:
george 2012-05-06 14:28:08 +00:00
parent ff107f1362
commit 2d9860fe3d
1 changed files with 24 additions and 5 deletions

View File

@ -21,6 +21,8 @@ C0XXFRM ; GPL - Fileman Triples utilities ;11/07/11 17:05
;
TEST1 ; test GRAPHY
;
D INITFARY^C0XF2N("C0XFARY")
D USEFARY^C0XF2N("C0XFARY")
S G("possibleMatch",18262)=""
S G("possibleMatch",18262,"DOB")="19520606^19520606"
S G("possibleMatch",18262,"FNAME")="GEORGE^GEORGE PHILLIP"
@ -32,10 +34,12 @@ TEST1 ; test GRAPHY
S G("possibleMatch",18263,"LNAME")="LILLY^LILLY"
S G("possibleMatch",18263,"SSN")=3232221111
S GRAPH="/test/gpl/graph"
D DELGRAPH^C0XF2N(GRAPH)
S SUBJECT="/test/gpl/match"
D GRAPHY("G2","G",GRAPH,SUBJECT) ; CONVERT TO GRAPH
W !
ZWR G2
D PUTGRAF("G2",GRAPH) ; add them to the triple store
;
Q
;
@ -53,16 +57,31 @@ GRAPHY(ZOUT,ZIN,ZGRF,ZSUB,ZWHICH) ; turn a mumps array into triples
N ZJ S ZJ=""
F S ZJ=$O(@ZIN@(ZP,ZJ)) Q:ZJ="" D ; for each object
. N ZO
. S ZO=$$ANONS^C0XF2N ; anonomous subject
. S @ZOUT@(ZSUB,ZP,ZO)=""
. S @ZOUT@(ZO,"rdf:id",ZJ)=""
. ;S ZO=$$ANONS^C0XF2N ; anonomous subject
. S ZO="vista:"_ZJ
. S @ZOUT@(ZSUB,"fmts:"_ZP,ZO)=""
. ;S @ZOUT@(ZO,"fmts:id",ZJ)=""
. N ZK S ZK=""
. F S ZK=$O(@ZIN@(ZP,ZJ,ZK)) Q:ZK="" D ;
. . S @ZOUT@(ZO,ZK,$G(@ZIN@(ZP,ZJ,ZK)))=""
. . D GRAPHY(ZOUT,$NA(@ZIN@(ZP,ZJ,ZK)),ZGRF,ZO)
. . S @ZOUT@(ZO,"fmts:"_ZK,$G(@ZIN@(ZP,ZJ,ZK)))=""
. . ;D GRAPHY(ZOUT,$NA(@ZIN@(ZP,ZJ,ZK)),ZGRF,ZO)
;
Q
;
PUTGRAF(ZIN,ZGRF) ; add graph ZIN to the triples store with graph name ZGRF
; format for ZIN is @ZIN@("subject","predicate","object")=""
N ZI,ZJ,ZK S (ZI,ZJ,ZK)=""
D STARTADD^C0XF2N ; initialize for adding
F S ZI=$O(@ZIN@(ZI)) Q:ZI="" D ;
. N ZARY
. F S ZJ=$O(@ZIN@(ZI,ZJ)) Q:ZJ="" D ;
. . F S ZK=$O(@ZIN@(ZI,ZJ,ZK)) Q:ZK="" D ;
. . . S ZARY(ZJ)=ZK
. . . D ADDINN^C0XF2N(ZGRF,ZI,.ZARY) ; add triples for one subject
. ;ZWR C0XFDA
D BULKLOAD^C0XF2N(.C0XFDA) ; add to the triplestore
Q
;
ARRAYIFY(ZOUT,ZIN,ZWHICH) ; turn triples into a mumps array (opposite of GRAPHY)
;
Q