[1421] | 1 | C0XXFRM ; GPL - Fileman Triples utilities ;11/07/11 17:05
|
---|
| 2 | ;;0.1;C0X;nopatch;noreleasedate;Build 7
|
---|
| 3 | ;Copyright 2011 George Lilly. Licensed under the terms of the GNU
|
---|
| 4 | ;General Public License See attached copy of the License.
|
---|
| 5 | ;
|
---|
| 6 | ;This program is free software; you can redistribute it and/or modify
|
---|
| 7 | ;it under the terms of the GNU General Public License as published by
|
---|
| 8 | ;the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | ;(at your option) any later version.
|
---|
| 10 | ;
|
---|
| 11 | ;This program is distributed in the hope that it will be useful,
|
---|
| 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | ;GNU General Public License for more details.
|
---|
| 15 | ;
|
---|
| 16 | ;You should have received a copy of the GNU General Public License along
|
---|
| 17 | ;with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
| 18 | ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
| 19 | ;
|
---|
| 20 | Q
|
---|
| 21 | ;
|
---|
| 22 | TEST1 ; test GRAPHY
|
---|
| 23 | ;
|
---|
[1423] | 24 | D INITFARY^C0XF2N("C0XFARY")
|
---|
| 25 | D USEFARY^C0XF2N("C0XFARY")
|
---|
[1422] | 26 | S G("possibleMatch",18262)=""
|
---|
| 27 | S G("possibleMatch",18262,"DOB")="19520606^19520606"
|
---|
| 28 | S G("possibleMatch",18262,"FNAME")="GEORGE^GEORGE PHILLIP"
|
---|
| 29 | S G("possibleMatch",18262,"LNAME")="LILLY^LILLY"
|
---|
| 30 | S G("possibleMatch",18262,"SSN")=310449999
|
---|
| 31 | S G("possibleMatch",18263)=""
|
---|
| 32 | S G("possibleMatch",18263,"DOB")="19520606^19531031"
|
---|
| 33 | S G("possibleMatch",18263,"FNAME")="GEORGE^FRANCIS JAMES"
|
---|
| 34 | S G("possibleMatch",18263,"LNAME")="LILLY^LILLY"
|
---|
| 35 | S G("possibleMatch",18263,"SSN")=3232221111
|
---|
[1421] | 36 | S GRAPH="/test/gpl/graph"
|
---|
[1423] | 37 | D DELGRAPH^C0XF2N(GRAPH)
|
---|
[1421] | 38 | S SUBJECT="/test/gpl/match"
|
---|
| 39 | D GRAPHY("G2","G",GRAPH,SUBJECT) ; CONVERT TO GRAPH
|
---|
[1422] | 40 | W !
|
---|
[1421] | 41 | ZWR G2
|
---|
[1423] | 42 | D PUTGRAF("G2",GRAPH) ; add them to the triple store
|
---|
[1421] | 43 | ;
|
---|
| 44 | Q
|
---|
| 45 | ;
|
---|
| 46 | TEST2 ; test ARRAYIFY
|
---|
| 47 | ;
|
---|
| 48 | Q
|
---|
| 49 | ;
|
---|
| 50 | GRAPHY(ZOUT,ZIN,ZGRF,ZSUB,ZWHICH) ; turn a mumps array into triples
|
---|
| 51 | W !,"GRAPHY: ZOUT=",ZOUT," ZIN=",ZIN," ZSUB=",ZSUB," ZWHICH=",$G(ZWHICH),!
|
---|
| 52 | N ZI S ZI=$G(ZWHICH)
|
---|
| 53 | N ZP
|
---|
| 54 | S ZP=$O(@ZIN@(ZI))
|
---|
| 55 | W !,"ZP=",ZP
|
---|
| 56 | I ZP="" Q ; THE WAY OUT
|
---|
| 57 | N ZJ S ZJ=""
|
---|
| 58 | F S ZJ=$O(@ZIN@(ZP,ZJ)) Q:ZJ="" D ; for each object
|
---|
| 59 | . N ZO
|
---|
[1423] | 60 | . ;S ZO=$$ANONS^C0XF2N ; anonomous subject
|
---|
| 61 | . S ZO="vista:"_ZJ
|
---|
| 62 | . S @ZOUT@(ZSUB,"fmts:"_ZP,ZO)=""
|
---|
| 63 | . ;S @ZOUT@(ZO,"fmts:id",ZJ)=""
|
---|
[1421] | 64 | . N ZK S ZK=""
|
---|
| 65 | . F S ZK=$O(@ZIN@(ZP,ZJ,ZK)) Q:ZK="" D ;
|
---|
[1423] | 66 | . . S @ZOUT@(ZO,"fmts:"_ZK,$G(@ZIN@(ZP,ZJ,ZK)))=""
|
---|
| 67 | . . ;D GRAPHY(ZOUT,$NA(@ZIN@(ZP,ZJ,ZK)),ZGRF,ZO)
|
---|
[1421] | 68 | ;
|
---|
| 69 | Q
|
---|
| 70 | ;
|
---|
[1423] | 71 | PUTGRAF(ZIN,ZGRF) ; add graph ZIN to the triples store with graph name ZGRF
|
---|
| 72 | ; format for ZIN is @ZIN@("subject","predicate","object")=""
|
---|
| 73 | N ZI,ZJ,ZK S (ZI,ZJ,ZK)=""
|
---|
| 74 | D STARTADD^C0XF2N ; initialize for adding
|
---|
| 75 | F S ZI=$O(@ZIN@(ZI)) Q:ZI="" D ;
|
---|
| 76 | . N ZARY
|
---|
| 77 | . F S ZJ=$O(@ZIN@(ZI,ZJ)) Q:ZJ="" D ;
|
---|
| 78 | . . F S ZK=$O(@ZIN@(ZI,ZJ,ZK)) Q:ZK="" D ;
|
---|
| 79 | . . . S ZARY(ZJ)=ZK
|
---|
| 80 | . . . D ADDINN^C0XF2N(ZGRF,ZI,.ZARY) ; add triples for one subject
|
---|
| 81 | . ;ZWR C0XFDA
|
---|
| 82 | D BULKLOAD^C0XF2N(.C0XFDA) ; add to the triplestore
|
---|
| 83 | Q
|
---|
| 84 | ;
|
---|
[1421] | 85 | ARRAYIFY(ZOUT,ZIN,ZWHICH) ; turn triples into a mumps array (opposite of GRAPHY)
|
---|
| 86 | ;
|
---|
| 87 | Q
|
---|
| 88 | ; |
---|