new handy utilities for transforming triples to mumps and back again

This commit is contained in:
george 2012-05-05 19:35:48 +00:00
parent abdb05b72d
commit aeff2fb2f6
1 changed files with 63 additions and 0 deletions

63
p/C0XXFRM.m Normal file
View File

@ -0,0 +1,63 @@
C0XXFRM ; GPL - Fileman Triples utilities ;11/07/11 17:05
;;0.1;C0X;nopatch;noreleasedate;Build 7
;Copyright 2011 George Lilly. Licensed under the terms of the GNU
;General Public License See attached copy of the License.
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
Q
;
TEST1 ; test GRAPHY
;
S G("positiveMatch",18262)=""
S G("positiveMatch",18262,"DOB")="19520606^19520606"
S G("positiveMatch",18262,"FNAME")="GEORGE^GEORGE PHILLIP"
S G("positiveMatch",18262,"LNAME")="LILLY^LILLY"
S G("positiveMatch",18262,"SSN")=310449999
S GRAPH="/test/gpl/graph"
S SUBJECT="/test/gpl/match"
D GRAPHY("G2","G",GRAPH,SUBJECT) ; CONVERT TO GRAPH
ZWR G2
;
Q
;
TEST2 ; test ARRAYIFY
;
Q
;
GRAPHY(ZOUT,ZIN,ZGRF,ZSUB,ZWHICH) ; turn a mumps array into triples
W !,"GRAPHY: ZOUT=",ZOUT," ZIN=",ZIN," ZSUB=",ZSUB," ZWHICH=",$G(ZWHICH),!
N ZI S ZI=$G(ZWHICH)
N ZP
S ZP=$O(@ZIN@(ZI))
W !,"ZP=",ZP
I ZP="" Q ; THE WAY OUT
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
. 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)
;
Q
;
ARRAYIFY(ZOUT,ZIN,ZWHICH) ; turn triples into a mumps array (opposite of GRAPHY)
;
Q
;