Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use IANA describes/describedby predicates to link a non-rdf source an…
…d its description
  • Loading branch information
cbeer committed Oct 30, 2014
1 parent bc44e2d commit 3ad9b11
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
@@ -1,4 +1,4 @@
#set ($content = $helpers.getObjectsAsString($rdf, $topic, $rdfLexicon.HAS_CONTENT, false))
#set ($content = $helpers.getObjectsAsString($rdf, $topic, $rdfLexicon.DESCRIBES, false))
#set ($writable = $helpers.isWritable($rdf, $topic))
#set ($frozen = $helpers.isFrozenNode($rdf, $topic))

Expand Down
Expand Up @@ -25,7 +25,7 @@
import static org.fcrepo.kernel.RdfLexicon.LAST_MODIFIED_DATE;
import static org.fcrepo.kernel.RdfLexicon.RDFS_LABEL;
import static org.fcrepo.kernel.RdfLexicon.HAS_VERSION;
import static org.fcrepo.kernel.RdfLexicon.HAS_CONTENT;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBES;
import static org.fcrepo.kernel.RdfLexicon.RDF_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.DC_NAMESPACE;
import static org.slf4j.LoggerFactory.getLogger;
Expand Down Expand Up @@ -118,7 +118,7 @@ public Iterator<Node> getVersions(final Graph graph,
*/
public Iterator<Node> getChildVersions(final Graph graph,
final Node subject) {
return getOrderedVersions(graph, subject, HAS_CONTENT);
return getOrderedVersions(graph, subject, DESCRIBES);
}

/**
Expand Down
Expand Up @@ -31,7 +31,7 @@
import static org.fcrepo.kernel.RdfLexicon.DC_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.LAST_MODIFIED_DATE;
import static org.fcrepo.kernel.RdfLexicon.HAS_VERSION;
import static org.fcrepo.kernel.RdfLexicon.HAS_CONTENT;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBES;
import static org.fcrepo.kernel.RdfLexicon.RDFS_LABEL;
import static org.fcrepo.kernel.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.fcrepo.kernel.RdfLexicon.WRITABLE;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void testGetChildVersions() {
final Node contentVersion = createURI("http://localhost/fcrepo/abc/fcr:version/adcd/fcr:content");
final String date = new Date().toString();
mem.add(new Triple(version, HAS_VERSION.asNode(), version));
mem.add(new Triple(version, HAS_CONTENT.asNode(), contentVersion));
mem.add(new Triple(version, DESCRIBES.asNode(), contentVersion));
mem.add(new Triple(contentVersion, LAST_MODIFIED_DATE.asNode(), createLiteral(date)));
assertEquals("Content version should be available.",
contentVersion, testObj.getChildVersions(mem, version).next());
Expand Down Expand Up @@ -169,7 +169,7 @@ public void testIsWritableFalse() {
@Test
public void testIsWritableFalseJunk() {
final Graph mem = createDefaultModel().getGraph();
mem.add(new Triple(createURI("a/b/c"), HAS_CONTENT.asNode(), createLiteral("junk")));
mem.add(new Triple(createURI("a/b/c"), DESCRIBES.asNode(), createLiteral("junk")));
assertFalse("Node should not be writable.", testObj.isWritable(mem, createURI("a/b/c")));
}

Expand Down
Expand Up @@ -16,8 +16,8 @@
package org.fcrepo.kernel.impl.rdf.impl;

import static com.hp.hpl.jena.graph.Triple.create;
import static org.fcrepo.kernel.RdfLexicon.HAS_CONTENT;
import static org.fcrepo.kernel.RdfLexicon.IS_CONTENT_OF;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBES;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBED_BY;

import org.fcrepo.kernel.models.NonRdfSourceDescription;
import org.fcrepo.kernel.models.FedoraBinary;
Expand Down Expand Up @@ -49,12 +49,12 @@ public ContentRdfContext(final FedoraResource resource,
final Node subject = translator().reverse().convert(resource()).asNode();
final Node contentSubject = translator().reverse().convert(contentNode).asNode();
// add triples representing parent-to-content-child relationship
concat(create(subject, HAS_CONTENT.asNode(), contentSubject));
concat(create(subject, DESCRIBES.asNode(), contentSubject));

} else if (resource instanceof FedoraBinary) {
final FedoraResource description = ((FedoraBinary) resource).getDescription();
concat(create(translator().reverse().convert(resource).asNode(),
IS_CONTENT_OF.asNode(),
DESCRIBED_BY.asNode(),
translator().reverse().convert(description).asNode()));
}
}
Expand Down
Expand Up @@ -15,8 +15,8 @@
*/
package org.fcrepo.kernel.impl.rdf.impl;

import static org.fcrepo.kernel.RdfLexicon.HAS_CONTENT;
import static org.fcrepo.kernel.RdfLexicon.IS_CONTENT_OF;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBES;
import static org.fcrepo.kernel.RdfLexicon.DESCRIBED_BY;
import static org.fcrepo.kernel.RdfLexicon.JCR_NAMESPACE;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void testForLowLevelStorageTriples() throws IOException {
new ContentRdfContext(mockResource, idTranslator).asModel();
logRdf("Retrieved RDF for testForLowLevelStorageTriples():", results);
assertTrue("Didn't find triple showing node has content!", results
.contains(mockSubject, HAS_CONTENT, mockContentSubject));
.contains(mockSubject, DESCRIBES, mockContentSubject));
}

