EDM/commit

Introduce `user' context graph

authorJan Wielemaker
Thu Dec 9 11:50:21 2010 +0100
committerJan Wielemaker
Thu Dec 9 11:50:21 2010 +0100
commitf70a8e42352414099d5b1cf695b88f93231c8625
tree5160ab7623ef510a0928eea1f769f04a98df1f6d
parentb0ec2bcb1aa2c81b2b67d546cd73e92aed31b0a0
Diff style: patch stat
diff --git a/components/edm/components.pl b/components/edm/components.pl
index 4835631..5444a83 100644
--- a/components/edm/components.pl
+++ b/components/edm/components.pl
@@ -41,6 +41,7 @@
 :- use_module(library(semweb/rdf_label)).
 :- use_module(library(http/http_path)).
 :- use_module(components(label)).
+:- use_module(applications(browse)).
 :- use_module(library(http/http_dispatch)).
 :- use_module(library(http/http_wrapper)).
 :- use_module(user(preferences)).
@@ -99,6 +100,8 @@ edm_proxy_view(URI, _Options) -->
 		       [ \values(span, URI, dcterms:rights),
 			 \values(span, URI, dcterms:identifier)
 		       ]),
+		   h2('Related objects'),
+		   \context_graph(URI, [style(edm(user))]),
 		   br(clear(all)),
 		   div(class(fullview), a(href(FullHREF), 'Full view'))
 		 ])).
diff --git a/components/edm/graph.pl b/components/edm/graph.pl
index cf9cc0c..a5a03ef 100644
--- a/components/edm/graph.pl
+++ b/components/edm/graph.pl
@@ -34,64 +34,74 @@ in the rendering of the EDM classes.
 %	20 and the total graph is not expanded beyond 100 nodes.
 
 :- rdf_meta
-	edm_relation(r),
+	edm_relation(?, r),
 	edm_class(r).
 
 edm_context_graph(R, RDF, Options) :-
-	option(style(edm), Options),
-	bf_graph(R, 2, 100, 20, RDF0),
+	option(style(Style), Options),
+	(   ground(Style)
+	->  Style = edm(_),
+	    IsEDM = true
+	;   IsEDM = maybe
+	),
+	Style = edm(EDMStyle),
+	bf_graph(R, EDMStyle, 2, 100, 20, RDF0),
 	minimise_graph(RDF0, RDF1),		% remove inverse/symmetric/...
 	bagify_graph(RDF1, RDF2, Bags, []), 	% Create bags of similar resources
 	append(RDF2, Bags, RDF),
 	graph_resources(RDF, Resources, _Preds, _Types),
-	include(edm_resource, Resources, EDMResources),
-	EDMResources = [_,_|_].
+	(   IsEDM == true
+	->  true
+	;   include(edm_resource, Resources, EDMResources),
+	    EDMResources = [_,_|_]
+	).
 
 %%	bf_graph(+Start, +MaxDist, +MaxEdges, +MaxBranch, -Graph)
 
-bf_graph(Start, MaxDist, MaxEdges, MaxBranch, Graph) :-
-	bf_graph_2([0-Start], MaxDist, MaxEdges, MaxBranch, [], Graph).
+bf_graph(Start, Style, MaxDist, MaxEdges, MaxBranch, Graph) :-
+	bf_graph_2([0-Start], Style, MaxDist, MaxEdges, MaxBranch, [], Graph).
 
-bf_graph_2([], _, _, _, G, G) :- !.
-bf_graph_2([D-_|_], MaxDist, _, _, G, G) :-
+bf_graph_2([], _, _, _, _, G, G) :- !.
+bf_graph_2([D-_|_], _, MaxDist, _, _, G, G) :-
 	D >= MaxDist, !.
-bf_graph_2(AG0, MaxDist, MaxEdges, MaxBranch, G0, G) :-
-	bf_expand(AG0, AG, MaxBranch, G1),
+bf_graph_2(AG0, Style, MaxDist, MaxEdges, MaxBranch, G0, G) :-
+	bf_expand(AG0, AG, Style, MaxBranch, G1),
 	(   G1 == []
-	->  bf_graph_2(AG, MaxDist, MaxEdges, MaxBranch, G0, G)
+	->  bf_graph_2(AG, Style, MaxDist, MaxEdges, MaxBranch, G0, G)
 	;   append(G1, G0, G2),
 	    sort(G2, G3),
 	    length(G3, Edges),
 	    (   Edges >= MaxEdges
 	    ->  G = G0
-	    ;   bf_graph_2(AG, MaxDist, MaxEdges, MaxBranch, G3, G)
+	    ;   bf_graph_2(AG, Style, MaxDist, MaxEdges, MaxBranch, G3, G)
 	    )
 	).
 
-bf_expand([D-F|AG0], AG, MaxBranch, Triples) :-
+bf_expand([D-F|AG0], AG, Style, MaxBranch, Triples) :-
 	D1 is D + 1,
 	Key = D1-Dst,
-	answer_set(Key-Triple, related(F, Dst, Triple), MaxBranch, Pairs),
+	answer_set(Key-Triple, related(Style, F, Dst, Triple), MaxBranch, Pairs),
 	pairs_keys_values(Pairs, Dsts, Triples),
 	append(AG0, Dsts, AG).
 
-related(S, O, rdf(S,P,O)) :-
-	edm_relation(Rel),
+related(Style, S, O, rdf(S,P,O)) :-
+	edm_relation(Style, Rel),
 	rdf_has(S, Rel, O, P).
-related(O, S, rdf(S,P,O)) :-
-	edm_relation(Rel),
+related(Style, O, S, rdf(S,P,O)) :-
+	edm_relation(Style, Rel),
 	rdf_has(S, Rel, O, P).
 
-edm_relation(ore:aggregates).
-edm_relation(ore:proxyFor).
-edm_relation(ore:proxyIn).
-edm_relation(ens:aggregatedCHO).
-edm_relation(ens:hasThumbnail).
-edm_relation(dcterms:hasPart).
-edm_relation(ens:isNextInSequence).
-edm_relation(ens:object).		% this is *always* a thumbnail
-edm_relation(ens:hasView).
-edm_relation(dcterms:relation).
+edm_relation(edm,  ore:aggregates).
+edm_relation(edm,  ore:proxyFor).
+edm_relation(edm,  ore:proxyIn).
+edm_relation(edm,  ens:aggregatedCHO).
+edm_relation(edm,  ens:hasThumbnail).
+edm_relation(edm,  dcterms:hasPart).
+edm_relation(edm,  ens:isNextInSequence).
+edm_relation(edm,  ens:object).			% this is *always* a thumbnail
+edm_relation(edm,  ens:hasView).
+edm_relation(_,	   dcterms:relation).
+edm_relation(user, dcterms:creator).
 
 edm_resource(R) :-
 	edm_class(Class),
@@ -109,23 +119,23 @@ edm_class(ens:'PhysicalThing').
 %	context-graph.
 
 edm_node_shape(URI, Shape, Options) :-
-	option(style(edm), Options),
-	node_shape(URI, Shape, Options).
+	option(style(edm(Style)), Options),
+	node_shape(URI, Style, Shape, Options).
 
-node_shape(URI, Shape, Options) :-
+node_shape(URI, _, Shape, Options) :-
 	memberchk(start(URI), Options),
 	Shape = [shape(tripleoctagon),style(filled),fillcolor('#ff85fd')].
-node_shape(URI, Shape, _Options) :-
+node_shape(URI, _, Shape, _Options) :-
 	rdf_has(URI, rdf:type, ens:'WebResource'),
 	page_content_type(URI, Type),
 	sub_atom(Type, 0, _, _, 'image/'),
 	Shape = [img([src(URI)])].
-node_shape(URI, Shape, _Options) :-
+node_shape(URI, _, Shape, _Options) :-
 	rdf_has(URI, rdf:type, ore:'Aggregation'),
 	Shape = [shape(box3d),style(filled),fillcolor('#85fff7')].
-node_shape(URI, Shape, _Options) :-
+node_shape(URI, _, Shape, _Options) :-
 	rdf_has(URI, rdf:type, ore:'Proxy'),
 	Shape = [shape(diamond),style('rounded,filled'),fillcolor('#ffb785')].
-node_shape(URI, Shape, _Options) :-
+node_shape(URI, _, Shape, _Options) :-
 	rdf_has(URI, rdf:type, ens:'PhysicalThing'),
 	Shape = [shape(house),style('filled'),fillcolor('#ff8585')].