Skip to content

Commit

Permalink
use the rdf ns prefix mapping to control predicate display
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 20, 2013
1 parent cac6c8e commit f11e5df
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Expand Up @@ -181,6 +181,7 @@ public void writeTo(final Dataset rdf, final Class<?> type,
context.put("rdfLexicon", fieldTool.in(RdfLexicon.class));
context.put("helpers", ViewHelpers.getInstance());
context.put("rdf", rdf.asDatasetGraph());
context.put("model", rdf.getDefaultModel());
context.put("subjects", rdf.getDefaultModel().listSubjects());
context.put("nodeany", Node.ANY);
context.put("topic", subject);
Expand Down
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableMap;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.sparql.core.DatasetGraph;
import com.hp.hpl.jena.sparql.core.Quad;
Expand Down Expand Up @@ -109,4 +110,14 @@ public Map<String, String> getNodeBreadcrumbs(final UriInfo uriInfo, final Node
return builder.build();

}

public String getNamespacePrefix(final Model model, final String namespace) {
final String nsURIPrefix = model.getNsURIPrefix(namespace);

if (nsURIPrefix == null) {
return namespace;
} else {
return nsURIPrefix + ":";
}
}
}
10 changes: 4 additions & 6 deletions fcrepo-http-commons/src/main/resources/views/common.vsl
@@ -1,4 +1,6 @@
#* @vtlvariable name="quad" type="com.hp.hpl.jena.sparql.core.Quad" *#
#* @vtlvariable name="rdf" type="com.hp.hpl.jena.sparql.core.DatasetGraph" *#
#* @vtlvariable name="model" type="com.hp.hpl.jena.rdf.model.Model" *#
#macro( triples $sub )
<div resource="$sub.getURI()">
#if($sub.isURI())
Expand All @@ -11,12 +13,8 @@
#foreach($quad in $rdf.find($nodeany, $nodeany, $nodeany, $nodeany))
#if($sub.equals($quad.getSubject()))
<dt>
#if($quad.getPredicate().toString().startsWith("info:fedora/fedora-system:def/internal#") )
<span class="namespace muted">fedora</span><span class="divider muted">:</span><span class="localName">$quad.getPredicate().getLocalName()</span>
#else
<span class="namespace muted">$quad.getPredicate().getNameSpace()</span><span class="divider muted">:</span>
<span class="localName">$quad.getPredicate().getLocalName()</span>
#end
<span class="namespace muted">$helpers.getNamespacePrefix($model, $quad.getPredicate().getNameSpace())</span><span class="localName">$quad.getPredicate().getLocalName()</span>

</dt>
<dd>
#if($quad.getObject().isURI() && $quad.getObject().getURI().startsWith("http"))
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-commons/src/main/resources/views/nt-file.vsl
Expand Up @@ -44,7 +44,7 @@
<dd>
<ol>
#foreach($quad in $helpers.getObjects($rdf, $topic, $rdfLexicon.HAS_CHILD))
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $topic)</a></li>
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $quad.getObject())</a></li>
#end
</ol>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-commons/src/main/resources/views/nt-folder.vsl
Expand Up @@ -44,7 +44,7 @@
<dd>
<ol>
#foreach($quad in $helpers.getObjects($rdf, $topic, $rdfLexicon.HAS_CHILD))
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $topic)</a></li>
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $quad.getObject())</a></li>
#end
</ol>
</dd>
Expand Down
Expand Up @@ -44,7 +44,7 @@
<dd>
<ol>
#foreach($quad in $helpers.getObjects($rdf, $topic, $rdfLexicon.HAS_CHILD))
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $topic)</a></li>
<li><a href="$quad.getObject().getURI()">$helpers.getObjectTitle($rdf, $quad.getObject())</a></li>
#end
</ol>
</dd>
Expand Down

0 comments on commit f11e5df

Please sign in to comment.