@Test
Expand All @@ -69,7 +69,7 @@ public void testFedoraBinaryTriples() throws IOException {
final Model results =
new ContentRdfContext(mockBinary, idTranslator).asModel();
assertTrue("Didn't find triple showing content has node!", results
.contains(mockContentSubject, IS_CONTENT_OF, mockSubject));
.contains(mockContentSubject, DESCRIBED_BY, mockSubject));
}

@Before
Expand Down
17 changes: 10 additions & 7 deletions fcrepo-kernel/src/main/java/org/fcrepo/kernel/RdfLexicon.java
Expand Up @@ -239,11 +239,15 @@ public final class RdfLexicon {
HAS_FEED, HAS_SUBSCRIPTION_SERVICE);


// BINARY DESCRIPTIONS
public static final Property DESCRIBES =
createProperty("http://www.iana.org/assignments/relation/describes");
public static final Property DESCRIBED_BY =
createProperty("http://www.iana.org/assignments/relation/describedby");

public static final Set<Property> structProperties = of(DESCRIBES, DESCRIBED_BY);

// CONTENT
public static final Property HAS_CONTENT =
createProperty(REPOSITORY_NAMESPACE + "hasContent");
public static final Property IS_CONTENT_OF =
createProperty(REPOSITORY_NAMESPACE + "isContentOf");
public static final Resource CONTENT_LOCATION_TYPE =
createResource(PREMIS_NAMESPACE + "ContentLocation");
public static final Property HAS_CONTENT_LOCATION =
Expand All @@ -255,8 +259,7 @@ public final class RdfLexicon {
public static final Property HAS_ORIGINAL_NAME =
createProperty(PREMIS_NAMESPACE + "hasOriginalName");

public static final Set<Property> contentProperties = of(HAS_CONTENT,
IS_CONTENT_OF, HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE,
public static final Set<Property> contentProperties = of(HAS_CONTENT_LOCATION, HAS_CONTENT_LOCATION_VALUE,
HAS_MIME_TYPE, HAS_ORIGINAL_NAME, HAS_SIZE);


Expand Down Expand Up @@ -310,7 +313,7 @@ public final class RdfLexicon {
final ImmutableSet.Builder<Property> b = ImmutableSet.builder();
b.addAll(membershipProperties).addAll(fixityProperties).addAll(ldpProperties).addAll(
repositoryProperties).addAll(namespaceProperties).addAll(
otherServiceProperties).addAll(contentProperties).addAll(
otherServiceProperties).addAll(structProperties).addAll(contentProperties).addAll(
versioningProperties).addAll(jcrProperties);
managedProperties = b.build();
}
Expand Down

0 comments on commit 3ad9b11

Please sign in to comment.