rdf-mt/commit
Added manifest loading
author | Jan Wielemaker |
---|---|
Fri Dec 13 10:52:26 2013 +0100 | |
committer | Jan Wielemaker |
Fri Dec 13 10:52:26 2013 +0100 | |
commit | 23fb32f5ea632686b2697ec813161cb4dee0cf8e |
tree | d56aa97795e0fd9ae2848d22ac70105f4ca9a959 |
parent | 259e2ded4eb2f8f3228f80b4115b6df08afbb673 |
Diff style: patch stat
diff --git a/lib/rdf_mt/manifest.pl b/lib/rdf_mt/manifest.pl new file mode 100644 index 0000000..4c1bb23 --- /dev/null +++ b/lib/rdf_mt/manifest.pl @@ -0,0 +1,94 @@ +/* Part of ClioPatria SeRQL and SPARQL server + + Author: Jan Wielemaker + E-mail: J.Wielemaker@cs.vu.nl + WWW: http://www.swi-prolog.org + Copyright (C): 2013, University of Amsterdam, + VU University Amsterdam + + This program 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; either version 2 + of the License, or (at your option) any later version. + + 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 library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + As a special exception, if you link this library with other files, + compiled with a Free Software compiler, to produce an executable, this + library does not by itself cause the resulting executable to be covered + by the GNU General Public License. This exception does not however + invalidate any other reasons why the executable file might be covered by + the GNU General Public License. +*/ + +:- module(rdf_mt_manifest, + [ load_manifest/1, % +File + clean_manifests/0, + mf_test/2, % ?Test, ?Properties + mf_rdf/3 % S,P,O + ]). +:- use_module(library(semweb/turtle)). +:- use_module(library(apply)). + +/** <module> Process an RDF test manifest +*/ + +:- dynamic + mf_rdf/3, + mf_manifest/1. % URI + +:- rdf_meta + mf_rdf(r, r, o). + +:- rdf_register_prefix( + mf, + 'http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#'). +:- rdf_register_prefix( + rdft, + 'http://www.w3.org/ns/rdftest#'). + +%% load_manifest(+File) +% +% Load a new manifest + +load_manifest(File) :- + uri_file_name(URI, File), + atom_concat('__', URI, BNPrefix), + rdf_read_turtle(File, Triples, [anon_prefix(BNPrefix)]), + maplist(mf_assert, Triples), + assert(mf_manifest(URI)). + +mf_assert(rdf(S,P,O)) :- + assert(mf_rdf(S,P,O)). + +%% mf_test(?Test, -Properties) :- +% +% True when Test is a test in the manifest + +mf_test(Test, _Properties) :- + mf_rdf(MF, rdf:type, mf:'Manifest'), + mf_rdf(MF, mf:entries, Entries), + mf_member(Test, Entries). + +%% clean_manifests +% +% Remove data loaded from manifests + +clean_manifests :- + retractall(mf_manifest(_)), + retractall(mf_rdf(_,_,_)). + +%% mf_member(?URI, +Collection) + +mf_member(URI, Collection) :- + mf_rdf(Collection, rdf:first, URI). +mf_member(URI, Collection) :- + mf_rdf(Collection, rdf:rest, Next), + mf_member(URI, Next).