-- Cleanup

SPARQL
CLEAR GRAPH <http://opllinux5.usnet.private:8708/Progress9#>  ;

SPARQL
CLEAR GRAPH <urn:opllinux5.usnet.private:8708:Progress9>  ;


SPARQL
CLEAR GRAPH <urn:Progress9:8708:r2rml> ;

-- Load Mapping Descriptions into a Designated Named Graph (or Internal Virtuoso Document) identified by its IRI

SPARQL

prefix rr: <http://www.w3.org/ns/r2rml#> 
prefix progress9: <http://opllinux5.usnet.private:8708/schemas/progress9/> 
prefix progress9-stat: <http://opllinux5.usnet.private:8708/progress9/stat#> 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
prefix void: <http://rdfs.org/ns/void#> 
prefix scovo: <http://purl.org/NET/scovo#> 
prefix aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

INSERT { GRAPH <urn:Progress9:8708:r2rml> {


<#TriplesMapCustomer> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Customer" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/customer/Cust-Num={Cust-Num}"; rr:class progress9:Customer; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cust-num ] ; rr:objectMap [ rr:column "Cust-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:country ] ; rr:objectMap [ rr:column "Country" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:name ] ; rr:objectMap [ rr:column "Name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:address ] ; rr:objectMap [ rr:column "Address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:address2 ] ; rr:objectMap [ rr:column "Address2" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:city ] ; rr:objectMap [ rr:column "City" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:state ] ; rr:objectMap [ rr:column "State" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:postal-code ] ; rr:objectMap [ rr:column "Postal-Code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:contact ] ; rr:objectMap [ rr:column "Contact" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:phone ] ; rr:objectMap [ rr:column "Phone" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:sales-rep ] ; rr:objectMap [ rr:column "Sales-Rep" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:credit-limit ] ; rr:objectMap [ rr:column "Credit-Limit" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:balance ] ; rr:objectMap [ rr:column "Balance" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:terms ] ; rr:objectMap [ rr:column "Terms" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:discount ] ; rr:objectMap [ rr:column "Discount" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:comments ] ; rr:objectMap [ rr:column "Comments" ]; ] .

<#TriplesMapInvoice> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Invoice" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/invoice/Invoice-Num={Invoice-Num}"; rr:class progress9:Invoice; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:invoice-num ] ; rr:objectMap [ rr:column "Invoice-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cust-num ] ; rr:objectMap [ rr:column "Cust-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:invoice-date ] ; rr:objectMap [ rr:column "Invoice-Date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:amount ] ; rr:objectMap [ rr:column "Amount" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:total-paid ] ; rr:objectMap [ rr:column "Total-Paid" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:adjustment ] ; rr:objectMap [ rr:column "Adjustment" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:order-num ] ; rr:objectMap [ rr:column "Order-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:ship-charge ] ; rr:objectMap [ rr:column "Ship-Charge" ]; ] .

<#TriplesMapItem> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Item" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/item/Item-num={Item-num}"; rr:class progress9:Item; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:item-num ] ; rr:objectMap [ rr:column "Item-num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:item-name ] ; rr:objectMap [ rr:column "Item-Name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:price ] ; rr:objectMap [ rr:column "Price" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:on-hand ] ; rr:objectMap [ rr:column "On-hand" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:allocated ] ; rr:objectMap [ rr:column "Allocated" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:re-order ] ; rr:objectMap [ rr:column "Re-Order" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:on-order ] ; rr:objectMap [ rr:column "On-Order" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cat-page ] ; rr:objectMap [ rr:column "Cat-Page" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cat-description ] ; rr:objectMap [ rr:column "Cat-Description" ]; ] .

<#TriplesMapOrder> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Order" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/order/Order-num={Order-num}"; rr:class progress9:Order; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:order-num ] ; rr:objectMap [ rr:column "Order-num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cust-num ] ; rr:objectMap [ rr:column "Cust-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:order-date ] ; rr:objectMap [ rr:column "Order-Date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:ship-date ] ; rr:objectMap [ rr:column "Ship-Date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:promise-date ] ; rr:objectMap [ rr:column "Promise-Date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:carrier ] ; rr:objectMap [ rr:column "Carrier" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:instructions ] ; rr:objectMap [ rr:column "Instructions" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:po ] ; rr:objectMap [ rr:column "PO" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:terms ] ; rr:objectMap [ rr:column "Terms" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:sales-rep ] ; rr:objectMap [ rr:column "Sales-Rep" ]; ] .

<#TriplesMapOrder-Line> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Order-Line" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/order_line/Order-num={Order-num}/Line-num={Line-num}"; rr:class progress9:Order_Line; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:order-num ] ; rr:objectMap [ rr:column "Order-num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:line-num ] ; rr:objectMap [ rr:column "Line-num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:item-num ] ; rr:objectMap [ rr:column "Item-num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:price ] ; rr:objectMap [ rr:column "Price" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:qty ] ; rr:objectMap [ rr:column "Qty" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:discount ] ; rr:objectMap [ rr:column "Discount" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:extended-price ] ; rr:objectMap [ rr:column "Extended-Price" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:backorder ] ; rr:objectMap [ rr:column "Backorder" ]; ] .

<#TriplesMapRef-Call> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Ref-Call" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/ref_call/Call-Num={Call-Num}"; rr:class progress9:Ref_Call; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:call-num ] ; rr:objectMap [ rr:column "Call-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:cust-num ] ; rr:objectMap [ rr:column "Cust-Num" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:call-date ] ; rr:objectMap [ rr:column "Call-Date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:sales-rep ] ; rr:objectMap [ rr:column "Sales-Rep" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:parent ] ; rr:objectMap [ rr:column "Parent" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:txt ] ; rr:objectMap [ rr:column "Txt" ]; ] .

<#TriplesMapSalesrep> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "Salesrep" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/salesrep/Sales-Rep={Sales-Rep}"; rr:class progress9:Salesrep; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:sales-rep ] ; rr:objectMap [ rr:column "Sales-Rep" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:rep-name ] ; rr:objectMap [ rr:column "Rep-Name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:region ] ; rr:objectMap [ rr:column "Region" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@1> ] ; rr:objectMap [ rr:column "Month-Quota@1" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@2> ] ; rr:objectMap [ rr:column "Month-Quota@2" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@3> ] ; rr:objectMap [ rr:column "Month-Quota@3" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@4> ] ; rr:objectMap [ rr:column "Month-Quota@4" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@5> ] ; rr:objectMap [ rr:column "Month-Quota@5" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@6> ] ; rr:objectMap [ rr:column "Month-Quota@6" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@7> ] ; rr:objectMap [ rr:column "Month-Quota@7" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@8> ] ; rr:objectMap [ rr:column "Month-Quota@8" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@9> ] ; rr:objectMap [ rr:column "Month-Quota@9" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@10> ] ; rr:objectMap [ rr:column "Month-Quota@10" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@11> ] ; rr:objectMap [ rr:column "Month-Quota@11" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant <http://opllinux5.usnet.private:8708/schemas/progress9/:month-quota@12> ] ; rr:objectMap [ rr:column "Month-Quota@12" ]; ] .

<#TriplesMapState> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "progress9" ; rr:tableOwner "isports" ; rr:tableName "State" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://opllinux5.usnet.private:8708/progress9/state/State={State}"; rr:class progress9:State; rr:graph <http://opllinux5.usnet.private:8708/progress9#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:state ] ; rr:objectMap [ rr:column "State" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:state-name ] ; rr:objectMap [ rr:column "State-Name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant progress9:region ] ; rr:objectMap [ rr:column "Region" ]; ] .

}
} ;

