[1294] | 1 | C0XF2N ; GPL - Fileman Triples entry point routine ;10/13/11 17:05
|
---|
[1343] | 2 | ;;0.1;C0X;nopatch;noreleasedate;Build 7
|
---|
[1277] | 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 | ; This is based on C0XMAIN but experiments with a fast load for triples
|
---|
| 23 | ; that will write directly to the fileman global
|
---|
| 24 | ; The file 172.101 is a F2N design style for triples, which means
|
---|
| 25 | ; that it is a Flat file with no subfiles, all fields at the root
|
---|
| 26 | ; ... it is a "2" file solution which means all strings are stored in
|
---|
| 27 | ; ... strings file and pointed to by the triples file
|
---|
| 28 | ; ... it is an N file because it has generated Node IDs instead of
|
---|
| 29 | ; ... DINUM which would use the IEN for the Node ID.
|
---|
| 30 | ; gpl 11/04/2011
|
---|
| 31 | ;
|
---|
| 32 | INITFARY(ZFARY) ; INITIALIZE FILE NUMBERS AND OTHER USEFUL THINGS
|
---|
| 33 | ; FOR THE DEFAULT TRIPLE STORE. USE OTHER VALUES FOR SUPPORTING ADDITIONAL
|
---|
| 34 | ; TRIPLE STORES
|
---|
[1294] | 35 | I $D(@ZFARY) Q ; ALREADY INITIALIZED
|
---|
[1277] | 36 | S @ZFARY@("C0XTFN")=172.101 ; TRIPLES FILE NUMBER
|
---|
| 37 | S @ZFARY@("C0XSFN")=172.201 ; TRIPLES STRINGS FILE NUMBER
|
---|
| 38 | S @ZFARY@("C0XTN")=$NA(^C0X(101)) ; TRIPLES GLOBAL NAME
|
---|
| 39 | S @ZFARY@("C0XSN")=$NA(^C0X(201)) ; STRING FILE GLOBAL NAME
|
---|
[1367] | 40 | S @ZFARY@("C0XDIR")="/home/glilly/fmts/trunk/samples/smart-rdf-in/"
|
---|
[1279] | 41 | S @ZFARY@("BLKLOAD")=1 ; this file supports block load
|
---|
| 42 | S @ZFARY@("FMTSSTYLE")="F2N" ; fileman style
|
---|
[1366] | 43 | S @ZFARY@("REPLYFMT")="JSON"
|
---|
[1277] | 44 | D USEFARY(ZFARY)
|
---|
| 45 | Q
|
---|
| 46 | ;
|
---|
| 47 | USEFARY(ZFARY) ; INITIALIZES VARIABLES SAVED IN ARRAY ZFARY
|
---|
| 48 | N ZI S ZI=""
|
---|
| 49 | F S ZI=$O(@ZFARY@(ZI)) Q:ZI="" D
|
---|
| 50 | . ;N ZX
|
---|
| 51 | . S ZX="S "_ZI_"="""_@ZFARY@(ZI)_""""
|
---|
| 52 | . ;W !,ZX
|
---|
| 53 | . X ZX
|
---|
| 54 | Q
|
---|
| 55 | ;
|
---|
| 56 | FILEIN ; INTERACTIVE ENTRY POINT FOR OPTION TO READ IN A FILE
|
---|
| 57 | I '$D(C0XFARY) D INITFARY("C0XFARY")
|
---|
| 58 | D USEFARY("C0XFARY")
|
---|
| 59 | S DIR(0)="F^3:240"
|
---|
| 60 | S DIR("A")="File Directory"
|
---|
| 61 | S DIR("B")=C0XDIR
|
---|
| 62 | D ^DIR
|
---|
| 63 | I Y="^" Q ;
|
---|
| 64 | S C0XDIR=Y
|
---|
| 65 | S C0XFARY("C0XDIR")=Y
|
---|
| 66 | S DIR(0)="F^3:240"
|
---|
| 67 | S DIR("A")="File Name"
|
---|
| 68 | I '$D(C0XFN) S DIR("B")="qds.rdf"
|
---|
| 69 | E S DIR("B")=C0XFN
|
---|
| 70 | D ^DIR
|
---|
| 71 | I Y="" Q ;
|
---|
| 72 | I Y="^" Q ;
|
---|
| 73 | S C0XFN=Y
|
---|
| 74 | D IMPORT(C0XFN,C0XDIR,,"C0XFARY")
|
---|
[1294] | 75 | K C0XFDA
|
---|
[1277] | 76 | Q
|
---|
| 77 | ;
|
---|
[1294] | 78 | IMPORT(FNAME,INDIR,INURL,FARY) ; EXTRINSIC THAT READS A FILE FROM THE STANDARD
|
---|
[1277] | 79 | ; DIRECTORY, LOADS IT INTO THE TRIPLESTORE AS TEXT, AND RETURNS THE
|
---|
| 80 | ; NODE NAME OF THE TEXT TRIPLE
|
---|
[1294] | 81 | ; INDIR IS THE OPTIONAL DIRECTORY (DEFAUTS TO STANDARD DIR)
|
---|
| 82 | ; INURL IS THE OPTIONAL URI FOR ACCESSING THE FILE FROM THE TRIPLE STORE
|
---|
[1277] | 83 | ; FARY IS THE OPTIONAL FILE ARRAY OF THE TRIPLE STORE TO USE
|
---|
| 84 | I '$D(FARY) D ;
|
---|
| 85 | . D INITFARY("C0XFARY")
|
---|
| 86 | . S FARY="C0XFARY"
|
---|
| 87 | D USEFARY(FARY)
|
---|
| 88 | N ZD,ZTMP
|
---|
[1294] | 89 | I '$D(INDIR) S INDIR=C0XDIR ; DIRECTORY OF THE RDF FILE
|
---|
| 90 | I $G(INURL)="" D ;
|
---|
| 91 | . ;N ZN2 S ZN2=$P(FNAME,".",1)_"_"_$P(FNAME,".",2) ; REMOVE THE DOT
|
---|
| 92 | . ;S INURL=FDIR_ZN2
|
---|
| 93 | . S INURL=INDIR_FNAME
|
---|
[1277] | 94 | N ZTMP
|
---|
| 95 | S ZTMP=$NA(^TMP("C0X",$J,"FILEIN",1)) ; WHERE TO PUT THE INCOMING FILE
|
---|
| 96 | K @ZTMP ; MAKE SURE IT'S CLEAR
|
---|
| 97 | S C0XSTART=$$NOW^XLFDT
|
---|
| 98 | W !,"STARTED: ",C0XSTART
|
---|
| 99 | W !,"READING IN: ",FNAME
|
---|
[1294] | 100 | I '$$FILEREAD(ZTMP,INDIR,FNAME,4) D Q ; QUIT IF NO SUCCESS
|
---|
| 101 | . W !,"ERROR READING FILE: ",INDIR,FNAME
|
---|
[1277] | 102 | S ZRDF=$NA(^TMP("C0X",$J,"FILEIN")) ; WITHOUT THE SUBSCRIPT
|
---|
| 103 | W !,$O(@ZRDF@(""),-1)," LINES READ"
|
---|
[1294] | 104 | D INSRDF(ZRDF,INURL,FARY) ; IMPORT AND PROCESS THE RDF
|
---|
| 105 | K INURL
|
---|
| 106 | K C0XFDA
|
---|
[1322] | 107 | ;K ^TMP("MXMLDOM",$J)
|
---|
[1277] | 108 | Q
|
---|
| 109 | ;
|
---|
| 110 | WGET(ZURL,FARY) ; GET FROM THE INTERNET AN RDF FILE AND INSERT IT
|
---|
| 111 | ;
|
---|
| 112 | I '$D(FARY) D ;
|
---|
| 113 | . D INITFARY("C0XFARY")
|
---|
| 114 | . S FARY="C0XFARY"
|
---|
| 115 | D USEFARY(FARY)
|
---|
| 116 | ;N ZLOC,ZTMP
|
---|
| 117 | K ZTMP
|
---|
| 118 | S ZLOC=$NA(^TMP("C0X","WGET",$J))
|
---|
| 119 | K @ZLOC
|
---|
| 120 | S C0XSTART=$$NOW^XLFDT
|
---|
| 121 | W !,"STARTED: ",C0XSTART
|
---|
| 122 | W !,"DOWNLOADING: ",ZURL
|
---|
| 123 | S OK=$$httpGET^%zewdGTM(ZURL,.ZTMP)
|
---|
| 124 | M @ZLOC=ZTMP
|
---|
| 125 | S C0XLINES=$O(@ZLOC@(""),-1)
|
---|
| 126 | W !,C0XLINES," LINES READ"
|
---|
| 127 | S C0XDLC=$$NOW^XLFDT ; DOWNLOAD COMPLETE
|
---|
| 128 | W !,"DOWNLOAD COMPLETE AT ",C0XDLC
|
---|
| 129 | S C0XDIFF=$$FMDIFF^XLFDT(C0XDLC,C0XSTART,2)
|
---|
| 130 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
| 131 | I C0XDIFF'=0 W !," APPROXIMATELY ",$P(C0XLINES/C0XDIFF,".")," LINES PER SEC"
|
---|
| 132 | D INSRDF(ZLOC,ZURL,FARY)
|
---|
| 133 | Q
|
---|
| 134 | ;
|
---|
| 135 | INSRDF(ZRDF,ZNAME,FARY) ; INSERT AN RDF FILE INTO THE STORE AND PROCESS
|
---|
| 136 | ; ZRDF IS PASSED BY NAME
|
---|
| 137 | I '$D(FARY) D ;
|
---|
| 138 | . D INITFARY("C0XFARY")
|
---|
| 139 | . S FARY="C0XFARY"
|
---|
| 140 | D USEFARY(FARY)
|
---|
[1294] | 141 | S BATCNT=0 ; BATCH COUNTER
|
---|
| 142 | S BATMAX=10000 ; TRY BATCHES OF THIS SIZE
|
---|
[1277] | 143 | N ZGRAPH,ZSUBJECT
|
---|
| 144 | S ZGRAPH="_:G"_$$LKY9 ; RANDOM GRAPH NAME
|
---|
[1372] | 145 | S ZSUBJECT=$$ANONS() ; RANDOM ANOYMOUS SUBJECT
|
---|
[1277] | 146 | D ADD(ZGRAPH,ZSUBJECT,"fmts:url",ZNAME,FARY)
|
---|
| 147 | N ZTXTNM
|
---|
| 148 | S ZTXTNM="_TXT_INCOMING_RDF_FILE_"_ZNAME_"_"_$$LKY9 ; NAME FOR TEXT NODE
|
---|
| 149 | D ADD(ZGRAPH,ZSUBJECT,"fmts:rdfSource",ZTXTNM,FARY)
|
---|
[1294] | 150 | D SWUPDIE(.C0XFDA) ; TRY IT OUT
|
---|
[1277] | 151 | K C0XCNT ;RESET FOR NEXT TIME
|
---|
| 152 | D STORETXT(ZRDF,ZTXTNM,FARY)
|
---|
| 153 | W !,"ADDED: ",ZGRAPH," ",ZSUBJECT," fmts:rdfSource ",ZTXTNM
|
---|
[1294] | 154 | D PROCESS(.G,ZRDF,ZNAME,ZGRAPH,FARY) ; PARSE AND INSERT THE RDF
|
---|
[1277] | 155 | Q
|
---|
| 156 | ;
|
---|
| 157 | STORETXT(ZTXT,ZNAME,FARY) ; STORE TEXT IN THE TRIPLESTORE AT ZNAME
|
---|
| 158 | ;
|
---|
| 159 | I '$D(FARY) D ;
|
---|
| 160 | . D INITFARY("C0XFARY")
|
---|
| 161 | . S FARY="C0XFARY"
|
---|
| 162 | D USEFARY(FARY)
|
---|
| 163 | N ZIEN
|
---|
| 164 | S ZIEN=$$IENOF(ZNAME,FARY) ; GET THE IEN
|
---|
| 165 | D CLEAN^DILF
|
---|
| 166 | K ZERR
|
---|
| 167 | D WP^DIE(C0XSFN,ZIEN_",",1,,ZTXT,"ZERR")
|
---|
[1366] | 168 | I $D(ZERR) D Q ;
|
---|
| 169 | . W !,"ERROR CREATING WORD PROCESSING FIELD"
|
---|
| 170 | . S C0XERR="ERROR CREATING WORD PROCESSING FIELD"
|
---|
| 171 | . D ^%ZTER ; error trap
|
---|
[1277] | 172 | Q
|
---|
| 173 | ;
|
---|
| 174 | GETTXT(ZRTN,ZNAME,FARY) ; RETURNS RDF SOURCE OR OTHER TEXT
|
---|
| 175 | ; ZRTN IS PASSED BY REFERENCE
|
---|
| 176 | I '$D(FARY) D ;
|
---|
| 177 | . D INITFARY("C0XFARY")
|
---|
| 178 | . S FARY="C0XFARY"
|
---|
| 179 | D USEFARY(FARY)
|
---|
| 180 | N ZIEN
|
---|
| 181 | S ZIEN=$$IENOF(ZNAME)
|
---|
| 182 | S OK=$$GET1^DIQ(C0XSFN,ZIEN_",",1,,"ZRTN")
|
---|
| 183 | Q
|
---|
| 184 | ;
|
---|
| 185 | WHERETXT(ZNAME,FARY) ; EXTRINSIC WHICH RETURNS THE NAME OF THE GLOBAL
|
---|
| 186 | ; WHERE THE TEXT IS LOCATED. NAME IS THE NAME OF THE STRING
|
---|
| 187 | I '$D(FARY) D ;
|
---|
| 188 | . D INITFARY("C0XFARY")
|
---|
| 189 | . S FARY="C0XFARY"
|
---|
| 190 | D USEFARY(FARY)
|
---|
| 191 | N ZIEN
|
---|
| 192 | S ZIEN=$$IENOF(ZNAME)
|
---|
| 193 | Q $NA(@C0XSN@(ZIEN,1))
|
---|
| 194 | ;
|
---|
| 195 | FILEREAD(ZINTMP,ZDIR,ZFNAME,ZLVL) ; READS A FILE INTO ZINTMP USING FTG^%ZISH
|
---|
| 196 | ; ZINTMP IS PASSED BY NAME AND INCLUDES THE NEW SUBSCRIPT
|
---|
| 197 | ; IE ^TMP("C0X","FILEIN",1)
|
---|
| 198 | ; ZLVL IN THIS CASE WOULD BE 3 INCREMENTING THE 1
|
---|
| 199 | ; EXTRINSIC WHICH RETURNS THE RESULT OF FTG^%ZISH
|
---|
| 200 | S OK=$$FTG^%ZISH(ZDIR,FNAME,ZINTMP,ZLVL)
|
---|
| 201 | Q OK
|
---|
| 202 | ;
|
---|
| 203 | TESTPROC ; TEST PROCESS WITH EXISTING SMALL RDF FILE
|
---|
| 204 | S ZIN=$NA(^TMP("C0X",12226,"FILEIN"))
|
---|
| 205 | S ZGRAPH="/test/rdfFile"
|
---|
| 206 | S ZM="/test/rdfFile/meta"
|
---|
| 207 | D PROCESS(.G,ZIN,ZGRAPH,ZM)
|
---|
| 208 | Q
|
---|
| 209 | ;
|
---|
[1359] | 210 | VISTAOWL ;
|
---|
| 211 | S ZRDF=$NA(^TMP("C0X",542,"FILEIN"))
|
---|
| 212 | S ZNAME="/home/glilly/vistaowl/VistAOWL.owl"
|
---|
| 213 | S ZGRAPH="_:G431590209"
|
---|
| 214 | S FARY="C0XFARY"
|
---|
| 215 | D INITFARY(FARY)
|
---|
| 216 | S C0XDOCID=1
|
---|
| 217 | S BATCNT=0
|
---|
| 218 | S BATMAX=10000
|
---|
| 219 | D PROCESS(.G,ZRDF,ZGRAPH,ZNAME,FARY)
|
---|
| 220 | Q
|
---|
| 221 | ;
|
---|
[1277] | 222 | PROCESS(ZRTN,ZRDF,ZGRF,ZMETA,FARY) ; PROCESS AN INCOMING RDF FILE
|
---|
| 223 | ; ZRTN IS PASS BY REFERENCE AND RETURNS MESSAGES ABOUT THE PROCESSING
|
---|
| 224 | ; ZRDF IS PASSED BY NAME AND IS THE GLOBAL CONTAINING THE RDF FILE
|
---|
| 225 | ; ZGRF IS THE NAME OF THE GRAPH TO USE IN THE TRIPLE STORE FOR RESULTS
|
---|
| 226 | ; ZMETA IS OPTIONAL AND IS THE NAME OF THE GRAPH TO STORE METADATA
|
---|
| 227 | ;
|
---|
| 228 | I '$D(FARY) D ;
|
---|
| 229 | . D INITFARY("C0XFARY")
|
---|
| 230 | . S FARY="C0XFARY"
|
---|
| 231 | D USEFARY(FARY)
|
---|
| 232 | ;N BATCNT
|
---|
| 233 | ;N BATMAX
|
---|
| 234 | ; -- first parse the rdf file with the MXML parser
|
---|
| 235 | ;S C0XDOCID=$$PARSE^C0CNHIN(ZRDF,"C0XARRAY") ; PARSE WITH MXML
|
---|
| 236 | S C0XDLC2=$$NOW^XLFDT ; START OF PARSE
|
---|
[1360] | 237 | S C0XDOCID=$$EN^MXMLDOM(ZRDF,"W") ;
|
---|
[1322] | 238 | ;B
|
---|
[1294] | 239 | K @ZRDF ; DON'T NEED INPUT BUFFER ANYMORE
|
---|
[1277] | 240 | ; -- assign the MXLM dom global name to ZDOM
|
---|
[1360] | 241 | S ZDOM=$NA(^TMP("MXMLDOM",$J,C0XDOCID))
|
---|
| 242 | ;S ZDOM=$NA(^TMP("MXMLDOM",16850,C0XDOCID)) ;VISTAOWL DOM
|
---|
[1277] | 243 | S C0XNODE=$O(@ZDOM@(""),-1)
|
---|
| 244 | W !,C0XNODE," XML NODES PARSED"
|
---|
| 245 | S C0XPRS=$$NOW^XLFDT ; PARSE COMPLETE
|
---|
| 246 | W !,"PARSE COMPLETE AT ",C0XPRS
|
---|
| 247 | S C0XDIFF=$$FMDIFF^XLFDT(C0XPRS,C0XDLC2,2)
|
---|
| 248 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
| 249 | I C0XDIFF'=0 D ;
|
---|
| 250 | . W !," APPROXIMATELY ",$P(C0XNODE/C0XDIFF,".")," NODES PER SECOND"
|
---|
| 251 | ; -- populate the metagraph to point to the graph with status unfinished
|
---|
| 252 | S METAS=$$ANONS ; GET AN ANONOMOUS RANDOM SUBJECT
|
---|
| 253 | I '$D(ZMETA) S ZMETA="_:G"_$$LKY9 ; RANDOM GRAPH NAME FOR METAGRAPH
|
---|
| 254 | D ADD(ZMETA,METAS,"fmts:about",ZGRF,FARY) ; POINT THE META TO THE GRAPH
|
---|
| 255 | D ADD(ZMETA,METAS,"fmts:status","unfinished",FARY) ; mark as unfinished
|
---|
[1294] | 256 | W !,"INSERTING GRAPH: ",ZGRF
|
---|
[1277] | 257 | ;S C0XDATE=$$FMDTOUTC^C0CUTIL($$NOW^XLFDT,"DT")
|
---|
| 258 | S C0XDATE=$$NOW^XLFDT
|
---|
| 259 | D ADD(ZMETA,METAS,"fmts:dateTime",C0XDATE,FARY)
|
---|
[1294] | 260 | D SWUPDIE(.C0XFDA) ; commit the metagraph changes to the triple store
|
---|
[1277] | 261 | ; --
|
---|
| 262 | ; -- pull out the vocabularies in the RDF statement. marked with xmlns:
|
---|
| 263 | ; -- put them in a local variable for quick reference
|
---|
| 264 | ; -- TODO: create a graph for vocabularies and validate incoming against it
|
---|
| 265 | ;
|
---|
| 266 | S C0XVOC=""
|
---|
| 267 | N ZI,ZJ,ZK S ZI=""
|
---|
| 268 | F S ZI=$O(@ZDOM@(1,"A",ZI)) Q:ZI="" D ; FOR EACH xmlns
|
---|
| 269 | . S ZVOC=$P(ZI,"xmlns:",2)
|
---|
| 270 | . I ZVOC'="" S C0XVOC(ZVOC)=$G(@ZDOM@(1,"A",ZI))
|
---|
[1366] | 271 | W !,"VOCABS:"
|
---|
| 272 | N ZZ S ZZ=""
|
---|
[1367] | 273 | F S ZZ=$O(C0XVOC(ZZ)) Q:ZZ="" W !,ZZ,":",C0XVOC(ZZ)
|
---|
[1277] | 274 | ;
|
---|
| 275 | ; -- look for children called rdf:Description. quit if none. not an rdf file
|
---|
| 276 | ;
|
---|
[1322] | 277 | S C0XTYPE("rdf:Description")=1
|
---|
| 278 | S C0XTYPE("owl:ObjectProperty")=1
|
---|
[1359] | 279 | S C0XTYPE("owl:Ontology")=1
|
---|
[1363] | 280 | S C0XTYPE("owl:Class")=1
|
---|
| 281 | S C0XTYPE("rdfs:subClassOf")=1
|
---|
[1277] | 282 | S ZI=$O(@ZDOM@(1,"C",""))
|
---|
[1322] | 283 | I '$G(C0XTYPE(@ZDOM@(1,"C",ZI))) D Q ; not an rdf file
|
---|
[1277] | 284 | . W !,"Error. Not an RDF file. Cannot process."
|
---|
[1366] | 285 | . D SHOW(1)
|
---|
[1277] | 286 | ;
|
---|
| 287 | ; -- now process the rdf description children
|
---|
| 288 | ;
|
---|
| 289 | S ZI=""
|
---|
| 290 | S (C0XSUB,C0XPRE,C0XOBJ)="" ; INITIALIZE subject, object and predicate
|
---|
| 291 | F S ZI=$O(@ZDOM@(1,"C",ZI)) Q:ZI="" D ;
|
---|
| 292 | . ; -- we are skipping any child that is not rdf:Description
|
---|
| 293 | . ; -- TODO: check to see if this is right in general
|
---|
| 294 | . ;
|
---|
[1322] | 295 | . IF '$G(C0XTYPE(@ZDOM@(1,"C",ZI))) D Q ;
|
---|
[1277] | 296 | . . W !,"SKIPPING NODE: ",ZI
|
---|
| 297 | . ; -- now looking for the subject for the triples
|
---|
| 298 | . S ZX=$G(@ZDOM@(ZI,"A","rdf:about"))
|
---|
| 299 | . I ZX'="" D ; we have the subject
|
---|
| 300 | . . ;W " about: ",ZX
|
---|
| 301 | . . S C0XSUB=ZX
|
---|
| 302 | . E D ;
|
---|
| 303 | . . S ZX=$G(@ZDOM@(ZI,"A","rdf:nodeID")) ; node id is another style of subject
|
---|
| 304 | . . I ZX'="" D ;
|
---|
| 305 | . . . S C0XSUB=ZX
|
---|
| 306 | . I C0XSUB="" S C0XSUB=$$ANONS ; DEFAULT TO BLANK SUBJECT
|
---|
| 307 | . ;
|
---|
| 308 | . ; -- we now have the subject. the children of this node have the rest
|
---|
| 309 | . ;
|
---|
| 310 | . S ZJ="" ; for the children of the rdf:Description nodes
|
---|
| 311 | . F S ZJ=$O(@ZDOM@(ZI,"C",ZJ)) Q:ZJ="" D ; for each child
|
---|
| 312 | . . S C0XPRE=@ZDOM@(ZJ) ; the predicate without a prefix
|
---|
| 313 | . . S ZX=$G(@ZDOM@(ZJ,"A","xmlns")) ; name space
|
---|
| 314 | . . I ZX'="" S C0XPRE=ZX_C0XPRE ; add the namespace prefix
|
---|
| 315 | . . I C0XPRE[":" D ; expand using vocabulary
|
---|
| 316 | . . . N ZB,ZA
|
---|
| 317 | . . . S ZB=$P(C0XPRE,":",1)
|
---|
| 318 | . . . S ZA=$P(C0XPRE,":",2)
|
---|
| 319 | . . . I $G(C0XVOC(ZB))'="" D ;
|
---|
| 320 | . . . . S C0XPRE=C0XVOC(ZB)_ZA ; expanded
|
---|
| 321 | . . S ZY=$G(@ZDOM@(ZJ,"A","rdf:resource")) ; potential object
|
---|
| 322 | . . I ZY'="" D Q ;
|
---|
[1363] | 323 | . . . S C0XOBJ=$$EXT^C0XUTIL(ZY) ; object
|
---|
[1294] | 324 | . . . D ADD(ZGRF,C0XSUB,C0XPRE,C0XOBJ) ; finally. our first real triple
|
---|
[1277] | 325 | . . ; -- this is an else because of the quit above
|
---|
| 326 | . . S ZX=$G(@ZDOM@(ZJ,"A","rdf:nodeID")) ; fishing for nodeId object
|
---|
| 327 | . . I ZX'="" D Q ; got one
|
---|
| 328 | . . . S C0XOBJ=ZX ; we are using the incoming nodeIDs as object/subject
|
---|
| 329 | . . . ; without change... this could be foolish .. look at it again later
|
---|
[1294] | 330 | . . . D ADD(ZGRF,C0XSUB,C0XPRE,C0XOBJ) ; go for it and add a node
|
---|
[1277] | 331 | . . S C0XOBJ=$G(@ZDOM@(ZJ,"T",1)) ; hopefully an object is here
|
---|
| 332 | . . I C0XOBJ="" D Q ; not a happy situation
|
---|
| 333 | . . . W !,"ERROR, NO OBJECT FOUND FOR NODE: ",ZJ
|
---|
[1363] | 334 | . . S C0XOBJ=$$EXT^C0XUTIL(C0XOBJ) ; might be namespaced
|
---|
[1294] | 335 | . . D ADD(ZGRF,C0XSUB,C0XPRE,C0XOBJ) ; go for it and add a node
|
---|
[1277] | 336 | S C0XTRP=$$NOW^XLFDT ; PARSE COMPLETE
|
---|
| 337 | W !,"TRIPLES COMPLETE AT ",C0XTRP
|
---|
| 338 | S C0XDIFF=$$FMDIFF^XLFDT(C0XTRP,C0XPRS,2)
|
---|
| 339 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
| 340 | I C0XDIFF'=0 D ;
|
---|
| 341 | . W !," APPROXIMATELY ",$P(C0XCNT/C0XDIFF,".")," TRIPLES PER SECOND"
|
---|
| 342 | W !,"INSERTING ",C0XCNT," TRIPLES"
|
---|
[1279] | 343 | I $D(C0XFDA) D ;
|
---|
| 344 | . I $G(BLKLOAD) D ;
|
---|
| 345 | . . D BULKLOAD(.C0XFDA)
|
---|
| 346 | . E D ;
|
---|
| 347 | . . D UPDIE(.C0XFDA) ; commit the updates to the file
|
---|
[1277] | 348 | ; next, mark the graph as finished
|
---|
| 349 | S C0XINS=$$NOW^XLFDT ; PARSE COMPLETE
|
---|
| 350 | W !,"INSERTION COMPLETE AT ",C0XPRS
|
---|
| 351 | S C0XDIFF=$$FMDIFF^XLFDT(C0XINS,C0XTRP,2)
|
---|
| 352 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
[1294] | 353 | I C0XDIFF'=0 W !," APPROXIMATELY ",$P(C0XCNT/C0XDIFF,".")," NODES PER SECOND"
|
---|
[1277] | 354 | S C0XEND=$$NOW^XLFDT
|
---|
| 355 | W !," ENDED AT: ",C0XEND
|
---|
| 356 | S C0XDIFF=$$FMDIFF^XLFDT(C0XEND,C0XSTART,2)
|
---|
| 357 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
[1294] | 358 | I C0XDIFF'=0 W !," APPROXIMATELY ",$P(C0XCNT/C0XDIFF,".")," TRIPLES PER SECOND"
|
---|
[1277] | 359 | Q
|
---|
| 360 | ;
|
---|
| 361 | SHOW(ZN) ;
|
---|
[1365] | 362 | I '$D(C0XJOB) S C0XJOB=$J
|
---|
[1366] | 363 | N ZD
|
---|
| 364 | S ZD=$NA(^TMP("MXMLDOM",C0XJOB,1,ZN))
|
---|
| 365 | W ZD,"=",@ZD
|
---|
| 366 | F S ZD=$Q(@ZD) Q:$QS(ZD,4)'=ZN W !,ZD,"=",@ZD
|
---|
| 367 | ;ZWR ^TMP("MXMLDOM",C0XJOB,1,ZN,*)
|
---|
[1277] | 368 | Q
|
---|
| 369 | ;
|
---|
| 370 | ANONS() ; RETURNS AN ANONOMOUS SUBJECT
|
---|
[1371] | 371 | Q "iDPsDPss"_$$LKY9
|
---|
[1277] | 372 | ;
|
---|
| 373 | NEWG(NGRAPH,NMETA) ; CREATES A NEW META GRAPH, MARKS IT AS UNFINISHED
|
---|
| 374 | ; THEN CREATES A NEW GRAPH AND POINTS THE METAGRAPH TO IT
|
---|
| 375 | ; NGRAPH AND NMETA ARE PASSED BY REFERENCE AND ARE THE RETURN
|
---|
| 376 | S NGRAPH="G"_$$LKY9
|
---|
| 377 | S NMETA=NGRAPH_"A"
|
---|
| 378 | Q
|
---|
| 379 | ;
|
---|
| 380 | ADD(ZG,ZS,ZP,ZO,FARY) ; ADD A TRIPLE TO THE TRIPLESTORE. ALL VALUES ARE TEXT
|
---|
| 381 | ; THE FDA IS SET UP BUT THE FILES ARE NOT UPDATED. CALL UPDIE TO COMPLETE
|
---|
| 382 | I '$D(FARY) D ;
|
---|
| 383 | . D INITFARY("C0XFARY")
|
---|
| 384 | . S FARY="C0XFARY"
|
---|
| 385 | D USEFARY(FARY)
|
---|
| 386 | I '$D(C0XCNT) S C0XCNT=0
|
---|
| 387 | N ZNODE
|
---|
| 388 | S ZNODE="N"_$$LKY17
|
---|
| 389 | N ZNARY ; GET READY TO CALL IENOFA
|
---|
| 390 | S ZNARY("ZG",ZG)=""
|
---|
| 391 | S ZNARY("ZS",ZS)=""
|
---|
| 392 | S ZNARY("ZP",ZP)=""
|
---|
| 393 | S ZNARY("ZO",ZO)=""
|
---|
| 394 | D IENOFA(.ZIENS,.ZNARY,FARY) ; RESOLVE/ADD STRINGS
|
---|
| 395 | ;S ZGIEN=$$IENOF(ZG) ; LAYGO TO GET IEN
|
---|
| 396 | ;S ZSIEN=$$IENOF(ZS)
|
---|
| 397 | ;S ZPIEN=$$IENOF(ZP)
|
---|
| 398 | ;S ZOIEN=$$IENOF(ZO)
|
---|
| 399 | ;I $D(C0XFDA) D UPDIE ; ADD THE STRINGS IF NEEDED
|
---|
[1367] | 400 | I '$D(BATCNT) S BATCNT=0
|
---|
[1277] | 401 | S BATCNT=BATCNT+1
|
---|
| 402 | S C0XCNT=C0XCNT+1
|
---|
[1279] | 403 | I $G(BLKLOAD)=1 D ; we are using bulk load
|
---|
| 404 | . S C0XFDA(C0XTFN,BATCNT,.01)=ZNODE
|
---|
| 405 | . S C0XFDA(C0XTFN,BATCNT,.02)=$O(ZIENS("IEN","ZG",""))
|
---|
| 406 | . S C0XFDA(C0XTFN,BATCNT,.03)=$O(ZIENS("IEN","ZS",""))
|
---|
| 407 | . S C0XFDA(C0XTFN,BATCNT,.04)=$O(ZIENS("IEN","ZP",""))
|
---|
| 408 | . S C0XFDA(C0XTFN,BATCNT,.05)=$O(ZIENS("IEN","ZO",""))
|
---|
| 409 | E D ;
|
---|
| 410 | . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.01)=ZNODE
|
---|
| 411 | . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.02)=$O(ZIENS("IEN","ZG",""))
|
---|
| 412 | . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.03)=$O(ZIENS("IEN","ZS",""))
|
---|
[1359] | 413 | . S C0XFDA(C0XTFN,"?+"_ATCNT_",",.04)=$O(ZIENS("IEN","ZP",""))
|
---|
[1279] | 414 | . S C0XFDA(C0XTFN,"?+"_BATCNT_",",.05)=$O(ZIENS("IEN","ZO",""))
|
---|
[1367] | 415 | I '$D(BATMAX) S BATMAX=10000
|
---|
[1277] | 416 | I BATCNT=BATMAX D ; BATCH IS DONE
|
---|
[1279] | 417 | . I $G(BLKLOAD) D ; bulk load
|
---|
| 418 | . . D BULKLOAD(.C0XFDA) ; bulk load the batch
|
---|
| 419 | . E D ; no bulk load
|
---|
| 420 | . . D UPDIE(.C0XFDA)
|
---|
[1277] | 421 | . K C0XFDA
|
---|
| 422 | . S BATCNT=0 ; RESET COUNTER
|
---|
| 423 | ; REMEMBER TO CALL UPDIE WHEN YOU'RE DONE
|
---|
| 424 | Q
|
---|
| 425 | ;
|
---|
| 426 | LKY9() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
|
---|
| 427 | ; UNIQUE NODE AND GRAPH NAMES
|
---|
| 428 | N ZN,ZI
|
---|
| 429 | S ZN=""
|
---|
| 430 | F ZI=1:1:9 D ;
|
---|
| 431 | . S ZN=ZN_$R(10)
|
---|
| 432 | Q ZN
|
---|
| 433 | ;
|
---|
| 434 | LKY17() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
|
---|
| 435 | ; UNIQUE NODE AND GRAPH NAMES
|
---|
| 436 | N ZN,ZI
|
---|
| 437 | S ZN=""
|
---|
| 438 | F ZI=1:1:17 D ;
|
---|
| 439 | . S ZN=ZN_$R(10)
|
---|
| 440 | Q ZN
|
---|
| 441 | ;
|
---|
[1376] | 442 | ; these routines add the string if it is not found
|
---|
| 443 | ;
|
---|
[1277] | 444 | IENOF(ZSTRING,FARY) ; EXTRINSIC WHICH RETURNS THE IEN OF ZS IN THE STRINGS FILE
|
---|
| 445 | I '$D(FARY) D ;
|
---|
| 446 | . D INITFARY("C0XFARY")
|
---|
| 447 | . S FARY="C0XFARY"
|
---|
| 448 | N ZIEN
|
---|
[1349] | 449 | I $G(ZSTRING)="" Q "" ; NO STRING
|
---|
[1277] | 450 | S ZIEN=$O(@C0XSN@("B",ZSTRING,""))
|
---|
| 451 | I ZIEN="" D ;
|
---|
| 452 | . S C0XFDA2(C0XSFN,"+1,",.01)=ZSTRING
|
---|
| 453 | . D UPDIE(.C0XFDA2)
|
---|
| 454 | . S ZIEN=$O(@C0XSN@("B",ZSTRING,""))
|
---|
| 455 | . K C0XFDA2
|
---|
| 456 | Q ZIEN
|
---|
| 457 | ;
|
---|
[1367] | 458 | IENOFA(ZOUTARY,INARY,FARY) ; RESOLVE STRINGS TO IEN IN STRINGS FILE
|
---|
[1277] | 459 | ; OR ADD THEM IF
|
---|
| 460 | ; MISSING. ZINARY AND ZOUTARY ARE PASSED BY REFERENCE
|
---|
| 461 | ; ZINARY LOOKS LIKE ZINARY("VAR","VAL")=""
|
---|
| 462 | ; RETURNS IN ZOUTARY OF THE FORM ZOUTARY("IEN","VAR",IEN)=""
|
---|
| 463 | I '$D(FARY) D ;
|
---|
| 464 | . D INITFARY("C0XFARY")
|
---|
| 465 | . S FARY="C0XFARY"
|
---|
| 466 | K ZOUTARY ; START WITH CLEAN RESULTS
|
---|
| 467 | K C0XFDA2 ; USE A SEPARATE FDA FOR THIS
|
---|
[1372] | 468 | I '$D(C0XVOC) D VOCINIT^C0XUTIL
|
---|
[1367] | 469 | N ZINARY
|
---|
[1277] | 470 | N ZI S ZI=""
|
---|
[1367] | 471 | F S ZI=$O(INARY(ZI)) Q:ZI="" D ;
|
---|
| 472 | . N ZK
|
---|
| 473 | . S ZK=$O(INARY(ZI,""))
|
---|
| 474 | . S ZINARY($$EXT^C0XUTIL(ZI),$$EXT^C0XUTIL(ZK))=""
|
---|
[1277] | 475 | N ZV,ZIEN
|
---|
| 476 | N ZCNT S ZCNT=0
|
---|
| 477 | F S ZI=$O(ZINARY(ZI)) Q:ZI="" D ; LOOK FOR MISSING STRINGS
|
---|
| 478 | . S ZV=$O(ZINARY(ZI,""))
|
---|
[1359] | 479 | . I ZV["^" S ZV=$TR(ZV,"^","|")
|
---|
[1277] | 480 | . I $O(@C0XSN@("B",ZV,""))="" D ;
|
---|
| 481 | . . S ZCNT=ZCNT+1
|
---|
| 482 | . . S C0XFDA2(C0XSFN,"+"_ZCNT_",",.01)=ZV
|
---|
| 483 | I $D(C0XFDA2) D ;
|
---|
| 484 | . D UPDIE(.C0XFDA2) ; ADD MISSING STRINGS
|
---|
| 485 | . K C0XFDA2 ; CLEAN UP
|
---|
| 486 | F S ZI=$O(ZINARY(ZI)) Q:ZI="" D ; NOT GET ALL IENS
|
---|
| 487 | . S ZV=$O(ZINARY(ZI,""))
|
---|
[1359] | 488 | . I ZV["^" S ZV=$TR(ZV,"^","|")
|
---|
[1277] | 489 | . S ZIEN=$O(@C0XSN@("B",ZV,"")) ; THEY SHOULD BE THERE NOW
|
---|
| 490 | . I ZIEN="" D ;
|
---|
| 491 | . . W !,"ERROR ADDING STRING: ",ZV
|
---|
| 492 | . . B
|
---|
| 493 | . S ZOUTARY("IEN",ZI,ZIEN)=""
|
---|
| 494 | Q
|
---|
| 495 | ;
|
---|
[1279] | 496 | BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101
|
---|
| 497 | ; USING GLOBAL SETS INSTEAD OF UPDATE^DIE
|
---|
| 498 | ; QUITS IF FILE IS NOT 172.101
|
---|
| 499 | ; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1
|
---|
| 500 | ; QUITS IF FIRST ENTRY IS NOT IENS 1
|
---|
| 501 | ; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES
|
---|
| 502 | ; ZBFDA IS PASSED BY REFERENCE
|
---|
| 503 | ;
|
---|
| 504 | ; -- reserves a block of iens from file 172.101 by locking the zero node
|
---|
| 505 | ; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3
|
---|
| 506 | ; -- then unlocking to minimize the duration of the lock
|
---|
| 507 | ;
|
---|
| 508 | W !,"USING BULKLOAD"
|
---|
| 509 | I '$D(ZBFDA) Q ; EMPTY FDA
|
---|
| 510 | I $O(ZBFDA(""))'=172.101 Q ; WRONG FILE
|
---|
| 511 | N ZCNT,ZP3,ZP4
|
---|
| 512 | ; -- find the number of nodes to insert
|
---|
| 513 | S ZCNT=$O(ZBFDA(172.101,""),-1)
|
---|
| 514 | I ZCNT="" D Q ;
|
---|
| 515 | . W !,"ERROR IN BULK LOAD - INVALID NODE COUNT"
|
---|
| 516 | . B
|
---|
| 517 | ; -- lock the zero node and reserve a block of iens to insert
|
---|
| 518 | W !,"LOCKING ZERO NODE"
|
---|
| 519 | LOCK +^C0X(101,0)
|
---|
| 520 | S ZP3=$P(^C0X(101,0),U,3)
|
---|
| 521 | S ZP4=$P(^C0X(101,0),U,4)
|
---|
| 522 | S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1
|
---|
| 523 | S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1
|
---|
| 524 | LOCK -^C0X(101,0)
|
---|
| 525 | N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE
|
---|
| 526 | S ZBASE=ZP3 ; the last ien in the file
|
---|
| 527 | W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT
|
---|
| 528 | W !,$$NOW^XLFDT
|
---|
| 529 | S ZI=""
|
---|
| 530 | F S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI="" D ;
|
---|
| 531 | . S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name
|
---|
| 532 | . I ZN="" D BLKERR Q ;
|
---|
| 533 | . S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer
|
---|
| 534 | . I ZG="" D BLKERR Q ;
|
---|
| 535 | . S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer
|
---|
| 536 | . I ZS="" D BLKERR Q ;
|
---|
| 537 | . S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer
|
---|
| 538 | . I ZP="" D BLKERR Q ;
|
---|
| 539 | . S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer
|
---|
| 540 | . I ZO="" D BLKERR Q ;
|
---|
| 541 | . S ZIEN=ZI+ZBASE ; the new ien
|
---|
| 542 | . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node
|
---|
[1349] | 543 | . D INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO)
|
---|
[1279] | 544 | Q
|
---|
| 545 | ;
|
---|
[1349] | 546 | INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO) ; HARD SET THE INDEX FOR ONE ENTRY
|
---|
| 547 | S ^C0X(101,"B",ZN,ZIEN)="" ; the B index
|
---|
| 548 | S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index
|
---|
| 549 | S ^C0X(101,"SPO",ZS,ZP,ZO,ZIEN)=""
|
---|
| 550 | S ^C0X(101,"SOP",ZS,ZO,ZP,ZIEN)=""
|
---|
| 551 | S ^C0X(101,"OPS",ZO,ZP,ZS,ZIEN)=""
|
---|
| 552 | S ^C0X(101,"OSP",ZO,ZS,ZP,ZIEN)=""
|
---|
| 553 | S ^C0X(101,"PSO",ZP,ZS,ZO,ZIEN)=""
|
---|
| 554 | S ^C0X(101,"POS",ZP,ZO,ZS,ZIEN)=""
|
---|
| 555 | S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS,ZIEN)=""
|
---|
| 556 | S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP,ZIEN)=""
|
---|
| 557 | S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO,ZIEN)=""
|
---|
| 558 | S ^C0X(101,"GPOS",ZG,ZP,ZO,ZS,ZIEN)=""
|
---|
| 559 | S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO,ZIEN)=""
|
---|
| 560 | S ^C0X(101,"GSOP",ZG,ZS,ZO,ZP,ZIEN)=""
|
---|
| 561 | Q
|
---|
| 562 | ;
|
---|
| 563 | REINDEX ; REINDEX THE ^C0X(101, TRIPLE STORE
|
---|
| 564 | K ^C0X(101,"B")
|
---|
| 565 | K ^C0X(101,"G")
|
---|
| 566 | K ^C0X(101,"SPO")
|
---|
| 567 | K ^C0X(101,"SOP")
|
---|
| 568 | K ^C0X(101,"OPS")
|
---|
| 569 | K ^C0X(101,"OSP")
|
---|
| 570 | K ^C0X(101,"PSO")
|
---|
| 571 | K ^C0X(101,"POS")
|
---|
| 572 | K ^C0X(101,"GOPS")
|
---|
| 573 | K ^C0X(101,"GOSP")
|
---|
| 574 | K ^C0X(101,"GPSO")
|
---|
| 575 | K ^C0X(101,"GPOS")
|
---|
| 576 | K ^C0X(101,"GSPO")
|
---|
| 577 | K ^C0X(101,"GSOP")
|
---|
| 578 | N ZIEN,ZZ
|
---|
| 579 | S ZIEN=0
|
---|
| 580 | F S ZIEN=$O(^C0X(101,ZIEN)) Q:+ZIEN=0 D ; FOR EACH NODE
|
---|
| 581 | . S ZZ=$G(^C0X(101,ZIEN,0))
|
---|
| 582 | . I ZZ="" D Q ;
|
---|
| 583 | . . W !,"ERROR REINDEXING NODE ",ZI
|
---|
| 584 | . S ZN=$P(ZZ,"^",1)
|
---|
| 585 | . S ZG=$P(ZZ,"^",2)
|
---|
| 586 | . S ZS=$P(ZZ,"^",3)
|
---|
| 587 | . S ZP=$P(ZZ,"^",4)
|
---|
| 588 | . S ZO=$P(ZZ,"^",5)
|
---|
| 589 | . D INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO)
|
---|
| 590 | Q
|
---|
| 591 | ;
|
---|
[1279] | 592 | BLKERR ;
|
---|
[1366] | 593 | W !,"ERROR IN BULK LOAD"
|
---|
| 594 | S C0XERR="ERROR IN BULK LOAD"
|
---|
| 595 | S C0XLOC=ZBFDA(ZI)
|
---|
| 596 | D ^%ZTER ; report the error
|
---|
[1279] | 597 | B
|
---|
| 598 | Q
|
---|
| 599 | ;
|
---|
[1368] | 600 | DELGRAPH(ZGRF,FARY) ; delete a graph from the triplestore
|
---|
| 601 | ; (doesn't delete strings)
|
---|
| 602 | ;
|
---|
| 603 | I '$D(FARY) D ;
|
---|
| 604 | . D INITFARY("C0XFARY")
|
---|
| 605 | . S FARY="C0XFARY"
|
---|
| 606 | D USEFARY(FARY)
|
---|
| 607 | N ZGRAPH
|
---|
| 608 | D TING(.ZGRAPH,ZGRF,FARY)
|
---|
| 609 | I '$D(ZGRAPH) D Q ;
|
---|
| 610 | . W !,"NO TRIPLES IN GRAPH"
|
---|
| 611 | K C0XFDA
|
---|
| 612 | N ZI S ZI=""
|
---|
| 613 | F S ZI=$O(ZGRAPH(ZI)) Q:ZI="" D ;
|
---|
| 614 | . S C0XFDA(C0XTFN,ZI_",",.01)="@"
|
---|
| 615 | D UPDIE(.C0XFDA)
|
---|
| 616 | Q
|
---|
| 617 | ;
|
---|
| 618 | TING(ZRTN,ZGRF,FARY) ; return the iens for graph ZGRF
|
---|
| 619 | ; ZRTN is passed by reference
|
---|
| 620 | I '$D(FARY) D ;
|
---|
| 621 | . D INITFARY("C0XFARY")
|
---|
| 622 | . S FARY="C0XFARY"
|
---|
| 623 | D USEFARY(FARY)
|
---|
| 624 | K ZRTN
|
---|
| 625 | N ZI,ZG S ZI=""
|
---|
| 626 | S ZG=$$IENOF(ZGRF)
|
---|
| 627 | I ZG="" D Q ;
|
---|
| 628 | . W !,"ERROR GRAPH NOT FOUND"
|
---|
| 629 | I '$D(@C0XTN@("G",ZG)) Q ;
|
---|
| 630 | F S ZI=$O(@C0XTN@("G",ZG,ZI)) Q:ZI="" D ;
|
---|
| 631 | . S ZRTN(ZI)=""
|
---|
| 632 | Q
|
---|
| 633 | ;
|
---|
[1294] | 634 | SWUPDIE(ZFDA) ; SWITCH BETWEEN UPDIE AND BULKLOAD
|
---|
| 635 | . I $G(BLKLOAD) D ; bulk load
|
---|
| 636 | . . D BULKLOAD(.ZFDA) ; bulk load the batch
|
---|
| 637 | . E D ; no bulk load
|
---|
| 638 | . . D UPDIE(.ZFDA)
|
---|
| 639 | . K ZFDA
|
---|
| 640 | Q
|
---|
| 641 | ;
|
---|
[1277] | 642 | UPDIE(ZFDA) ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
|
---|
| 643 | ; ZFDA IS PASSED BY REFERENCE
|
---|
| 644 | ;ZWR ZFDA
|
---|
| 645 | ;B
|
---|
| 646 | K ZERR
|
---|
| 647 | D CLEAN^DILF
|
---|
| 648 | D UPDATE^DIE("","ZFDA","","ZERR")
|
---|
| 649 | I $D(ZERR) S ZZERR=ZZERR ; ZZERR DOESN'T EXIST,
|
---|
| 650 | ; INVOKE THE ERROR TRAP IF TASKED
|
---|
| 651 | ;. W "ERROR",!
|
---|
| 652 | ;. ZWR ZERR
|
---|
| 653 | ;. B
|
---|
| 654 | K ZFDA
|
---|
| 655 | Q
|
---|
| 656 | ;
|
---|