¶ VADß EThis file consists of binary data and should not be touched by hands!¶ STICKERß ;
if (lt (sys_stat ('st_dbms_ver'), '06.02.3130')) { result ('ERROR', 'The RDB2RDF package requires server version 06.02.3130 or greater'); signal ('FATAL', 'The conductor package requires server version 06.02.3130 or greater'); }
"DB"."DBA"."VAD_LOAD_SQL_FILE"('/DAV/VAD/rdb2rdf/ovl.sql', 1, 'report', 1);
"DB"."DBA"."VAD_LOAD_SQL_FILE"('/DAV/VAD/rdb2rdf/r2rml.sql', 1, 'report', 1);
"DB"."DBA"."VAD_LOAD_SQL_FILE"('/DAV/VAD/rdb2rdf/r2rml_validation_metas.sql', 1, 'report', 1);
;
¶ rdb2rdf/ovl.sqlß :ð-- $Id: ovl.sql,v 1.6 2012/04/23 09:09:10 ivan Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
DB.DBA.XML_SET_NS_DECL ( 'OVL' , 'http://www.openlinksw.com/schemas/OVL#' , 2)
;
create function DB.DBA.OVL_NODE_NAME (in source_g_iri varchar, in node_iid varchar)
{
if (isstring (node_iid) and bit_and (__box_flags (node_iid), 1))
node_iid := iri_to_id (node_iid);
else if (node_iid is null)
return null;
if (isiri_id (node_iid))
{
declare bnlabel varchar;
declare bnrow integer;
if (is_named_iri_id(node_iid))
return '<' || id_to_iri (node_iid) || '>';
bnlabel := (sparql define input:storage "" select ?l where { graph `iri(?:source_g_iri)` { `iri(?:node_iid)` virtrdf:bnode-label ?l }});
if (bnlabel is not null)
return '_:' || bnlabel;
bnrow := (sparql define input:storage "" select ?r where { graph `iri(?:source_g_iri)` { `iri(?:node_iid)` virtrdf:bnode-row ?r }});
if (bnrow is not null)
return 'bnode at row ' || cast (bnrow as varchar);
return id_to_iri (node_iid);
}
return 'literal ' || cast (node_iid as varchar);
}
;
create function DB.DBA.OVL_EXEC_SPARQL (in source_g_iri varchar, in extras_g_iri varchar, in rules_g_iri varchar, in qry varchar) returns any
{
declare full_qry, state, msg varchar;
declare qry_params, rset, metas any;
state := '00000';
full_qry := concat ('sparql define input:storage "" define input:default-graph-uri <', source_g_iri, '> define input:default-graph-uri <', extras_g_iri, '> define input:named-graph-uri <', rules_g_iri, '> ', qry);
-- qry_params := vector ('source_g_iri', source_g_iri, 'extras_g_iri', extras_g_iri, 'rules_g_iri', rules_g_iri);
qry_params := vector (extras_g_iri);
-- dbg_obj_princ ('DB.DBA.OVL_EXEC_SPARQL () executes ', qry);
exec (full_qry, state, msg, qry_params, 1000, metas, rset);
if (state <> '00000')
{
-- dbg_obj_princ ('DB.DBA.OVL_EXEC_SPARQL () signals ', state, msg);
return vector (vector (null, 'Error', 'OVL validation has signalled ' || state || ': ' || msg || ' on query ' || qry));
}
-- dbg_obj_princ ('DB.DBA.OVL_EXEC_SPARQL () makes the result ', rset);
if (not isvector (metas) or 3 <> length (metas[0]) or ('severity' <> metas[0][1][0]))
return vector ();
return rset;
}
;
create function DB.DBA.OVL_DERIVE_EXTRAS (in source_g_iri varchar, in extras_g_iri varchar, in rules_g_iri varchar) returns any
{
declare baserules, err_agg any;
declare old_extras_count, new_extras_count integer;
vectorbld_init (err_agg);
baserules := vector (
' select ?s, ("Error") as ?severity,
"Nothing to validate?!" as ?message
where {
optional { ?s ?p ?o }
filter (!bound (?s)) } limit 1',
' select ?s, ("Error") as ?severity,
"No graph with validation data?!" as ?message
where {
optional { graph ?rs { ?s ?p ?o } }
filter (!bound (?s)) } limit 1',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> is obsolete. ", bif:coalesce(str(?prop_cmt), ""))) as ?message
where {
?s ?prop ?o .
graph ?rs {
?prop a OVL:ObsoleteProperty .
optional { ?prop rdfs:comment ?prop_cmt } } }
group by ?s ?o order by asc (str(?s)) asc (str(?prop))
',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> is not know (typo in its IRI?)")) as ?message
where {
?s ?prop ?o .
graph ?rs { ?prefx a OVL:ClosedWorldPrefix }
optional { graph ?rs { ?prop a ?t } }
filter (!bound (?t))
filter (bif:starts_with (str (?prop), str(?prefx))) }
group by ?s ?o order by asc (str(?s)) asc (str(?prop))
',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has domain <", str (?prop_dom), "> but the actual type of its subject is <", str (?t), ">")) as ?message
where {
?s a ?t ; ?prop ?o .
graph ?rs {
?prop a rdf:Property ; rdfs:domain ?prop_dom .
optional { ?prop_dom OVL:superClassOf ?prop_subdom } .
optional { ?t OVL:superClassOf ?sub_of_t filter (?sub_of_t = ?prop_dom) } .
filter (!bound (?prop_subdom))
filter (!bound (?sub_of_t)) }
filter (?t != ?prop_dom) }
group by ?s ?t ?prop ?prop_dom order by asc (str(?s)) asc (str(?prop))
',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has domain <", str (?prop_dom), "> (with subtypes) but the actual type of its subject is <", str (?t), "> is not a subtype of the domain")) as ?message
where {
?s a ?t ; ?prop ?o .
graph ?rs {
?prop a rdf:Property ; rdfs:domain ?prop_dom . ?prop_dom OVL:superClassOf ?prop_subdom
optional { ?prop_dom OVL:superClassOf ?t1 . filter (?t1 = ?t) } }
filter (!bound (?t1)) }
group by ?s ?t ?prop ?prop_dom order by asc(str(?s)) asc (str(?prop))
',
' insert in graph iri(??) { ?prop_obj a ?range ; OVL:info `bif:concat("Node <", str (?prop_obj), "> gets type <", str (?range), "> because it is in range of <", str (?prop), ">")` }
where {
graph ?rs { ?prop a rdf:Property, OVL:InferTypeFromRange ; rdfs:range ?range }
?s ?prop ?prop_obj . optional { ?prop_obj a ?t }
filter (!bound(?t))
filter (!isliteral (?prop_obj)) }
' );
old_extras_count := 0;
next_round:
foreach (varchar qry in baserules) do
{
declare new_errs any;
new_errs := DB.DBA.OVL_EXEC_SPARQL (source_g_iri, extras_g_iri, rules_g_iri, qry);
if (length (new_errs))
{
vectorbld_concat_acc (err_agg, new_errs);
goto no_more_rounds;
}
}
new_extras_count := (sparql select count (*) where { graph `iri(?:extras_g_iri)` { ?s ?p ?o }});
if (new_extras_count <= old_extras_count)
goto no_more_rounds;
old_extras_count := new_extras_count;
goto next_round;
no_more_rounds:
vectorbld_final (err_agg);
return err_agg;
}
;
create function DB.DBA.OVL_VALIDATE_READONLY (in source_g_iri varchar, in extras_g_iri varchar, in rules_g_iri varchar) returns any
{
declare baserules, err_agg any;
baserules := vector (
-- Checks for ranges:
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has range <", str (?prop_range), "> but the actual type of its object <", str (?o), "> is <", str (?t), ">")) as ?message
where {
?s ?prop ?o . ?o a ?t .
graph ?rs {
?prop a rdf:Property ; rdfs:range ?prop_range .
optional { ?prop_range OVL:superClassOf ?prop_subrange }
filter (!bound (?prop_subrange)) }
filter (?t != ?prop_range) }
group by ?s ?t ?prop ?prop_range ?o order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has range <", str (?prop_range), "> but the actual type of its object <", str (?o), "> is not specified")) as ?message
where {
?s ?prop ?o . optional { ?o a ?t } . filter (!isliteral(?o)) . filter (!bound(?t))
graph ?rs {
?prop a rdf:Property ; rdfs:range ?prop_range .
optional { ?prop_range OVL:superClassOf ?prop_subrange }
optional { ?prop_range OVL:enumOf ?enum_val }
filter (!bound (?prop_subrange))
filter (!bound (?enum_val))
filter (?prop_range != xsd:anyURI)
filter (isIRI(?o) && (?prop_range = rdfs:Class)) } }
group by ?s ?t ?prop ?prop_range ?o order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has range <", str (?prop_range), "> but the actual type of its object \'", str (?o), "\' is <", str (?prop_range), ">")) as ?message
where {
?s ?prop ?o . filter (isLiteral(?o))
graph ?rs {
?prop a rdf:Property ; rdfs:range ?prop_range .
optional { ?prop_range OVL:enumOf ?enum_val }
filter (!bound (?enum_val))
filter (datatype (?o) != ?prop_range) } }
group by ?s ?prop ?prop_range ?o order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has enum <", str (?prop_range), "> as range but the actual value is ", str (?enum_val) )) as ?message
where {
?s ?prop ?enum_val
graph ?rs {
?prop a rdf:Property ; rdfs:range ?prop_range .
?prop_range OVL:enumOf ?enum_val_1 . }
optional { graph ?rs { ?prop_range OVL:enumOf ?enum_val_2 } . FILTER (?enum_val_2 = ?enum_val) }
filter (!bound (?enum_val_2)) }
group by ?s ?prop ?prop_range ?o order by asc (str(?s)) asc (str(?prop))',
-- Checks for cardinalities:
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> is mandatory but not specified")) as ?message
where {
graph ?rs {
?prop a rdf:Property ; rdfs:domain ?prop_dom ; owl:minCardinality ?minc . filter (?minc > 0)
optional { ?prop_dom OVL:superClassOf ?prop_subdom } }
{ ?s a ?prop_dom } union { ?s a ?prop_subdom }
optional { ?s ?prop ?o }
filter (!bound(?o)) }
group by ?s ?prop order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Warning") as ?severity,
(bif:concat ("Property <", str(?prop), "> has suspiciously many values (", str(count(?o)), " values, whereas ", str(min(?maxgoodc)), " is more than enough)")) as ?message
where {
graph ?rs {
?prop a rdf:Property ; OVL:maxGoodCard ?maxgoodc . optional { ?prop owl:maxCardinality ?maxc } }
?s ?prop ?o }
group by ?s ?prop
having ((count(?o) > min (?maxgoodc)) && (!count (?maxc) || (count(?o) <= min (?maxc))))
order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Property <", str(?prop), "> has prohibitively many values (", str(count(?o)), " values, max ", str(min (?maxc)), " allowed)")) as ?message
where {
graph ?rs {
?prop a rdf:Property ; owl:maxCardinality ?maxc }
?s ?prop ?o }
group by ?s ?prop
having (count(?o) > min (?maxc))
order by asc (str(?s)) asc (str(?prop))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Properties <", str(?prop1), "> and <", str(?prop2), "> are mutualy exclusive for type <", str(?prop_dom), ">")) as ?message
where {
graph ?rs {
?prop_dom OVL:typeRestriction [ OVL:mutuallyExclusivePredicates ?prop1, ?prop2 ] . filter (str(?prop1) < str(?prop2))
optional { ?prop_dom OVL:superClassOf ?prop_subdom } }
{ ?s a ?prop_dom } union { ?s a ?prop_subdom }
?s ?prop1 ?o1 ; ?prop2 ?o2 }
group by ?s ?prop1 ?prop2
order by asc (str(?s)) asc (str(?prop1)) asc (str(?prop2))',
' select ?s, ("Error") as ?severity,
(bif:concat ("Subject of type <", str(?prop_dom), "> does not have any of predicates of a mandatory group")) as ?message
where {
graph ?rs {
?prop_dom OVL:typeRestriction ?restr .
?restr OVL:needSomeOfPredicates ?pred .
optional { ?prop_dom OVL:superClassOf ?prop_subdom } }
{ ?s a ?prop_dom } union { ?s a ?prop_subdom }
optional { ?s ?pred ?o } }
group by ?s ?prop_dom ?restr
having (count (?o) = 0)
order by asc (str(?s)) asc (str(?prop_dom))' );
vectorbld_init (err_agg);
foreach (varchar qry in baserules) do
{
declare new_errs any;
new_errs := DB.DBA.OVL_EXEC_SPARQL (source_g_iri, extras_g_iri, rules_g_iri, qry);
-- dbg_obj_princ ('OVL_VALIDATE_READONLY after ', qry, ': ', new_errs);
vectorbld_concat_acc (err_agg, new_errs);
}
for (sparql define input:storage ""
select ?qry
where { graph `iri (?:rules_g_iri)` { ?pred OVL:inconsistencyOfPredicate ?qry } }
order by asc (str(?qry)) ) do
{
declare new_errs any;
new_errs := DB.DBA.OVL_EXEC_SPARQL (source_g_iri, extras_g_iri, rules_g_iri, "qry");
-- dbg_obj_princ ('OVL_VALIDATE_READONLY after ', "qry", ': ', new_errs);
vectorbld_concat_acc (err_agg, new_errs);
}
vectorbld_final (err_agg);
return err_agg;
}
;
create procedure DB.DBA.OVL_VALIDATE (in source_g_iri varchar, in rules_g_iri varchar)
{
declare extras_g_iri varchar;
declare err_agg, res any;
declare SUBJ, SEVERITY, MESSAGE varchar;
result_names (SUBJ, SEVERITY, MESSAGE);
extras_g_iri := 'http://virtuoso.openlinksw.com/tmp/OVL/' || DB.DBA.R2RML_MD5_IRI (vector (source_g_iri, rules_g_iri));
sparql clear graph iri (?:extras_g_iri);
commit work;
vectorbld_init (err_agg);
res := DB.DBA.OVL_DERIVE_EXTRAS (source_g_iri, extras_g_iri, rules_g_iri);
if (length (res))
{
vectorbld_concat_acc (err_agg, res);
goto final_report;
}
res := DB.DBA.OVL_VALIDATE_READONLY (source_g_iri, extras_g_iri, rules_g_iri);
vectorbld_concat_acc (err_agg, res);
final_report:
vectorbld_final (err_agg);
if (length (err_agg))
{
for (sparql define input:storage "" select ?s, ?info where { graph `iri(?:extras_g_iri)` { ?s OVL:info ?info }} order by 1 2) do
{
result (DB.DBA.OVL_NODE_NAME (source_g_iri, "s"), 'Info', "info");
}
}
else
{
declare infocount integer;
result (NULL, 'Info', 'No errors or warnings found');
infocount := ((sparql define input:storage "" select count (1) where { graph `iri(?:extras_g_iri)` { ?s OVL:info ?info }}));
if (infocount > 0)
{
result (NULL, 'Info', sprintf ('The validator has made %d small additions to the R2RML source', infocount));
result (NULL, 'Info', 'The added triples are saved in graph <' || extras_g_iri || '> for reference');
}
}
foreach (any err in err_agg) do
{
result (DB.DBA.OVL_NODE_NAME (source_g_iri, err[0]), err[1], err[2]);
}
}
;
¶ rdb2rdf/r2rml.sqlß «Ë--
-- Converter from R2RML graph to SPARQL-BI declaration of RDF Views.
--
-- $Id: r2rml.sql,v 1.23 2012/04/20 10:07:26 mitko Exp $
--
-- The implemented version of the spec is "Overview.html,v 1.59 2011/05/24 19:22:21 rcygania2 Exp"
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
DB.DBA.XML_SET_NS_DECL ( 'rr' , 'http://www.w3.org/ns/r2rml#' , 2)
;
DB.DBA.XML_SET_NS_DECL ( 'exa' , 'http://example.com/ns#' , 1)
;
EXEC_STMT ('drop type DB.DBA.R2RML_MAP', 0)
;
create type DB.DBA.R2RML_MAP as (
graph_iid IRI_ID, --!< IRI_ID of a graph with R2RML description in question. Set by constructor, constant after that
triplesmap_metas_cache any, --!< Dictionary with rr:TriplesMap IRI_IDs as keys and metadata vectors of tables/SQLQueries as values
-- Metadata vector is (('TABLE'/'QUERY', schema, owner, text), (column_name, (NULL, column_name, column_metas), ...))
declared_jsos any, --!< Dictionary with IRI_IDs of all JSOs that have the 'create' source code written into codegen_ses
declared_ns_prefixes any, --!< Dictionary with namespace IRIs as keys and theird declared prefixes as values
declared_tmap_aliases any, --!< Dictionary with TripleMap IRI_IDs as keys and aliases of tables/queries as values
default_constg IRI_ID, --!< Default constant graph of quad map, if not a variable and if single value
prev_p_md5 varchar, --!< Checksum of last printed predicate of QM declaration
codegen_ses any --!< String output for the generated SPARQL text
) self as ref
constructor method R2RML_MAP (in graph_iid IRI_ID),
method R2RML_DEST_IID_OF_THING (in src_iid IRI_ID, in depth_limit integer) returns IRI_ID,
method R2RML_ADD_NS_PREFIX_TO_CACHE (in iri varchar) returns integer,
method R2RML_FILL_NS_PREFIXES_CACHE () returns integer,
method R2RML_IRI_ID_AS_QNAME (in iid any) returns varchar,
method R2RML_FILL_TRIPLESMAP_METAS_CACHE () returns integer,
method R2RML_TRIPLESMAP_TABLE_REPORT_NAME (in triplesmap_iid IRI_ID) returns varchar,
method R2RML_GET_COL_DESC (in triplesmap_iid IRI_ID, in col_name varchar) returns any, --!< Returns vector (triplesmap_iid, triplesmap_metas[0], column_metas)
method R2RML_GEN_CONST_FLD (in constfld any, in termtype varchar, in dt IRI_ID, in lang varchar) returns integer,
method R2RML_GEN_CREATE_IOL_CLASS_OR_REF (in mode integer, in triplesmap_iid IRI_ID, in src_template varchar, in termtype varchar, in dt IRI_ID, in lang varchar) returns IRI_ID,
method R2RML_GEN_FLD (in constfld any, in triplesmap_iid IRI_ID, in col varchar, in src_template varchar, in termtype varchar, in dt IRI_ID, in lang varchar) returns integer,
method R2RML_VALIDATE () returns any,
method R2RML_MAKE_QM_IMPL_IOL_CLASSES () returns any,
method R2RML_MAKE_QM_IMPL_CHILDS (in needs_inner_g_field integer) returns any,
method R2RML_MAKE_QM_IMPL_REL_PO (in tmap IRI_ID, in tmap2 IRI_ID, in tmap2sfld IRI_ID, in pofld IRI_ID, in pconst IRI_ID, in pfld IRI_ID, in rofld IRI_ID) returns any,
method R2RML_MAKE_QM_IMPL_PLAIN_PO (in tmap IRI_ID, in pofld IRI_ID, in pconst IRI_ID, in pfld IRI_ID, in oconst any, in ofld IRI_ID) returns any,
method R2RML_MAKE_QM (in storage_iid IRI_ID, in rdfview_iid IRI_ID) returns any
;
create constructor method R2RML_MAP (in graph_iid IRI_ID) for DB.DBA.R2RML_MAP
{
self.graph_iid := graph_iid;
self.codegen_ses := null;
self.declared_ns_prefixes := dict_new (31);
}
;
create function DB.DBA.R2RML_MD5_IRI (inout box any) returns varchar
{
declare hex, md5, res varchar;
declare i integer;
-- return sprintf ('%U', serialize (box));
md5 := md5_box (box);
res := space (32);
hex := '0123456789abcdef';
for (i := 0; i < 16; i := i + 1)
{
res[i*2] := hex[md5[i]/16];
res[i*2+1] := hex[mod(md5[i],16)];
}
return res;
}
;
create method R2RML_DEST_IID_OF_THING (in src_iid IRI_ID, in depth_limit integer := 10) for DB.DBA.R2RML_MAP
{
declare parts_agg any;
if (src_iid is null)
return NULL;
if (src_iid < min_bnode_iri_id())
return src_iid;
if (0 > depth_limit)
signal ('R2RML', 'Cyclic dependency in R2RML data or an abnormal nesting depth');
depth_limit := depth_limit - 1;
vectorbld_init (parts_agg);
for (sparql define input:storage "" define output:valmode "LONG"
select ?p ?o where { graph `iri(?:self.graph_iid)` { `iri(?:src_iid)` ?p ?o } } ) do
{
if (isiri_id ("o"))
vectorbld_agg (parts_agg, self.R2RML_DEST_IID_OF_THING ("o", depth_limit));
else
vectorbld_agg (parts_agg, md5_box ("o"));
}
vectorbld_final (parts_agg);
gvector_sort (parts_agg, 1, 0, 0);
return 'r2rml:virt01-' || DB.DBA.R2RML_MD5_IRI (parts_agg);
}
;
create function R2RML_NS_OF_IRI (in iri varchar) returns varchar
{
declare irilen, patchedlen, taillen integer;
declare patched varchar;
if (iri = '')
return null;
if (subseq (iri, 0, 2) = '_:')
return null; -- 0123456789
if (subseq (iri, 0, 9) = 'nodeID://')
return null;
patched := sprintf ('%U', iri);
irilen := length (iri);
patchedlen := length (patched);
for (taillen := 0; taillen < irilen; taillen := taillen + 1)
{
if (iri[irilen-(1+taillen)] <> patched[patchedlen-(1+taillen)])
goto found_diff;
}
found_diff:
if (taillen >= irilen)
return NULL;
return subseq (iri, 0, irilen-taillen);
}
;
create method R2RML_ADD_NS_PREFIX_TO_CACHE (in iri varchar) returns integer for DB.DBA.R2RML_MAP
{
declare ns varchar;
declare prefx varchar;
ns := DB.DBA.R2RML_NS_OF_IRI (iri);
if (ns is null)
return 0;
prefx := dict_get (self.declared_ns_prefixes, ns, null);
if (prefx is not null)
return 0;
prefx := coalesce (__xml_get_ns_prefix (ns, 3), sprintf ('ns%d', dict_size (self.declared_ns_prefixes)));
dict_put (self.declared_ns_prefixes, ns, prefx);
http ('prefix ' || prefx || ': <' || ns || '>\n', self.codegen_ses);
}
;
create method R2RML_FILL_NS_PREFIXES_CACHE () returns integer for DB.DBA.R2RML_MAP
{
for (sparql define input:storage ""
select distinct ?i where { graph `iri(?:self.graph_iid)` {
{
?s ?p ?i .
filter (?p in (rr:graph, rr:subject, rr:predicate, rr:object))
}
union
{
?i a ?t .
filter (?t in (rr:GraphMap, rr:SubjectMap, rr:PredicateObjectMap, rr:PredicateMap, rr:ObjectMap))
}
filter (isIRI (?i)) } }
order by asc (str (?i)) ) do
{
self.R2RML_ADD_NS_PREFIX_TO_CACHE ("i");
}
return dict_size (self.declared_ns_prefixes);
}
;
create method R2RML_IRI_ID_AS_QNAME (in iid any) returns varchar for DB.DBA.R2RML_MAP
{
declare iri, ns varchar;
if (isstring (iid))
{
iri := iid;
if (subseq (iri, 0, 2) = '_:')
return iri; -- 0123456789
if (subseq (iri, 0, 9) = 'nodeID://')
return '_:' || subseq (iri, 9);
}
else
{
if (iid >= min_bnode_iri_id ())
{
if (iid >= min_named_bnode_iri_id ())
return '<' || id_to_iri (iid) || '>';
return '_:' || subseq (id_to_iri (iid), 9);
}
iri := id_to_iri (iid);
}
ns := DB.DBA.R2RML_NS_OF_IRI (iri);
if (ns is not null)
{
declare prefx varchar;
prefx := dict_get (self.declared_ns_prefixes, ns, null);
if (prefx is not null)
return prefx || ':' || subseq (iri, length (ns));
}
return '<' || iri || '>';
}
;
create method R2RML_FILL_TRIPLESMAP_METAS_CACHE () returns integer for DB.DBA.R2RML_MAP
{
self.triplesmap_metas_cache := dict_new (11);
for (sparql define input:storage ""
select distinct ?triplesmap ?q ?ts ?to ?tn where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap .
optional { ?triplesmap rr:logicalTable ?ltbl }
{ ?lt rr:sqlQuery ?q }
UNION
{ ?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts } }
filter (?lt in (?triplesmap, ?ltbl)) } } ) do
{
declare triplesmap_iid IRI_ID;
declare text_to_prepare, stat, msg varchar;
declare exec_metas, all_metas any;
declare colctr, colcount integer;
triplesmap_iid := iri_to_id ("triplesmap");
if (dict_get (self.triplesmap_metas_cache, triplesmap_iid, NULL) is not null)
signal ('R2RML', 'Multiple declaration of data source for <' || "triplesmap" || '>');
all_metas := vector (null, null);
if ("q" is not null)
{
all_metas[0] := vector ('QUERY', null, null, "q");
text_to_prepare := "q";
}
else
{
all_metas[0] := vector ('TABLE', coalesce ("ts", 'DB'), coalesce ("to", 'DBA'), "tn");
text_to_prepare := sprintf ('select * from "%I"."%I"."%I"', all_metas[0][1], all_metas[0][2], all_metas[0][3]);
}
stat := '00000';
exec_metadata (text_to_prepare, stat, msg, exec_metas);
if (stat <> '00000')
signal ('R2RML', 'Error ' || stat || ' in declaration of data source for <' || "triplesmap" || '>: ' || msg);
if (exec_metas[1] <> 1)
signal ('R2RML', 'The declaration of data source for <' || "triplesmap" || '> is a potentially dangerous DML');
exec_metas := exec_metas[0];
colcount := length (exec_metas);
all_metas[1] := make_array (colcount*2, 'any');
for (colctr := 0; colctr < colcount; colctr := colctr + 1)
{
all_metas[1][colctr*2] := exec_metas[colctr][0];
all_metas[1][colctr*2+1] := exec_metas[colctr];
}
dict_put (self.triplesmap_metas_cache, triplesmap_iid, all_metas);
}
return dict_size (self.triplesmap_metas_cache);
}
;
create function DB.DBA.R2RML_MAIN_KEY_EXISTS (in q varchar, in u varchar, in n varchar, in case_prec integer := 0)
{
if (case_prec)
return (select top 1 KEY_TABLE from DB.DBA.SYS_KEYS
where KEY_IS_MAIN and 0 = casemode_strcmp (sprintf ('%s.%s.%s', coalesce (q, 'DB'), coalesce (u, 'DBA'), n), KEY_TABLE) );
return (select top 1 KEY_TABLE from DB.DBA.SYS_KEYS
where KEY_IS_MAIN and sprintf ('%s.%s.%s', coalesce (q, 'DB'), coalesce (u, 'DBA'), n) = KEY_TABLE );
}
;
grant execute on DB.DBA.R2RML_MAIN_KEY_EXISTS to public
;
create function DB.DBA.R2RML_KEY_COLUMN_EXISTS (in q varchar, in u varchar, in n varchar, in c varchar, in case_prec integer := 0)
{
if (case_prec)
return (select top 1 "COLUMN" from DB.DBA.SYS_KEY_COLUMNS
where 0 = casemode_strcmp (sprintf ('%s.%s.%s', coalesce (q, 'DB'), coalesce (u, 'DBA'), n), "TABLE")
and 0 = casemode_strcmp (c, "COLUMN") );
return (select top 1 "COLUMN" from DB.DBA.SYS_KEY_COLUMNS
where sprintf ('%s.%s.%s', coalesce (q, 'DB'), coalesce (u, 'DBA'), n) = "TABLE"
and c = "COLUMN" );
}
;
grant execute on DB.DBA.R2RML_KEY_COLUMN_EXISTS to public
;
create method R2RML_TRIPLESMAP_TABLE_REPORT_NAME (in triplesmap_iid IRI_ID) returns varchar for DB.DBA.R2RML_MAP
{
declare all_metas any;
all_metas := dict_get (self.triplesmap_metas_cache, triplesmap_iid, null);
if (dict_get (self.triplesmap_metas_cache, triplesmap_iid, NULL) is null)
return '(Undeclared data source <' || id_to_iri (triplesmap_iid) || '>)';
for (sparql define input:storage ""
select ?q ?tn ?to where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap .
filter (?triplesmap = iri(?:triplesmap_iid))
optional { ?triplesmap rr:logicalTable ?ltbl }
{ ?lt rr:sqlQuery ?q }
UNION
{ ?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts } }
filter (?lt in (?triplesmap, ?ltbl)) } } ) do
{
if ("q" is not null)
return 'query in TriplesMap <' || id_to_iri (triplesmap_iid) || '>';
if ("to" is null)
return 'table ' || "tn";
else
return 'table DB.' || "to" || '.' || "tn";
}
}
;
create method R2RML_GET_COL_DESC (in triplesmap_iid IRI_ID, in col_name varchar) returns any for DB.DBA.R2RML_MAP
{
declare all_metas, res any;
all_metas := dict_get (self.triplesmap_metas_cache, triplesmap_iid, null);
if (dict_get (self.triplesmap_metas_cache, triplesmap_iid, NULL) is null)
signal ('R2RML', 'Undeclared data source <' || id_to_iri (triplesmap_iid) || '>');
res := get_keyword (col_name, all_metas[1], null);
if (res is null)
signal ('R2RML', 'Data source <' || id_to_iri (triplesmap_iid) || '> does not produce column "' || col_name || '"');
res := vector (triplesmap_iid, all_metas[0], res);
-- dbg_obj_princ ('R2RML_GET_COL_DESC (', triplesmap_iid, col_name, ') returns ', res);
return res;
}
;
create function DB.DBA.R2RML_SPLIT_TEMPLATE (in strg varchar) returns any
{
declare splitlbra, parts any;
declare ctr, len, rbra_idx integer;
splitlbra := split_and_decode (strg, 0, '\0\0{');
len := length (splitlbra);
parts := make_array ((len * 2) - 1, 'any');
if (strchr (splitlbra[0], '}') is not null)
signal ('R2RML', 'Syntax error in template: first "}" is before first "{"');
parts[0] := splitlbra[0];
for (ctr := 1; ctr < len; ctr := ctr + 1)
{
rbra_idx := strchr (splitlbra[ctr], '}');
if (rbra_idx is null)
signal ('R2RML', 'Syntax error in template: "{" without matching "}"');
parts[ctr*2-1] := subseq (splitlbra[ctr], 0, rbra_idx);
parts[ctr*2] := subseq (splitlbra[ctr], rbra_idx+1);
}
return parts;
}
;
create method R2RML_GEN_CONST_FLD (in constfld any, in termtype varchar, in dt IRI_ID, in lang varchar) returns integer for DB.DBA.R2RML_MAP
{
if ((termtype in ('IRI', 'BlankNode'))
or (__tag (constfld) = __tag of IRI_ID)
or (isstring (constfld) and bit_and (__box_flags (constfld), 1)) )
{
http (self.R2RML_IRI_ID_AS_QNAME (constfld), self.codegen_ses);
return 0;
}
if (__tag (constfld) = __tag of RDF_BOX)
{
http ('"', self.codegen_ses);
http_escape (__rdf_strsqlval (constfld), 11, self.codegen_ses, 1, 1);
http ('"', self.codegen_ses);
if (dt is null)
{
declare dt_twobytes integer;
dt_twobytes := rdf_box_type (constfld);
if (257 <> dt_twobytes)
dt := iri_to_id ((select RDT_QNAME from DB.DBA.RDF_DATATYPE where RDT_TWOBYTE = dt_twobytes));
}
if (lang is null)
{
declare lang_twobytes integer;
lang_twobytes := rdf_box_lang (constfld);
if (257 <> lang_twobytes)
lang := (select RL_ID from DB.DBA.RDF_LANGUAGE where RL_TWOBYTE = lang_twobytes);
}
}
else if (__tag of XML = __tag (constfld))
{
http ('"', self.codegen_ses);
http_escape (serialize_to_UTF8_xml (constfld), 11, self.codegen_ses, 1, 1);
http ('"', self.codegen_ses);
}
else if (isstring (constfld) or (__tag of XML = __tag (constfld)))
{
http ('"', self.codegen_ses);
http_escape (constfld, 11, self.codegen_ses, 1, 1);
http ('"', self.codegen_ses);
}
else
{
http ('"', self.codegen_ses);
http_escape (cast (constfld as varchar), 11, self.codegen_ses, 1, 1);
http ('"', self.codegen_ses);
if (dt is null)
dt := iri_to_id (__xsd_type (constfld, null));
}
if (dt is not null)
{
http ('^^', self.codegen_ses);
self.R2RML_IRI_ID_AS_QNAME (dt);
}
else if (isstring (lang))
{
http ('@', self.codegen_ses);
http (lang, self.codegen_ses);
}
return 0;
}
;
create function DB.DBA.R2RML_XSD_TYPE_OF_DTP (in dtp integer)
{
if (__tag of datetime = dtp) return 'http://www.w3.org/2001/XMLSchema#dateTime';
if (__tag of date = dtp) return 'http://www.w3.org/2001/XMLSchema#date';
if (__tag of time = dtp) return 'http://www.w3.org/2001/XMLSchema#time';
if (dtp in (__tag of varchar, __tag of nvarchar, __tag of long varchar, __tag of long nvarchar)) return NULL;
if (__tag of integer = dtp) return 'http://www.w3.org/2001/XMLSchema#integer';
if (__tag of double precision = dtp) return 'http://www.w3.org/2001/XMLSchema#double';
if (__tag of numeric = dtp) return 'http://www.w3.org/2001/XMLSchema#double';
if (__tag of real = dtp) return 'http://www.w3.org/2001/XMLSchema#float';
if (230) return 'http://www.w3.org/2001/XMLSchema#XMLLiteral';
if (238) return 'http://www.openlinksw.com/schemas/virtrdf#Geometry';
return 'http://www.w3.org/2001/XMLSchema#any';
}
;
create method R2RML_GEN_CREATE_IOL_CLASS_OR_REF (in mode integer, in triplesmap_iid IRI_ID, in src_template varchar, in termtype varchar, in dt IRI_ID, in lang varchar) returns IRI_ID for DB.DBA.R2RML_MAP
{
declare format_string, class_iri varchar;
declare format_ses, format_parts, col_descs, argtypes, class_digest any;
declare argctr, argcount integer;
-- dbg_obj_princ ('R2RML_GEN_CREATE_IOL_CLASS_OR_REF (', mode, triplesmap_iid, src_template, termtype, dt, lang, ')');
if (termtype = 'BlankNode')
{
src_template := '_:r2rml' || src_template;
termtype := 'IRI';
}
format_parts := DB.DBA.R2RML_SPLIT_TEMPLATE (src_template);
argcount := (length (format_parts) - 1) / 2;
if (0 = argcount) -- constant written as a template for some reason.
{
if (2 = mode) -- i.e., CREATE IRI CLASS or CREATE LITERAL CLASS statement
self.R2RML_GEN_CONST_FLD (src_template, termtype, dt, lang);
return null;
}
argtypes := make_array (argcount, 'any');
col_descs := make_array (argcount, 'any');
format_ses := string_output ();
for (argctr := 0; argctr < argcount; argctr := argctr + 1)
{
declare col_name, coltype, col_fmt varchar;
declare col_desc any;
col_name := format_parts[argctr * 2 + 1];
col_desc := self.R2RML_GET_COL_DESC (triplesmap_iid, col_name);
col_descs[argctr] := col_desc;
if (col_desc is null)
signal ('R2RML', sprintf ('The column "%s" is used in template "%s" but not in result set of <%s>', col_name, src_template, id_to_iri (triplesmap_iid)));
coltype := col_desc[2];
argtypes[argctr] := vector (coltype[1], coltype[4]);
col_fmt := case
when (coltype[1] in (__tag of date, __tag of datetime, __tag of datetime)) then '%D'
when (coltype[1] in (__tag of integer)) then '%d'
when (coltype[1] in (__tag of real, __tag of double precision, __tag of numeric)) then '%g'
when (coltype[1] in (__tag of varchar, __tag of nvarchar)) then
case (termtype) when 'Literal' then '%s' else '%U' end
else
signal ('R2RML',
sprintf ('Unsupported column type %d, column %s of %s',
coltype[1], col_desc[2][0], self.R2RML_TRIPLESMAP_TABLE_REPORT_NAME (triplesmap_iid) ) )
end;
http_escape (replace (format_parts[argctr * 2], '%', '%%'), 11, format_ses);
http (col_fmt, format_ses);
}
http_escape (replace (format_parts[argcount * 2], '%', '%%'), 11, format_ses);
format_string := string_output_string (format_ses);
class_digest := vector (termtype, format_string, argtypes, dt, lang);
class_iri := 'r2rml:virt02-' || DB.DBA.R2RML_MD5_IRI (class_digest);
if (1 = mode) -- i.e., CREATE IRI CLASS or CREATE LITERAL CLASS statement
goto create_iol_class;
if (2 = mode) -- i.e., quad map value in form class_iri (args)
goto print_field;
signal ('R2RML', 'iternal error: bad mode');
create_iol_class:
if (dict_get (self.declared_jsos, class_iri, null) is null)
{
http ('create ' || termtype || ' class <' || class_iri || '> "' || format_string || '" (', self.codegen_ses);
for (argctr := 0; argctr < argcount; argctr := argctr + 1)
{
declare argdtp integer;
argdtp := argtypes[argctr][0];
if (argctr > 0)
http (', ', self.codegen_ses);
http ('in ' || format_parts[argctr * 2 + 1] || ' ' ||
case (argdtp)
when __tag of date then 'date'
when __tag of time then 'time'
when __tag of datetime then 'datetime'
when __tag of integer then 'integer'
when __tag of real then 'real'
when __tag of double precision then 'double precision'
when __tag of numeric then 'numeric'
when __tag of varchar then 'varchar'
when __tag of nvarchar then 'nvarchar'
else 'any' end ||
case (argtypes[argctr][0]) when 0 then ' not null' else '' end,
self.codegen_ses );
}
http (') ', self.codegen_ses);
if (dt is not null or lang is not null)
{
http ('option (', self.codegen_ses);
if (dt is not null)
{
http ('datatype ', self.codegen_ses);
http (self.R2RML_IRI_ID_AS_QNAME (dt), self.codegen_ses);
}
if (lang is not null)
{
http ('lang "', self.codegen_ses);
http_escape (lang, 11, self.codegen_ses);
http ('"', self.codegen_ses);
}
http (') ', self.codegen_ses);
}
http ('.\n', self.codegen_ses);
dict_put (self.declared_jsos, class_iri, class_digest);
}
return iri_to_id (class_iri);
print_field:
http ('<' || class_iri || '> (', self.codegen_ses);
for (argctr := 0; argctr < argcount; argctr := argctr + 1)
{
declare col_desc any;
if (argctr > 0)
http (', ', self.codegen_ses);
col_desc := col_descs[argctr]; -- col_desc is a vector (triplesmap_iid, all_metas[0], (NULL, column_name, column_metas));
-- dbg_obj_princ ('R2RML_GEN_CREATE_IOL_CLASS_OR_REF(): desc #', argctr, ' is ', col_desc);
http (dict_get (self.declared_tmap_aliases, col_desc[0], null), self.codegen_ses);
http ('."', self.codegen_ses);
http_escape (col_desc[2][0], 11, self.codegen_ses);
http ('"', self.codegen_ses);
}
http (')', self.codegen_ses);
return iri_to_id (class_iri);
}
;
create method R2RML_GEN_FLD (in constfld any, in triplesmap_iid IRI_ID, in col varchar, in src_template varchar, in termtype varchar, in dt IRI_ID, in lang varchar) returns integer for DB.DBA.R2RML_MAP
{
if (src_template is not null)
self.R2RML_GEN_CREATE_IOL_CLASS_OR_REF (2, triplesmap_iid, src_template, termtype, dt, lang);
else if (col is not null)
{
if ((termtype <> 'Literal') or (dt is not null) or (lang is not null))
self.R2RML_GEN_CREATE_IOL_CLASS_OR_REF (2, triplesmap_iid, '{' || col || '}', termtype, dt, lang);
else
{
declare col_desc any;
col_desc := self.R2RML_GET_COL_DESC (triplesmap_iid, col);
http (dict_get (self.declared_tmap_aliases, col_desc[0], null), self.codegen_ses);
http (sprintf ('."%I"', col), self.codegen_ses);
}
}
else if (constfld is not null)
return self.R2RML_GEN_CONST_FLD (constfld, termtype, dt, lang);
else
signal ('R2RML', 'FLD without const, col or src_template');
return 0;
}
;
create method R2RML_MAKE_QM_IMPL_IOL_CLASSES () returns any for DB.DBA.R2RML_MAP
{
foreach (varchar dflttt in vector ('IRI', 'Literal')) do
{
for (sparql define input:storage ""
select ?triplesmap ?fldmap ?template ?termtype ?dt ?lang
where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap .
{ ?triplesmap rr:subjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:predicateObjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:subjectMap ?fldmap }
union
{ ?triplesmap rr:predicateObjectMap [ rr:predicateMap ?fldmap ] }
union
{ ?triplesmap rr:predicateObjectMap [ rr:objectMap ?fldmap ] }
?fldmap rr:template ?template .
optional { ?fldmap rr:termtype ?termtype . }
optional { ?fldmap rr:datatype ?dt . }
optional { ?fldmap rr:language ?lang . }
} } ) do
{
self.R2RML_GEN_CREATE_IOL_CLASS_OR_REF (1, iri_to_id ("triplesmap"), "template", coalesce (cast ("termtype" as varchar), dflttt), iri_to_id ("dt"), "lang");
}
}
for (sparql define input:storage ""
select ?triplesmap ?fldmap ?col ?termtype
where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap .
{ ?triplesmap rr:subjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:predicateObjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:subjectMap ?fldmap }
union
{ ?triplesmap rr:predicateObjectMap [ rr:predicateMap ?fldmap ] }
?fldmap rr:column ?col .
optional { ?fldmap rr:termtype ?termtype . }
} } ) do
{
self.R2RML_GEN_CREATE_IOL_CLASS_OR_REF (1, iri_to_id ("triplesmap"), '{' || "col" || '}', coalesce (cast ("termtype" as varchar), 'IRI'), null, null);
}
for (sparql define input:storage ""
select ?triplesmap ?fldmap ?col ?termtype ?dt ?lang
where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap .
?triplesmap rr:predicateObjectMap [ rr:objectMap ?fldmap ] .
?fldmap rr:column ?col .
optional { ?fldmap rr:termtype ?termtype . }
optional { ?fldmap rr:datatype ?dt . }
optional { ?fldmap rr:language ?lang . } } } ) do
{
if ((("termtype" is not null) and ("termtype" <> 'Literal')) or ("dt" is not null) or ("lang" is not null))
self.R2RML_GEN_CREATE_IOL_CLASS_OR_REF (1, iri_to_id ("triplesmap"), '{' || "col" || '}', coalesce ("termtype", 'Literal'), iri_to_id ("dt"), "lang");
}
}
;
create method R2RML_MAKE_QM_IMPL_REL_PO (in tmap IRI_ID, in tmap2 IRI_ID, in tmap2sfld IRI_ID, in pofld IRI_ID, in pconst IRI_ID, in pfld IRI_ID, in rofld IRI_ID) returns any for DB.DBA.R2RML_MAP
{
declare p_md5 varchar;
declare where_is_opened integer;
-- dbg_obj_princ ('R2RML_MAKE_QM: cross from ', "tmap", ' to ', "tmap2" );
for (sparql define input:storage "" define output:valmode "LONG"
select ?constp, ?consto, ?ocol, ?otmpl, ?ott
where { graph `iri(?:self.graph_iid)` {
{ `iri(?:pofld)` rr:predicate ?constp . filter (?constp = iri(?:pconst)) }
union
{ `iri(?:pfld)` rr:constant ?constp }
{ `iri(?:tmap2)` rr:subject ?consto }
union
{ `iri(?:tmap2sfld)` rr:constant ?consto }
union
{ `iri(?:tmap2sfld)` rr:column ?ocol }
union
{ `iri(?:tmap2sfld)` rr:template ?otmpl }
optional { `iri(?:tmap2sfld)` rr:termtype ?ott }
} }
order by 1 2 3 4 5) do
{
p_md5 := md5_box (vector (__rdf_strsqlval ("constp"), null, null));
if (self.prev_p_md5 is null or self.prev_p_md5 <> p_md5)
{
if (self.prev_p_md5 is not null)
{
http (' ;\n', self.codegen_ses);
self.prev_p_md5 := null;
}
http (' ', self.codegen_ses);
self.R2RML_GEN_FLD ("constp", tmap, NULL, NULL, 'IRI', null, null);
http (' ', self.codegen_ses);
self.prev_p_md5 := p_md5;
}
else
http (',\n ', self.codegen_ses);
self.R2RML_GEN_FLD ("consto", tmap2, __rdf_strsqlval("ocol"), __rdf_strsqlval("otmpl"), coalesce (__rdf_strsqlval("ott"), 'IRI'), NULL, NULL);
where_is_opened := 0;
for (sparql define input:storage ""
select ?child ?parent
where { graph `iri(?:self.graph_iid)` {
`iri(?:rofld)` rr:joinCondition [ rr:child ?child ; rr:parent ?parent ] } }
order by 1 2) do
{
self.R2RML_GET_COL_DESC (tmap, "child");
self.R2RML_GET_COL_DESC (tmap2, "parent");
http (case (where_is_opened) when 0 then ' where ((' else ') and (' end, self.codegen_ses);
http (sprintf ('^{%s.}^."%I" = ^{%s.}^."%I"',
dict_get (self.declared_tmap_aliases, tmap), "child",
dict_get (self.declared_tmap_aliases, tmap2), "parent" ),
self.codegen_ses);
where_is_opened := 1;
}
if (where_is_opened)
http ('))', self.codegen_ses);
}
}
;
create method R2RML_MAKE_QM_IMPL_PLAIN_PO (in tmap IRI_ID, in pofld IRI_ID, in pconst IRI_ID, in pfld IRI_ID, in oconst any, in ofld IRI_ID) returns any for DB.DBA.R2RML_MAP
{
declare p_md5 varchar;
for (sparql define input:storage "" define output:valmode "LONG"
select ?constp, ?pcol, ?ptmpl, ?consto, ?ocol, ?otmpl, ?ott, ?odatatype, ?lang
where { graph `iri(?:self.graph_iid)` {
{ `iri(?:pofld)` rr:predicate ?constp . filter (?constp = iri(?:pconst)) }
union
{ `iri(?:pfld)` rr:constant ?constp }
union
{ `iri(?:pfld)` rr:column ?pcol }
union
{ `iri(?:pfld)` rr:template ?ptmpl }
{ `iri(?:pofld)` rr:object ?consto . filter (?consto = iri(?:oconst)) }
union
{ `iri(?:ofld)` rr:constant ?consto }
union
{ `iri(?:ofld)` rr:column ?ocol }
union
{ `iri(?:ofld)` rr:template ?otmpl }
optional { `iri(?:ofld)` rr:termtype ?ott }
optional { `iri(?:ofld)` rr:datatype ?odatatype }
optional { `iri(?:ofld)` rr:language ?olang }
} }
order by 1 2 3 4 5 6 7 8 9) do
{
p_md5 := md5_box (vector (__rdf_strsqlval("constp"), __rdf_strsqlval("pcol"), __rdf_strsqlval("ptmpl")));
if (self.prev_p_md5 is null or self.prev_p_md5 <> p_md5)
{
if (self.prev_p_md5 is not null)
{
http (' ;\n', self.codegen_ses);
self.prev_p_md5 := null;
}
http (' ', self.codegen_ses);
self.R2RML_GEN_FLD ("constp", tmap, __rdf_strsqlval("pcol"), __rdf_strsqlval("ptmpl"), 'IRI', null, null);
http (' ', self.codegen_ses);
self.prev_p_md5 := p_md5;
}
else
http (',\n ', self.codegen_ses);
self.R2RML_GEN_FLD ("consto", tmap, __rdf_strsqlval("ocol"), __rdf_strsqlval("otmpl"), coalesce (__rdf_strsqlval("ott"), 'Literal'), "odatatype", __rdf_strsqlval("lang"));
}
}
;
create method R2RML_MAKE_QM_IMPL_CHILDS (in needs_inner_g_field integer) returns any for DB.DBA.R2RML_MAP
{
declare prev_g_md5, prev_s_md5 any;
-- For each combination of mapclasses and graph
prev_g_md5 := prev_s_md5 := null;
self.prev_p_md5 := null;
for (sparql define input:storage "" define output:valmode "LONG"
select ?constg, ?gcol, ?gtmpl, ?tmap, ?sfld, ?consts, ?scol, ?stmpl, ?stt, ?sclass, ?pofld, ?pconst, ?pfld, ?oconst, ?ofld, ?tmap2, ?tmap2sfld
where { graph `iri(?:self.graph_iid)` {
?tmap a rr:TriplesMap .
{ ?tmap rr:subject ?consts }
union
{
?tmap rr:subjectMap ?sfld .
{ ?sfld rr:constant ?consts }
union
{ ?sfld rr:column ?scol }
union
{ ?sfld rr:template ?stmpl }
optional { ?sfld rr:termtype ?stt }
}
{
?sfld rr:class ?sclass .
}
union
{
?tmap rr:predicateObjectMap ?pofld .
{ ?pofld rr:predicate ?pconst }
union
{ ?pofld rr:predicateMap ?pfld }
{ ?pofld rr:object ?oconst }
union
{ ?pofld rr:objectMap ?ofld
optional {
?ofld rr:parentTriplesMap ?tmap2 .
?tmap2 a rr:TriplesMap ;
rr:subjectMap ?tmap2sfld . }
}
}
optional {
{ ?gcontainer rr:graph ?constg . }
union
{
?gcontainer rr:graphMap ?gfld .
{ ?gfld rr:constant ?constg }
union
{ ?gfld rr:column ?gcol }
union
{ ?gfld rr:template ?gtmpl } }
filter (?gcontainer in (?sfld, ?pofld)) }
} }
order by 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) do
{
declare s_md5, p_md5 varchar;
-- dbg_obj_princ ('R2RML_MAKE_QM: g is ', "constg", "gcol", "gtmpl", '; tmap is ', "tmap", '; s is ', "sfld", "consts", "scol", "stmpl", "stt", "sclass", '; po is ', "pconst", "pfld", ' and ', "oconst", "ofld");
if (needs_inner_g_field)
{
declare g_md5 any;
g_md5 := md5_box (vector (coalesce ("constg", self.default_constg), __rdf_strsqlval("gcol"), __rdf_strsqlval("gtmpl")));
if (prev_g_md5 is null or prev_g_md5 <> g_md5)
{
if (prev_g_md5 is not null)
{
http (' . }\n', self.codegen_ses);
prev_g_md5 := prev_s_md5:= null;
self.prev_p_md5 := null;
}
http (' graph ', self.codegen_ses);
self.R2RML_GEN_FLD (coalesce ("constg", self.default_constg), "tmap", __rdf_strsqlval("gcol"), __rdf_strsqlval("gtmpl"), 'IRI', null, null);
http (' {\n', self.codegen_ses);
prev_g_md5 := g_md5;
}
}
s_md5 := md5_box (vector (__rdf_strsqlval("consts"), __rdf_strsqlval("scol"), __rdf_strsqlval("stmpl"), __rdf_strsqlval("stt")));
if (prev_s_md5 is null or prev_s_md5 <> s_md5)
{
if (prev_s_md5 is not null)
{
http (' .\n', self.codegen_ses);
prev_s_md5 := null;
self.prev_p_md5 := null;
}
http (' ', self.codegen_ses);
self.R2RML_GEN_FLD (__rdf_strsqlval("consts"), "tmap", __rdf_strsqlval("scol"), __rdf_strsqlval("stmpl"), coalesce (__rdf_strsqlval("stt"), 'IRI'), null, null);
http ('\n', self.codegen_ses);
prev_s_md5 := s_md5;
}
if ("sclass" is not null)
{
p_md5 := 'rdf:type';
if (self.prev_p_md5 is null or self.prev_p_md5 <> p_md5)
{
if (self.prev_p_md5 is not null)
{
http (' ;\n', self.codegen_ses);
self.prev_p_md5 := null;
}
http (' a ', self.codegen_ses);
self.prev_p_md5 := p_md5;
}
else
http (',\n ', self.codegen_ses);
self.R2RML_GEN_FLD ("sclass", "tmap", null, null, 'IRI', null, null);
}
else if ("tmap2" is not null)
{
self.R2RML_MAKE_QM_IMPL_REL_PO ("tmap", "tmap2", "tmap2sfld", "pofld", "pconst", "pfld", "ofld");
}
else
{
self.R2RML_MAKE_QM_IMPL_PLAIN_PO ("tmap", "pofld", "pconst", "pfld", "oconst", "ofld");
}
skip_the_quad_map: ;
}
if (needs_inner_g_field)
{
if (prev_g_md5 is not null)
{
http (' . }\n', self.codegen_ses);
prev_s_md5 := self.prev_p_md5 := null;
}
}
else
http (' }\n', self.codegen_ses);
}
;
create method R2RML_MAKE_QM (in storage_iid IRI_ID := null, in rdfview_iid IRI_ID := null) returns any for DB.DBA.R2RML_MAP
{
declare const_graph_count, var_graph_count, needs_inner_g_field integer;
declare iter, iter_tmap, iter_metas any;
if (storage_iid is null)
storage_iid := iri_to_id ('http://www.openlinksw.com/schemas/virtrdf#DefaultQuadStorage');
if (rdfview_iid is null)
rdfview_iid := self.graph_iid;
if (self.codegen_ses is null)
self.codegen_ses := string_output ();
self.R2RML_ADD_NS_PREFIX_TO_CACHE (id_to_iri (storage_iid));
self.R2RML_ADD_NS_PREFIX_TO_CACHE (id_to_iri (rdfview_iid));
self.R2RML_FILL_NS_PREFIXES_CACHE ();
self.declared_jsos := dict_new (31);
self.declared_tmap_aliases := dict_new (11);
for (sparql define input:storage "" define output:valmode "LONG"
select ?triplesmap
where { graph `iri(?:self.graph_iid)` {
?triplesmap a rr:TriplesMap } } ) do
{
dict_put (self.declared_tmap_aliases, "triplesmap", sprintf ('tbl%d', dict_size (self.declared_tmap_aliases)));
}
if (0 = self.R2RML_FILL_TRIPLESMAP_METAS_CACHE ())
signal ('R2RML', 'No valid instances of TriplesMap, hence nothing to do');
self.R2RML_MAKE_QM_IMPL_IOL_CLASSES ();
const_graph_count := (sparql define input:storage ""
select count(distinct ?constg)
where { graph `iri(?:self.graph_iid)` {
?tmap a rr:TriplesMap .
optional {
{ ?tmap rr:subjectMap ?smap }
union
{ ?tmap rr:predicateObjectMap ?pomap } }
{ ?gcontainer rr:graph ?constg }
union
{
?gcontainer rr:graphMap ?gfld .
?gfld rr:constant ?constg }
filter (?gcontainer in (?smap, ?pomap)) } } );
var_graph_count := (sparql define input:storage ""
select count(distinct bif:concat (str(?tmap), ' ', ?c, ' ', ?t))
where { graph `iri(?:self.graph_iid)` {
?tmap a rr:TriplesMap .
optional {
{ ?tmap rr:subjectMap ?smap }
union
{ ?tmap rr:predicateObjectMap ?pomap } }
?gcontainer rr:graphMap ?gfld .
{ ?gfld rr:column ?c }
union { ?gfld rr:template ?t }
filter (?gcontainer in (?smap, ?pomap)) } } );
-- dbg_obj_princ ('const_graph_count = ', const_graph_count, ', var_graph_count = ', var_graph_count);
http ('alter quad storage ' || self.R2RML_IRI_ID_AS_QNAME (storage_iid) || '\n', self.codegen_ses);
iter := self.triplesmap_metas_cache;
for (dict_iter_rewind (iter); dict_iter_next (iter, iter_tmap, iter_metas); )
{
declare tos_alias varchar;
tos_alias := dict_get (self.declared_tmap_aliases, iter_tmap, null);
if ('TABLE' = iter_metas[0][0])
http ('from "' || iter_metas[0][1] || '"."' || iter_metas[0][2] || '"."' || iter_metas[0][3] || '" as ' || tos_alias || '\n', self.codegen_ses);
else
http ('from sqlquery (' || iter_metas[0][3] || ') as ' || tos_alias || '\n', self.codegen_ses);
}
http (' {\n', self.codegen_ses);
http (' create ' || self.R2RML_IRI_ID_AS_QNAME (rdfview_iid) || ' as', self.codegen_ses);
if (self.default_constg is null)
self.default_constg := iri_to_id (sprintf ('http://example.com/r2rml?graph=%U', id_to_iri(self.graph_iid)));
if ((const_graph_count + var_graph_count) <= 1)
{
http (' graph ', self.codegen_ses);
if (0 = var_graph_count)
{
declare constg IRI_ID;
constg := (sparql define input:storage "" define output:valmode "LONG"
select ?constg
where { graph `iri(?:self.graph_iid)` {
?tmap a rr:TriplesMap .
optional {
{ ?tmap rr:subjectMap ?smap }
union
{ ?tmap rr:predicateObjectMap ?pomap } }
{ ?gcontainer rr:graph ?constg }
union
{
?gcontainer rr:graphMap ?gfld .
?gfld rr:constant ?constg }
filter (?gcontainer in (?smap, ?pomap)) } } );
if (constg is null)
constg := self.default_constg;
self.R2RML_GEN_FLD (constg, null, null, null, 'IRI', null, null);
http (' option (soft exclusive)', self.codegen_ses);
}
else
{
for (sparql define input:storage ""
select ?tmap, ?c, ?t
where { graph `iri(?:self.graph_iid)` {
?tmap a rr:TriplesMap .
optional {
{ ?tmap rr:subjectMap ?smap }
union
{ ?tmap rr:predicateObjectMap ?pomap } }
?gcontainer rr:graphMap ?gfld .
{ ?gfld rr:column ?c }
union { ?gfld rr:template ?t }
filter (?gcontainer in (?smap, ?pomap)) } } limit 1 ) do
{
self.R2RML_GEN_FLD (null, iri_to_id ("tmap"), "c", "t", 'IRI', null, null);
}
}
needs_inner_g_field := 0;
}
else
needs_inner_g_field := 1;
http (' {\n', self.codegen_ses);
self.R2RML_MAKE_QM_IMPL_CHILDS (needs_inner_g_field);
http (' }\n', self.codegen_ses);
}
;
create function R2RML_MAKE_QM_FROM_G (in g varchar, in tgt_graph varchar := null) returns varchar
{
declare m R2RML_MAP;
m := DB.DBA.R2RML_MAP (iri_to_id (g));
m.default_constg := iri_to_id (tgt_graph);
m.R2RML_MAKE_QM (null, null);
return string_output_string (m.codegen_ses);
}
;
create function R2RML_TEST (in g varchar)
{
declare m R2RML_MAP;
m := DB.DBA.R2RML_MAP (iri_to_id (g));
m.R2RML_MAKE_QM (null, null);
-- return string_output_string (m.codegen_ses);
declare _text varchar;
declare _strings any;
declare _slen, _sctr any;
result_names (_text);
_text := string_output_string (m.codegen_ses);
_strings := split_and_decode (_text,0,'\0\0\n');
_slen := length (_strings);
_sctr := 0;
while (_sctr < _slen)
{
result (aref (_strings, _sctr));
_sctr := _sctr+1;
}
}
;
create procedure R2RML_GENERATE_LINKED_VIEW (in source varchar, in destination_graph varchar, in graph_type int := 0, in clear_source_graph int := 1)
{
declare str, vstr, mime, vgraph, get_url varchar;
if (source like 'dav:%')
get_url := 'virt://WS.WS.SYS_DAV_RES.RES_FULL_PATH.RES_CONTENT:' || subseq (source, 4);
else
get_url := source;
str := XML_URI_GET ('', get_url);
mime := DB.DBA.RDF_SPONGE_GUESS_CONTENT_TYPE (source, '', str);
if (clear_source_graph)
{
sparql clear graph iri(?:source) ;
}
if (mime = 'application/rdf+xml')
DB.DBA.RDF_LOAD_RDFXML (str, source, source);
else
DB.DBA.TTLP (str, source, source);
if (graph_type = 0)
vgraph := destination_graph;
else
vgraph := sprintf ('http://example.com/r2rml?graph=%U', source);
if (graph_type = 1)
{
if (exists (sparql define input:storage "" prefix rr: ask { graph `iri(?:source)` { [] rr:graphMap ?m . ?m rr:template ?g }}))
signal ('42000', 'Can not sync graph template to physical graph');
}
vstr := DB.DBA.R2RML_MAKE_QM_FROM_G (source, vgraph);
exec ('sparql ' || vstr);
if (graph_type = 1)
{
RDF_VIEW_SYNC_TO_PHYSICAL (vgraph, 1, destination_graph);
for select "g" from (sparql define input:storage "" prefix rr:
select distinct ?g { graph `iri(?:source)` {{ ?s rr:graph ?g } union { ?s rr:graphMap ?m . ?m rr:constant ?g }}}) x do
{
RDF_VIEW_SYNC_TO_PHYSICAL ("g", 1, destination_graph);
}
}
}
;
¶ "rdb2rdf/r2rml_validation_metas.sqlß ?ê-- $Id: r2rml_validation_metas.sql,v 1.12 2012/04/14 19:47:19 ivan Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
sparql clear graph
;
DB.DBA.TTLP ('
@prefix OVL: .
@prefix owl: .
@prefix rdf: .
@prefix rdfs: .
@prefix rr: .
@prefix xsd: .
rr: a OVL:ClosedWorldPrefix .
rr:child a rdf:Property ; rdfs:domain rr:Join ; rdfs:range xsd:string ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "Names a column in the child table of a join" .
rr:class a rdf:Property ; rdfs:domain rr:SubjectMap ; rdfs:range rdfs:Class ; owl:minCardinality 0 ; OVL:maxGoodCard 10 ; rdfs:comment "The subject value generated for a logical table row will be asserted as an instance of this RDFS class" .
rr:column a rdf:Property ; rdfs:domain rr:OVL-G_S_P_O_Map ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Name of a column in the logical table. When generating RDF triples from a logical table row, value from the specified column is used as the graph, subject, predicate, or object (based upon the specific domain)" .
rr:datatype a rdf:Property ; rdfs:domain rr:ObjectMap ; rdfs:range rdfs:Datatype ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the datatype of the object component for the generated triple from a logical table row" .
rr:constant a rdf:Property ; rdfs:domain rr:OVL-G_S_P_O_Map ; rdfs:range rdfs:Resource ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the datatype of the object component for the generated triple from a logical table row" .
rr:graph a rdf:Property ; rdfs:domain rr:OVL-S_Po_Map ; rdfs:range xsd:anyURI ; owl:minCardinality 0 ; OVL:maxGoodCard 3 ; rdfs:comment "Specifies a graph IRI reference. When used with a SubjectMap element, all the RDF triples generated from a logical row will be stored in the specified named graph. Otherwise, the RDF triple generated using the (predicate, object) pair will be stored in the specified named graph" .
rr:graphMap a rdf:Property ; rdfs:domain rr:OVL-S_Po_Map ; rdfs:range rr:GraphMap ; owl:minCardinality 0 ; owl:maxGoodCard 10 ; rdfs:comment "A GraphMap element to generate a graph from a logical table row" .
rr:inverseExpression a rdf:Property ; rdfs:domain rr:OVL-G_S_P_O_Map ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "An expression that allows, at query processing time, use of index-based access to the the (underlying) relational tables, instead of simply retrieving the table rows first and then applying a filter. This property is useful for retrieval based on conditions involving graph, subject, predicate, or object generated from logical table column(s) and involves some transformation" .
rr:joinCondition a rdf:Property ; rdfs:domain rr:RefObjectMap ; rdfs:range rr:Join ; owl:minCardinality 1 ; OVL:maxGoodCard 3 ; rdfs:comment "Specifies the join condition for joining the child logical table with the parent logical table of the foreign key constraint" .
rr:language a rdf:Property ; rdfs:domain rr:ObjectMap ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the language for the object component for the generated triple from a logical table row" .
rr:logicalTable a rdf:Property ; rdfs:domain rr:TriplesMap ; rdfs:range rr:LogicalTable ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "Definition of logical table to be mapped" .
rr:object a rdf:Property ; rdfs:domain rr:PredicateObjectMap ; rdfs:range rdfs:Resource ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the object for the generated triple from the logical table row" .
rr:objectMap a rdf:Property ; rdfs:domain rr:PredicateObjectMap ; rdfs:range rr:OVL-O_Ro_Map ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "An ObjectMap element to generate the object component of the (predicate, object) pair from a logical table row" .
rr:parent a rdf:Property ; rdfs:domain rr:Join ; rdfs:range xsd:string ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "Names a column in the parent table of a join" .
rr:parentTriplesMap a rdf:Property ; rdfs:domain rr:RefObjectMap ; rdfs:range rr:TriplesMap ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the TriplesMap element corresponding to the parent logical table of the foreign key constraint" .
rr:predicate a rdf:Property ; rdfs:domain rr:PredicateObjectMap ; rdfs:range rdf:Property ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Specifies the predicate for the generated triple from the logical table row" .
rr:predicateMap a rdf:Property ; rdfs:domain rr:PredicateObjectMap ; rdfs:range rr:PredicateMap ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "A PredicateMap element to generate the predicate component of the (predicate, object) pair from a logical table row" .
rr:predicateObjectMap a rdf:Property ; rdfs:domain rr:TriplesMap ; rdfs:range rr:PredicateObjectMap ; owl:minCardinality 0 ; OVL:maxGoodCard 50 ; rdfs:comment "A PredicateObjectMap element to generate (predicate, object) pair from a logical table row" .
rr:sqlQuery a rdf:Property ; rdfs:domain rr:LogicalTable ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "A valid SQL query" .
rr:sqlVersion a rdf:Property ; rdfs:domain rr:LogicalTable ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "SQL version identifier" .
rr:subject a rdf:Property ; rdfs:domain rr:TriplesMap ; rdfs:range OVL:anyREF ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "An IRI reference or a blank node for use as subject for all the RDF triples generated from a logical table row" .
rr:subjectMap a rdf:Property ; rdfs:domain rr:TriplesMap ; rdfs:range rr:SubjectMap ; owl:minCardinality 1 ; owl:maxCardinality 1 ; rdfs:comment "A SubjectMap element to generate a subject from a logical table row" .
rr:tableName a rdf:Property ; rdfs:domain rr:LogicalTable ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Name of a table or view" .
rr:tableOwner a rdf:Property ; rdfs:domain rr:LogicalTable ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Name of table owner" .
rr:tableSchema a rdf:Property ; rdfs:domain rr:LogicalTable ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "Database schema name of table" .
rr:template a rdf:Property ; rdfs:domain rr:OVL-G_S_P_O_Map ; rdfs:range xsd:string ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "A template (format string) to specify how to generate a value for a subject, predicate, or object, using one or more columns from a logical table row" .
rr:termtype a rdf:Property ; rdfs:domain rr:OVL-S_O_Map ; rdfs:range rr:OVL-termtype ; owl:minCardinality 0 ; owl:maxCardinality 1 ; rdfs:comment "A string indicating whether subject or object generated using the value from column name specified for rr:column should be an IRI reference, blank node, or (if object) a literal" .
rr:graphTemplate a OVL:ObsoleteProperty ; rdfs:comment "Use rr:graph and rr:template" .
rr:useLogicalTable a OVL:ObsoleteProperty ; rdfs:comment "Use rr:logicalTable instead" .
rr:useObjectMap a OVL:ObsoleteProperty ; rdfs:comment "Use rr:objectMap instead" .
rr:usePredicateMap a OVL:ObsoleteProperty ; rdfs:comment "Use rr:predicateMap instead" .
rr:usePredicateObjectMap a OVL:ObsoleteProperty ; rdfs:comment "Use rr:predicateObjectMap instead" .
rr:useRefObjectMap a OVL:ObsoleteProperty ; rdfs:comment "Use nodes of rr:RefObjectMap type instead" .
rr:useRefPredicateMap a OVL:ObsoleteProperty ; rdfs:comment "Use nodes of rr:RefObjectMap type instead" .
rr:useRefPredicateObjectMap a OVL:ObsoleteProperty ; rdfs:comment "Use nodes of rr:RefObjectMap type instead" .
rr:useSubjectMap a OVL:ObsoleteProperty ; rdfs:comment "Use rr:subjectMap instead" .
rr:OVL-G_S_P_O_Map OVL:superClassOf rr:GraphMap, rr:SubjectMap, rr:PredicateMap, rr:ObjectMap .
rr:OVL-S_P_O_Map OVL:superClassOf rr:SubjectMap, rr:PredicateMap, rr:ObjectMap .
rr:OVL-S_Po_Map OVL:superClassOf rr:SubjectMap, rr:PredicateObjectMap .
rr:OVL-S_O_Map OVL:superClassOf rr:SubjectMap, rr:ObjectMap .
rr:OVL-O_Ro_Map OVL:superClassOf rr:ObjectMap, rr:RefObjectMap .
rr:LogicalTable OVL:superClassOf rr:TriplesMap .
rr:OVL-termtype OVL:enumOf "IRI", "BlankNode", "Literal" .
rr:TriplesMap OVL:typeRestriction
[ OVL:needSomeOfPredicates rr:subject, rr:subjectMap ] .
rr:PredicateObjectMap OVL:typeRestriction
[ OVL:needSomeOfPredicates rr:predicate, rr:predicateMap ] ,
[ OVL:needSomeOfPredicates rr:object, rr:objectMap ] .
rr:LogicalTable OVL:typeRestriction
[ OVL:mutuallyExclusivePredicates rr:tableName, rr:sqlQuery ] ,
[ OVL:mutuallyExclusivePredicates rr:tableOwner, rr:sqlQuery ] .
OVL:anyREF OVL:typeRestriction
[ OVL:mutuallyExclusivePredicates rr:constant, rr:column, rr:template ] ,
[ OVL:mutuallyExclusivePredicates rr:datatype, rr:language ] .
rr:OVL-G_S_P_O_Map OVL:typeRestriction
[ OVL:needSomeOfPredicates rr:constant, rr:column, rr:template ] .
rr:logicalTable a OVL:InferTypeFromRange .
rr:subjectMap a OVL:InferTypeFromRange .
rr:predicateObjectMap a OVL:InferTypeFromRange .
rr:predicateMap a OVL:InferTypeFromRange .
rr:objectMap a OVL:InferTypeFromRange .
rr:useRefPredicateObjectMap a OVL:InferTypeFromRange .
rr:useRefPredicateMap a OVL:InferTypeFromRange .
rr:useRefObjectMap a OVL:InferTypeFromRange .
rr:joinCondition a OVL:InferTypeFromRange .
rr:termtype OVL:inconsistencyOfPredicate """select ?s, ("Error") as ?severity,
("Literal is not a valid value for rr:termtype property of a rr:SubjectMap element") as ?message
where {
?s a rr:SubjectMap ; rr:termtype "Literal" . }""" .
rr:datatype OVL:inconsistencyOfPredicate """select ?s, ("Error") as ?severity,
("rr:datatype can be specified only if rr:termtype is not an IRI or BlankNode") as ?message
where {
?s a ?t ; rr:datatype ?dt .
optional { ?s rr:termtype ?tt } .
filter ((bound (?tt) && (?tt != "Literal")) || (?t = rr:SubjectMap)) }""" .
rr:language OVL:inconsistencyOfPredicate """select ?s, ("Error") as ?severity,
("rr:language can be specified only if rr:termtype is not an IRI or BlankNode") as ?message
where {
?s a ?t ; rr:language ?lang .
optional { ?s rr:termtype ?tt } .
filter ((bound (?tt) && (?tt != "Literal")) || (?t = rr:SubjectMap)) }""" .
rr:tableName OVL:inconsistencyOfPredicate """select ?lt, ("Warning") as ?severity,
(if (bif:isnotnull (sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 1)),
bif:concat ("rr:tableName refers to ", sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 1), " as to ",
bif:sprintf ("%s.%s.%s", bif:coalesce (?to, "DB"), bif:coalesce (?ts, "DBA"), ?tn),
", i.e., using wrong character case ; adjust the R2RML or the table before generating an RDF View" ),
"rr:tableName refers to table that does not exists ; adjust the R2RML or create the table before generating an RDF View" ) ) as ?message
where {
?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts }
filter (bif:isnull (sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0))) }""" .
rr:column OVL:inconsistencyOfPredicate """select ?fldmap as ?s, ("Warning") as ?severity,
(if (bif:isnotnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1)),
bif:concat ("rr:column refers to column ", ?col , " that is misspelled name of column ",
sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1), " that the table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " contains now ; adjust the R2RML or the table before generating an RDF View" ),
bif:concat ("rr:column refers to column ", ?col , " that is not found in table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " ; adjust the R2RML or the table before generating an RDF View" ) ) ) as ?message
where {
?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts }
filter (bif:isnotnull (sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0)))
?triplesmap a rr:TriplesMap ; rr:logicalTable ?lt .
{ ?triplesmap rr:subjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:predicateObjectMap [ rr:graphMap ?fldmap ] }
union
{ ?triplesmap rr:subjectMap ?fldmap }
union
{ ?triplesmap rr:predicateObjectMap [ rr:predicateMap ?fldmap ] }
union
{ ?triplesmap rr:predicateObjectMap [ rr:objectMap ?fldmap ] }
?fldmap rr:column ?col
filter (bif:isnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 0))) }""" .
rr:parent OVL:inconsistencyOfPredicate """select ?join as ?s, ("Warning") as ?severity,
(if (bif:isnotnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1)),
bif:concat ("rr:parent refers to column ", ?col , " that is misspelled name of column ",
sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1), " that the table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " contains now ; adjust the R2RML or the table before generating an RDF View" ),
bif:concat ("rr:parent refers to column ", ?col , " that is not found in table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " ; adjust the R2RML or the table before generating an RDF View" ) ) ) as ?message
where {
?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts }
filter (bif:isnotnull (sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0)))
?ptriplesmap a rr:TriplesMap ; rr:logicalTable ?lt .
?objmap rr:parentTriplesMap ?ptriplesmap ; rr:joinCondition ?join .
?join rr:parent ?col .
filter (bif:isnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 0))) }""" .
rr:child OVL:inconsistencyOfPredicate """select ?join as ?s, ("Warning") as ?severity,
(if (bif:isnotnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1)),
bif:concat ("rr:child refers to column ", ?col , " that is misspelled name of column ",
sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 1), " that the table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " contains now ; adjust the R2RML or the table before generating an RDF View" ),
bif:concat ("rr:child refers to column ", ?col , " that is not found in table ",
sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0), " ; adjust the R2RML or the table before generating an RDF View" ) ) ) as ?message
where {
?lt rr:tableName ?tn .
OPTIONAL { ?lt rr:tableOwner ?to }
OPTIONAL { ?lt rr:tableSchema ?ts }
filter (bif:isnotnull (sql:R2RML_MAIN_KEY_EXISTS (?ts, ?to, ?tn, 0)))
?triplesmap a rr:TriplesMap ; rr:logicalTable ?lt ; rr:predicateObjectMap [ rr:objectMap ?objmap ] .
?objmap rr:joinCondition ?join .
?join rr:child ?col .
filter (bif:isnull (sql:R2RML_KEY_COLUMN_EXISTS (?ts, ?to, ?tn, ?col, 0))) }""" .
', 'http://www.w3.org/ns/r2rml#OVL', 'http://www.w3.org/ns/r2rml#OVL')
;
¶ rdb2rdf/northwind_r2rml.ttlß ?æ@prefix rr: .
@prefix Demo: .
@prefix demo-stat: .
@prefix rdf: .
@prefix void: .
@prefix scovo: .
@prefix aowl: .
<#TriplesMapCategories> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Categories" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/categories/{CategoryID}"; rr:class Demo:Categories; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:categoryid ] ; rr:objectMap [ rr:column "CategoryID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:categoryname ] ; rr:objectMap [ rr:column "CategoryName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:description ] ; rr:objectMap [ rr:column "Description" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:picture ] ; rr:objectMap [ rr:column "Picture" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:categories_of_products ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapProducts>; rr:joinCondition [ rr:child "CategoryID" ; rr:parent "CategoryID" ] ; ]; ] .
<#TriplesMapCountries> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Countries" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/countries/{Name}"; rr:class Demo:Countries; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:name ] ; rr:objectMap [ rr:column "Name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:code ] ; rr:objectMap [ rr:column "Code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:smallflagdavresourcename ] ; rr:objectMap [ rr:column "SmallFlagDAVResourceName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:largeflagdavresourcename ] ; rr:objectMap [ rr:column "LargeFlagDAVResourceName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:smallflagdavresourceuri ] ; rr:objectMap [ rr:column "SmallFlagDAVResourceURI" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:largeflagdavresourceuri ] ; rr:objectMap [ rr:column "LargeFlagDAVResourceURI" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:lat ] ; rr:objectMap [ rr:column "Lat" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:lng ] ; rr:objectMap [ rr:column "Lng" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:countries_of_provinces ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapProvinces>; rr:joinCondition [ rr:child "Code" ; rr:parent "CountryCode" ] ; ]; ] .
<#TriplesMapCustomers> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Customers" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/customers/{CustomerID}"; rr:class Demo:Customers; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:customerid ] ; rr:objectMap [ rr:column "CustomerID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:companyname ] ; rr:objectMap [ rr:column "CompanyName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:contactname ] ; rr:objectMap [ rr:column "ContactName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:contacttitle ] ; rr:objectMap [ rr:column "ContactTitle" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:address ] ; rr:objectMap [ rr:column "Address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:city ] ; rr:objectMap [ rr:column "City" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:region ] ; rr:objectMap [ rr:column "Region" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:postalcode ] ; rr:objectMap [ rr:column "PostalCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:country ] ; rr:objectMap [ rr:column "Country" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:countrycode ] ; rr:objectMap [ rr:column "CountryCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:phone ] ; rr:objectMap [ rr:column "Phone" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:fax ] ; rr:objectMap [ rr:column "Fax" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:customers_of_orders ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOrders>; rr:joinCondition [ rr:child "CustomerID" ; rr:parent "CustomerID" ] ; ]; ] .
<#TriplesMapEmployees> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Employees" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/employees/{EmployeeID}"; rr:class Demo:Employees; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:employeeid ] ; rr:objectMap [ rr:column "EmployeeID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:lastname ] ; rr:objectMap [ rr:column "LastName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:firstname ] ; rr:objectMap [ rr:column "FirstName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:title ] ; rr:objectMap [ rr:column "Title" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:titleofcourtesy ] ; rr:objectMap [ rr:column "TitleOfCourtesy" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:birthdate ] ; rr:objectMap [ rr:column "BirthDate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:hiredate ] ; rr:objectMap [ rr:column "HireDate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:address ] ; rr:objectMap [ rr:column "Address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:city ] ; rr:objectMap [ rr:column "City" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:region ] ; rr:objectMap [ rr:column "Region" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:postalcode ] ; rr:objectMap [ rr:column "PostalCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:country ] ; rr:objectMap [ rr:column "Country" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:countrycode ] ; rr:objectMap [ rr:column "CountryCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:homephone ] ; rr:objectMap [ rr:column "HomePhone" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:extension ] ; rr:objectMap [ rr:column "Extension" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:photo ] ; rr:objectMap [ rr:column "Photo" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:notes ] ; rr:objectMap [ rr:column "Notes" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:reportsto ] ; rr:objectMap [ rr:column "ReportsTo" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:employees_of_orders ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOrders>; rr:joinCondition [ rr:child "EmployeeID" ; rr:parent "EmployeeID" ] ; ]; ] .
<#TriplesMapOrder_Details> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Order_Details" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/order_details/{OrderID}/{ProductID}"; rr:class Demo:Order_Details; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:unitprice ] ; rr:objectMap [ rr:column "UnitPrice" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:quantity ] ; rr:objectMap [ rr:column "Quantity" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:discount ] ; rr:objectMap [ rr:column "Discount" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:order_details_has_orders ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/orders/{OrderID}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:order_details_has_products ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/products/{ProductID}" ]; ] .
<#TriplesMapOrders> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Orders" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/orders/{OrderID}"; rr:class Demo:Orders; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orderid ] ; rr:objectMap [ rr:column "OrderID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orderdate ] ; rr:objectMap [ rr:column "OrderDate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:requireddate ] ; rr:objectMap [ rr:column "RequiredDate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shippeddate ] ; rr:objectMap [ rr:column "ShippedDate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:freight ] ; rr:objectMap [ rr:column "Freight" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipname ] ; rr:objectMap [ rr:column "ShipName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipaddress ] ; rr:objectMap [ rr:column "ShipAddress" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipcity ] ; rr:objectMap [ rr:column "ShipCity" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipregion ] ; rr:objectMap [ rr:column "ShipRegion" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shippostalcode ] ; rr:objectMap [ rr:column "ShipPostalCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipcountry ] ; rr:objectMap [ rr:column "ShipCountry" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipcountrycode ] ; rr:objectMap [ rr:column "ShipCountryCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orders_has_customers ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/customers/{CustomerID}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orders_has_employees ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/employees/{EmployeeID}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orders_has_shippers ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/shippers/{ShipVia}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:orders_of_order_details ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOrder_Details>; rr:joinCondition [ rr:child "OrderID" ; rr:parent "OrderID" ] ; ]; ] .
<#TriplesMapProducts> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Products" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/products/{ProductID}"; rr:class Demo:Products; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:productid ] ; rr:objectMap [ rr:column "ProductID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:productname ] ; rr:objectMap [ rr:column "ProductName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:quantityperunit ] ; rr:objectMap [ rr:column "QuantityPerUnit" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:unitprice ] ; rr:objectMap [ rr:column "UnitPrice" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:unitsinstock ] ; rr:objectMap [ rr:column "UnitsInStock" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:unitsonorder ] ; rr:objectMap [ rr:column "UnitsOnOrder" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:reorderlevel ] ; rr:objectMap [ rr:column "ReorderLevel" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:discontinued ] ; rr:objectMap [ rr:column "Discontinued" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:products_has_categories ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/categories/{CategoryID}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:products_has_suppliers ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/suppliers/{SupplierID}" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:products_of_order_details ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOrder_Details>; rr:joinCondition [ rr:child "ProductID" ; rr:parent "ProductID" ] ; ]; ] .
<#TriplesMapProvinces> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Provinces" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/provinces/{CountryCode}/{Province}"; rr:class Demo:Provinces; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:province ] ; rr:objectMap [ rr:column "Province" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:provinces_has_countries ] ; rr:objectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/countries/{CountryCode}" ]; ] .
<#TriplesMapShippers> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Shippers" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/shippers/{ShipperID}"; rr:class Demo:Shippers; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shipperid ] ; rr:objectMap [ rr:column "ShipperID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:companyname ] ; rr:objectMap [ rr:column "CompanyName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:phone ] ; rr:objectMap [ rr:column "Phone" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:shippers_of_orders ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOrders>; rr:joinCondition [ rr:child "ShipperID" ; rr:parent "ShipVia" ] ; ]; ] .
<#TriplesMapSuppliers> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Suppliers" ];
rr:subjectMap [ rr:termtype "IRI" ; rr:template "http://localhost:8890/Demo/suppliers/{SupplierID}"; rr:class Demo:Suppliers; rr:graph ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:supplierid ] ; rr:objectMap [ rr:column "SupplierID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:companyname ] ; rr:objectMap [ rr:column "CompanyName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:contactname ] ; rr:objectMap [ rr:column "ContactName" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:contacttitle ] ; rr:objectMap [ rr:column "ContactTitle" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:address ] ; rr:objectMap [ rr:column "Address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:city ] ; rr:objectMap [ rr:column "City" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:region ] ; rr:objectMap [ rr:column "Region" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:postalcode ] ; rr:objectMap [ rr:column "PostalCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:country ] ; rr:objectMap [ rr:column "Country" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:countrycode ] ; rr:objectMap [ rr:column "CountryCode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:phone ] ; rr:objectMap [ rr:column "Phone" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:fax ] ; rr:objectMap [ rr:column "Fax" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:homepage ] ; rr:objectMap [ rr:column "HomePage" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant Demo:suppliers_of_products ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapProducts>; rr:joinCondition [ rr:child "SupplierID" ; rr:parent "SupplierID" ] ; ]; ] .
¶ MD5ß b2d2670ae415c81890901c69b1490ac7