-- Next command is commented out due to fact that it produces urn: unsupported error
-- DB.DBA.R2RML_GENERATE_LINKED_VIEW('urn:Progress9:8708:r2rml', 'http://opllinux5.usnet.private:8708/Progress9#', 0);
-- DB.DBA.R2RML_GENERATE_LINKED_VIEW('urn:Progress9:8708:r2rml', 'http://opllinux5.usnet.private:8708/Progress9#', 0);
-- THIS WORKS for generating triples for Virtual RDF Views Graph: DB.DBA.R2RML_GENERATE_LINKED_VIEW('http://kingsley.idehen.net/DAV/home/kidehen/Public/R2RML%20Demos/Progress9-8708-r2rml.ttl',
--'http://opllinux5.usnet.private:8708/Progress9#', 0);
-- THIS WORKS for generating triples for both Virtual & Physical RDF Views Graph: DB.DBA.R2RML_GENERATE_LINKED_VIEW('http://kingsley.idehen.net/DAV/home/kidehen/Public/R2RML%20Demos/Progress9-8708-r2rml.ttl',
-- 'urn:opllinux5.usnet.private:8708:Progress9', 1);
-- Generate & Execute Virtual RDF Views Script, hence the use of EXEC()

EXEC ('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G ('urn:Progress9:8708:r2rml'));

-- Test RDF generated Virtual RDF Views

SPARQL
SELECT SAMPLE(?s) AS ?sample COUNT(1) AS ?count ?o
FROM <http://opllinux5.usnet.private:8708/Progress9#> 
WHERE {?s a ?o}
GROUP BY ?o
ORDER BY DESC(?count)
LIMIT 50 ;

-- Sync Triples from Virtual RDF Views Graph to Physical RDF Views Graph

RDF_VIEW_SYNC_TO_PHYSICAL ('http://opllinux5.usnet.private:8708/Progress9#', 1, 'urn:opllinux5.usnet.private:8708:Progress9');

-- Test Phyical RDF Views sync'd from Virtual RDF Views Graph

SPARQL
SELECT SAMPLE(?s) AS ?sample COUNT(1) AS ?count ?o
FROM <urn:opllinux5.usnet.private:8708:Progress9> 
WHERE {?s a ?o}
GROUP BY ?o
ORDER BY DESC(?count)
LIMIT 50 ;
