amalgame/commit

do not crash on publishing empty mappings

authorJacco van Ossenbruggen
Tue Sep 10 17:05:50 2013 +0200
committerJacco van Ossenbruggen
Tue Sep 10 17:05:50 2013 +0200
commit5c879ab5e03f51046145b69e57c404efe4747f19
treec4e7e2345f8247c2dcb2300254bea2fde6f0f48c
parent3407cdb96d0aad42dff2cd3c84b7a7515f9f2d9c
Diff style: patch stat
diff --git a/lib/amalgame/ag_publish.pl b/lib/amalgame/ag_publish.pl
index 2397764..c3b71f4 100644
--- a/lib/amalgame/ag_publish.pl
+++ b/lib/amalgame/ag_publish.pl
@@ -103,7 +103,7 @@ assert_void(Id,Options) :-
 
 	rdf_equal(xsd:int, Int),
 	void_graph(Strategy, Void),
-	rdf_statistics(triples_by_graph(Id, NrOfTriples)),
+	(   rdf_statistics(triples_by_graph(Id, NrOfTriples)) -> true; NrOfTriples=0),
 	assert_metadata(Id, Strategy, Void),
 	rdf_assert(All, void:subset,      Id,  Void),
 	rdf_assert(Id, void:vocabulary,   amalgame:'', Void),
@@ -134,11 +134,13 @@ default_mapping_relation(Id, Default, Options) :-
 prepare_mapping(Id, Strategy, Options) :-
 	(   \+ rdf_graph(Id)
 	->  expand_node(Strategy, Id, Mapping),
-	    Mapping = [_|_],
-	    default_mapping_relation(Id, Default, Options),
-	    augment_relations(Strategy, Id, Mapping, Augmented, [default_relation(Default)]),
-	    materialize_mapping_graph(Augmented, [graph(Id) | Options])
-	;   true
+	    (	Mapping = [_|_]
+	    ->	default_mapping_relation(Id, Default, Options),
+		augment_relations(Strategy, Id, Mapping, Augmented, [default_relation(Default)]),
+		materialize_mapping_graph(Augmented, [graph(Id) | Options])
+	    ;	true % empty mapping, do nothing
+	    )
+	;   true % already materialized in a previous run, do nothing
 	).
 
 save_mapping(Id, Options) :-