From 2d9860fe3d9c6b7f7ba40cf2c992925fbddf5587 Mon Sep 17 00:00:00 2001 From: george Date: Sun, 6 May 2012 14:28:08 +0000 Subject: [PATCH] implemented PUTGRAF --- p/C0XXFRM.m | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/p/C0XXFRM.m b/p/C0XXFRM.m index 5377988..49616fe 100644 --- a/p/C0XXFRM.m +++ b/p/C0XXFRM.m @@ -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