Skip to content

Commit

Permalink
Linking to datastream fcr:metadata in HTML UI
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Oct 21, 2014
1 parent c35d67b commit 04b5ece
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 6 additions & 2 deletions fcrepo-http-api/src/main/resources/views/common-metadata.vsl
Expand Up @@ -11,9 +11,13 @@
<dd>
<ol id="childList">
#foreach($quad in $helpers.getObjects($rdf, $topic, $rdfLexicon.CONTAINS))
<li><a href="$quad.getObject().getURI()">$esc.html($helpers.getObjectTitle($rdf, $quad.getObject()))</a></li>
#if ($helpers.isRdfResource($rdf, $quad.getObject()) )
<li><a href="$quad.getObject().getURI()">$esc.html($helpers.getObjectTitle($rdf, $quad.getObject()))</a></li>
#else
<li><a href="${quad.getObject().getURI()}/fcr:metadata">$esc.html($helpers.getObjectTitle($rdf, $quad.getObject()))</a></li>
#end
#end
</ol>
</dd>

</dl>
</dl>
Expand Up @@ -28,6 +28,7 @@
import static org.fcrepo.kernel.RdfLexicon.HAS_CONTENT;
import static org.fcrepo.kernel.RdfLexicon.RDF_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.DC_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.LDP_NAMESPACE;
import static org.slf4j.LoggerFactory.getLogger;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -424,13 +425,10 @@ public String getPrefixPreamble(final PrefixMapping mapping) {
/**
* Determines whether the subject is kind of RDF resource
*/
public boolean isRdfResource(final Graph graph,
final Node subject,
final String namespace,
final String resource) {
public boolean isRdfResource(final Graph graph, final Node subject ) {
final Iterator<Triple> it = graph.find(subject,
createResource(RDF_NAMESPACE + "type").asNode(),
createResource(namespace + resource).asNode());
createResource(LDP_NAMESPACE + "RDFSource").asNode());
return it.hasNext();
}

Expand Down
Expand Up @@ -36,6 +36,7 @@
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.WRITABLE;
import static org.fcrepo.kernel.RdfLexicon.RDF_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.LDP_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -194,12 +195,10 @@ public void testRdfResource() {
final Graph mem = createDefaultModel().getGraph();
mem.add(new Triple(createURI("a/b"),
createResource(RDF_NAMESPACE + "type").asNode(),
createResource(ns + type).asNode()));
createResource(LDP_NAMESPACE + "RDFSource").asNode()));

assertTrue("Node is a " + type + " node.",
testObj.isRdfResource(mem, createURI("a/b"), ns, type));
assertFalse("Node is not a " + type + " node.",
testObj.isRdfResource(mem, createURI("a/b"), ns, "otherType"));
testObj.isRdfResource(mem, createURI("a/b")));
}

@Test
Expand Down

0 comments on commit 04b5ece

Please sign in to comment.