grant select on "Oracle"."HR"."DEPARTMENTS" to SPARQL_SELECT;


SPARQL
prefix Oracle: <http://demo.openlinksw.com/schemas/Oracle/> 
create iri class Oracle:departments "http://^{URIQADefaultHost}^/Oracle/departments/DEPARTMENT_ID/%d#this" (in _DEPARTMENT_ID integer not null) . ;


create view "Oracle"."HR"."DEPARTMENTSCount" as select count (*) as cnt from "Oracle"."HR"."DEPARTMENTS"; 
grant select on "Oracle"."HR"."DEPARTMENTSCount" to SPARQL_SELECT; 
drop view "Oracle"."HR"."Oracle__Total"; 
create view "Oracle"."HR"."Oracle__Total" as select (cnt0*cnt1) AS cnt from 
 (select count(*) cnt0 from "Oracle"."HR"."DEPARTMENTS") tb0, 
 (select count(*)+1 as cnt1 from DB.DBA.TABLE_COLS where "TABLE" = 'Oracle.HR.DEPARTMENTS'  and "COLUMN" <> '_IDN') tb1
; 
grant select on "Oracle"."HR"."Oracle__Total" to SPARQL_SELECT; 


SPARQL
prefix Oracle: <http://demo.openlinksw.com/schemas/Oracle/> 
prefix oracle-stat: <http://demo.openlinksw.com/Oracle/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/> 
alter quad storage virtrdf:DefaultQuadStorage 
 from "Oracle"."HR"."DEPARTMENTS" as departments_s
 { 
   create Oracle:qm-departments as graph iri ("http://^{URIQADefaultHost}^/Oracle#")  
    { 
      # Maps from columns of "Oracle.HR.DEPARTMENTS"
      Oracle:departments (departments_s."DEPARTMENT_ID")  a Oracle:DEPARTMENTS ;
      Oracle:department_id departments_s."DEPARTMENT_ID" as Oracle:hr-departments-department_id ;
      Oracle:department_name departments_s."DEPARTMENT_NAME" as Oracle:hr-departments-department_name ;
      Oracle:manager_id departments_s."MANAGER_ID" as Oracle:hr-departments-manager_id ;
      Oracle:location_id departments_s."LOCATION_ID" as Oracle:hr-departments-location_id .

    }
 }

;

SPARQL
prefix Oracle: <http://demo.openlinksw.com/schemas/Oracle/> 
prefix oracle-stat: <http://demo.openlinksw.com/Oracle/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/> 
alter quad storage virtrdf:DefaultQuadStorage 
 from "Oracle"."HR"."DEPARTMENTSCount" as departmentscount_s
 from "Oracle"."HR"."Oracle__Total" as oracle__total_s
 { 
   create Oracle:qm-VoidStatistics as graph iri ("http://^{URIQADefaultHost}^/Oracle#") option (exclusive) 
    { 
      # voID Statistics 
      oracle-stat: a void:Dataset as Oracle:dataset-oracle ; 
       void:sparqlEndpoint <http://demo.openlinksw.com/sparql> as Oracle:dataset-sparql-oracle ; 
      void:statItem oracle-stat:Stat . 
      oracle-stat:Stat a scovo:Item ; 
       rdf:value oracle__total_s.cnt as Oracle:stat-decl-oracle ; 
       scovo:dimension void:numOfTriples . 

      oracle-stat: void:statItem oracle-stat:DEPARTMENTSStat as Oracle:statitem-oracle-departments . 
      oracle-stat:DEPARTMENTSStat a scovo:Item as Oracle:statitem-decl-oracle-departments ; 
      rdf:value departmentscount_s.cnt as Oracle:statitem-cnt-oracle-departments ; 
      scovo:dimension void:numberOfResources as Oracle:statitem-type-1-oracle-departments ; 
      scovo:dimension Oracle:DEPARTMENTS as Oracle:statitem-type-2-oracle-departments .

    }
 }
;



-- Virtual directories for instance data
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule2',
1,
'(/[^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%23this%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule4',
1,
'/Oracle/stat([^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle/stat%%23%%3E+%%3Fo+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle%%23%%3E+WHERE+{+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle/stat%%23%%3E+%%3Fp+%%3Fo+}&format=%U',
vector('*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule6',
1,
'/Oracle/objects/([^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle/objects/%U%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/Oracle%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule1',
1,
'([^#]*)',
vector('path'),
1,
'/describe/?url=http%%3A//^{URIQADefaultHost}^%U%%23this&graph=http%%3A//^{URIQADefaultHost}^/Oracle%%23&distinct=0',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule7',
1,
'/Oracle/stat([^#]*)',
vector('path'),
1,
'/describe/?url=http%%3A//^{URIQADefaultHost}^/Oracle/stat%%23&graph=http%%3A//^{URIQADefaultHost}^/Oracle%%23',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_rule5',
1,
'/Oracle/objects/(.*)',
vector('path'),
1,
'/services/rdf/object.binary?path=%%2FOracle%%2Fobjects%%2F%U&accept=%U',
vector('path', '*accept*'),
null,
null,
2,
null
);
DB.DBA.URLREWRITE_CREATE_RULELIST ( 'oracle_rule_list1', 1, vector ( 'oracle_rule1', 'oracle_rule7', 'oracle_rule5', 'oracle_rule2', 'oracle_rule4', 'oracle_rule6'));
DB.DBA.VHOST_REMOVE (lpath=>'/Oracle');
DB.DBA.VHOST_DEFINE (lpath=>'/Oracle', ppath=>'/', vsp_user=>'dba', is_dav=>0,
is_brws=>0, opts=>vector ('url_rewrite', 'oracle_rule_list1')
);

-- Virtual directories for ontology
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_owl_rule2',
1,
'(/[^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/schemas/Oracle%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
'oracle_owl_rule1',
1,
'([^#]*)',
vector('path'),
1,
'/describe/?url=http://^{URIQADefaultHost}^%U',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE_RULELIST ( 'oracle_owl_rule_list1', 1, vector ( 'oracle_owl_rule1', 'oracle_owl_rule2'));
DB.DBA.VHOST_REMOVE (lpath=>'/schemas/Oracle');
DB.DBA.VHOST_DEFINE (lpath=>'/schemas/Oracle', ppath=>'/', vsp_user=>'dba', is_dav=>0,
is_brws=>0, opts=>vector ('url_rewrite', 'oracle_owl_rule_list1')
);