rdf-mt/commit
ADDED: Generation of the test report
author | Jan Wielemaker |
---|---|
Fri Dec 13 13:21:32 2013 +0100 | |
committer | Jan Wielemaker |
Fri Dec 13 13:21:32 2013 +0100 | |
commit | 2428acec05a7c1bf3d7d2fe03f9dd79c9fdaa07e |
tree | 3630ca341be46f99b24c6a12ff36aaf672b048d1 |
parent | 23fb32f5ea632686b2697ec813161cb4dee0cf8e |
Diff style: patch stat
diff --git a/lib/rdf_mt/earl.pl b/lib/rdf_mt/earl.pl new file mode 100644 index 0000000..3d9bcc6 --- /dev/null +++ b/lib/rdf_mt/earl.pl @@ -0,0 +1,105 @@ +/* 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(earl, + [ earl_report/2 % +Results, +Options + ]). +:- use_module(library(semweb/rdf_db)). +:- use_module(library(semweb/rdf_turtle_write)). +:- use_module(library(option)). +:- use_module(library(apply)). + +/** <module> Generate an EARL report +*/ + +:- rdf_register_prefix(dc, 'http://purl.org/dc/elements/1.1/'). +:- rdf_register_prefix(earl, 'http://www.w3.org/ns/earl#'). +:- rdf_register_prefix(foaf, 'http://xmlns.com/foaf/0.1/'). +:- rdf_register_prefix(doap, 'http://usefulinc.com/ns/doap#'). + +%% earl_report(+Results, +Options) +% +% Generate an EARL report in a given graph. Options processed: +% +% * project(+Project) +% RDF file holding project data. +% * graph(Graph) +% Destination graph + +earl_report(Results, Options) :- + load_project(Options, Props), + put_dict(Props, Options, Options1), + maplist(earl_result(Options1), Results), + save_results(Options1). + +load_project(Options, earl{project:Project, tester:Tester, graph:Graph}) :- + option(project(Header), Options, 'earl_header.ttl'), + option(graph(Graph), Options, earl), + module_property(earl, file(Base)), + absolute_file_name(Header, File, + [ relative_to(Base), + access(read) + ]), + rdf_load(File, [graph(Graph)|Options]), + rdf(Project, rdf:type, doap:'Project', Graph), + rdf(Tester, rdf:type, foaf:'Person', Graph). + +earl_result(Dict, Result) :- + rdf_bnode(BN), + rdf_bnode(ResNode), + Graph = Dict.graph, + xsd_date_time(Result.date, Date), + rdf_global_id(earl:Result.outcome, OutCome), + rdf_assert(BN, rdf:type, earl:'Assertion', Graph), + rdf_assert(BN, earl:result, ResNode, Graph), + rdf_assert(ResNode, rdf:type, earl:'TestResult', Graph), + rdf_assert(ResNode, dc:date, Date, Graph), + rdf_assert(ResNode, earl:outcome, OutCome, Graph), + rdf_assert(BN, earl:assertedBy, Dict.tester, Graph), + rdf_assert(BN, earl:subject, Dict.project, Graph), + rdf_assert(BN, earl:test, Result.test, Graph). + +xsd_date_time(Stamp, literal(type(DT, String))) :- + rdf_equal(xsd:dateTime, DT), + format_time(atom(String), '%FT%T%:z', Stamp). + +%% save_results(+Options) is det. +% +% Save the result ERAL graph into File if save(File) is provided. + +save_results(Options) :- + _{save:File} :< Options, !, + rdf_save_turtle(File, + [ graph(Options.graph), + only_known_prefixes(true) + ]). +save_results(_). + + diff --git a/lib/rdf_mt/earl_header.ttl b/lib/rdf_mt/earl_header.ttl new file mode 100644 index 0000000..e55732c --- /dev/null +++ b/lib/rdf_mt/earl_header.ttl @@ -0,0 +1,22 @@ +@prefix dc: <http://purl.org/dc/elements/1.1/> . +@prefix earl: <http://www.w3.org/ns/earl#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix dct: <http://purl.org/dc/terms/> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix dawg: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> . +@prefix doap: <http://usefulinc.com/ns/doap#> . + +<http://cliopatria.swi-prolog.org/user/jan> a foaf:Person ; + foaf:homepage <http://www.cs.vu.nl/~janw/> ; + foaf:name "Jan Wielemaker" . + +<http://cliopatria.swi-prolog.org/> + a doap:Project ; + dc:creator <http://wm.cs.vu.nl/> ; + foaf:maker <http://wm.cs.vu.nl/> ; + doap:name "ClioPatria" ; + doap:developer <http://cliopatria.swi-prolog.org/user/jan>; + doap:license <http://www.swi-prolog.org/license.html> ; + foaf:description "ClioPatria is the Semantic Web platform for SWI-Prolog, providing package management, SPARQL and pluggable reasoning" ; + foaf:homepage <http://cliopatria.swi-prolog.org/> . diff --git a/lib/rdf_mt/manifest.pl b/lib/rdf_mt/manifest.pl index 4c1bb23..17ff8c0 100644 --- a/lib/rdf_mt/manifest.pl +++ b/lib/rdf_mt/manifest.pl @@ -31,8 +31,9 @@ :- module(rdf_mt_manifest, [ load_manifest/1, % +File clean_manifests/0, - mf_test/2, % ?Test, ?Properties - mf_rdf/3 % S,P,O + mf_test/1, % ?Test + mf_rdf/3, % S,P,O + mf_member/2 % ?URI, +Collection ]). :- use_module(library(semweb/turtle)). :- use_module(library(apply)). @@ -68,11 +69,11 @@ load_manifest(File) :- mf_assert(rdf(S,P,O)) :- assert(mf_rdf(S,P,O)). -%% mf_test(?Test, -Properties) :- +%% mf_test(?Test) :- % % True when Test is a test in the manifest -mf_test(Test, _Properties) :- +mf_test(Test) :- mf_rdf(MF, rdf:type, mf:'Manifest'), mf_rdf(MF, mf:entries, Entries), mf_member(Test, Entries).