source: fmts/trunk/p/C0XGET3.m@ 1700

Last change on this file since 1700 was 1609, checked in by Sam Habiel, 12 years ago

Medications: Can now add a fake prescription to the record

File size: 2.5 KB
RevLine 
[1609]1C0XGET3 ; VEN/SMH - Sam's Getters... let's try to make them simple ;2013-02-20 11:50 AM
[1602]2 ;;1.1;FILEMAN TRIPLE STORE;
3 ;
4IEN(N) ; Public $$; Resolved IEN of a stored string such as "rdf:type" in Strings File
[1604]5 I +N=N Q N ; We are given the IEN, just return it back
[1602]6 Q $$IENOF^C0XGET1($$EXT^C0XUTIL(N))
7 ;
8 ;
9 ;
10GOPS1(G,O,P) ; Public $$; Get Subject for A Graph/Object/Predicate combination
11 N S S S=$O(^C0X(101,"GOPS",$$IEN(G),$$IEN(O),$$IEN(P),""))
12 Q:S="" ""
13 Q ^C0X(201,S,0)
14GOPS(R,G,O,P) ; Public Proc; Get Subjects for A Graph/Object/Predicate combination
15 ; R is global style RPC reference
16 N S S S=""
17 F S S=$O(^C0X(101,"GOPS",$$IEN(G),$$IEN(O),$$IEN(P),S)) Q:S="" S @R@(S)=^C0X(201,S,0)
18 QUIT
19ONETYPE1(G,O) ; Public $$; Get Subject for Graph/Object of a specific type
20 ; This is a conveince call to GOPS1 with Predicate="rdf:type"
21 Q $$GOPS1(G,O,"rdf:type")
22ONETYPE(R,G,O) ; Public Proc; Get Subjects for Graph/Object of a specific type
23 ; R is global style RPC reference
24 ; This is a conveince call to GOPS with Predicate="rdf:type"
25 D GOPS(R,G,O,"rdf:type")
26 QUIT
27GSPO1(G,S,P) ; Public $$; Get Object for A Graph/Subject/Predicate combination
[1604]28 ; Supports forward relational navigation for predicates using "." as separator
29 N EP S EP=$P(P,".",2,99) ; Extended Predicate
30 S P=$P(P,".") ; Predicate becomes the first piece
[1602]31 N O S O=$O(^C0X(101,"GSPO",$$IEN(G),$$IEN(S),$$IEN(P),""))
[1604]32 Q:O="" "" ; Another end point for recursion
33 Q:$L(EP) $$GSPO1(G,O,EP) ; if we have an extended predicate, recurse
34 Q ^C0X(201,O,0) ; this is the end point of the recursion.
[1609]35 ;
36GSPO(R,G,S,P) ; Public Proc; Get Objects for a Graph/Subject/Predicate combination
37 ; Supports forward relational navigation for predicates using "." as separator
38 ; R is global style RPC reference
39 ; Extended Predicates are assumed to have only one object
40 ; This routine doesn't process multiple objects for the extended predicate.
41 N EP S EP=$P(P,".",2,99) ; Extended Predicate
42 S P=$P(P,".") ; Predicate becomes the first piece
43 N O S O=""
44 F S O=$O(^C0X(101,"GSPO",$$IEN(G),$$IEN(S),$$IEN(P),O)) Q:O="" D ; For each object
45 . I $L(EP) D ; If we have an extended predicate...
46 . . I EP="*" N P S P="" F S P=$O(^C0X(101,"GSPO",$$IEN(G),$$IEN(O),P)) Q:P="" D ; If all predicates (EP=*) for each predicate
47 . . . S @R@(O,$$NSP^C0XUTIL(P))=$$GSPO1(G,O,P) ; Return (Object, namespaced predicate)=value
48 . . E S @R@(O)=$$GSPO1(G,O,EP) ; If Extended Predicate, resolve the predicate to get ultimate object
49 . E S @R@(O)=^C0X(201,O,0) ; Otherwise, just return the object
50 QUIT
Note: See TracBrowser for help on using the repository browser.