Skip to content

Commit

Permalink
Updating LDP membership triples (fixes https://www.pivotaltracker.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Apr 16, 2014
1 parent 0540f6a commit f33a0c0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 38 deletions.
Expand Up @@ -400,13 +400,15 @@ public void verifyFullSetOfRdfTypes() throws Exception {
http://www.jcp.org/jcr/nt/1.0folder
http://www.jcp.org/jcr/nt/1.0hierarchyNode
http://www.w3.org/ns/ldp#Container
http://www.w3.org/ns/ldp#DirectContainer
http://www.w3.org/ns/ldp#Page
*/

verifyResource(model, nodeUri, rdfType, RESTAPI_NAMESPACE, "object");
verifyResource(model, nodeUri, rdfType, RESTAPI_NAMESPACE, "relations");
verifyResource(model, nodeUri, rdfType, RESTAPI_NAMESPACE, "resource");
verifyResource(model, nodeUri, rdfType, LDP_NAMESPACE, "Container");
verifyResource(model, nodeUri, rdfType, LDP_NAMESPACE, "DirectContainer");
verifyResource(model, nodeUri, rdfType, LDP_NAMESPACE, "Page");
verifyResource(model, nodeUri, rdfType, DC_NAMESPACE, "describable");
verifyResource(model, nodeUri, rdfType, MIX_NAMESPACE, "created");
Expand Down
17 changes: 7 additions & 10 deletions fcrepo-kernel-api/src/main/java/org/fcrepo/kernel/RdfLexicon.java
Expand Up @@ -173,21 +173,18 @@ public final class RdfLexicon {
createProperty(LDP_NAMESPACE + "membersInlined");
public static final Property CONTAINER =
createProperty(LDP_NAMESPACE + "Container");
public static final Property MEMBERSHIP_SUBJECT =
createProperty(LDP_NAMESPACE + "membershipSubject");
public static final Property MEMBERSHIP_PREDICATE =
createProperty(LDP_NAMESPACE + "membershipPredicate");
public static final Property MEMBERSHIP_OBJECT =
createProperty(LDP_NAMESPACE + "membershipObject");
public static final Property MEMBER_SUBJECT =
createProperty(LDP_NAMESPACE + "MemberSubject");
public static final Property DIRECT_CONTAINER =
createProperty(LDP_NAMESPACE + "DirectContainer");
public static final Property MEMBERSHIP_RESOURCE =
createProperty(LDP_NAMESPACE + "membershipResource");
public static final Property HAS_MEMBER_RELATION =
createProperty(LDP_NAMESPACE + "hasMemberRelation");
public static final Property INLINED_RESOURCE =
createProperty(LDP_NAMESPACE + "inlinedResource");

public static final Set<Property> ldpProperties = of(PAGE, PAGE_OF,
FIRST_PAGE, NEXT_PAGE, MEMBERS_INLINED, CONTAINER,
MEMBERSHIP_SUBJECT, MEMBERSHIP_PREDICATE, MEMBERSHIP_OBJECT,
MEMBER_SUBJECT, INLINED_RESOURCE);
MEMBERSHIP_RESOURCE, HAS_MEMBER_RELATION, INLINED_RESOURCE);

// REPOSITORY INFORMATION
public static final Property HAS_OBJECT_COUNT =
Expand Down
Expand Up @@ -23,14 +23,13 @@
import static com.hp.hpl.jena.vocabulary.RDF.type;
import static java.lang.Boolean.TRUE;
import static org.fcrepo.kernel.RdfLexicon.CONTAINER;
import static org.fcrepo.kernel.RdfLexicon.DIRECT_CONTAINER;
import static org.fcrepo.kernel.RdfLexicon.HAS_CHILD;
import static org.fcrepo.kernel.RdfLexicon.HAS_PARENT;
import static org.fcrepo.kernel.RdfLexicon.INLINED_RESOURCE;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_OBJECT;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_PREDICATE;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_SUBJECT;
import static org.fcrepo.kernel.RdfLexicon.HAS_MEMBER_RELATION;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_RESOURCE;
import static org.fcrepo.kernel.RdfLexicon.MEMBERS_INLINED;
import static org.fcrepo.kernel.RdfLexicon.MEMBER_SUBJECT;
import static org.fcrepo.kernel.RdfLexicon.PAGE;
import static org.fcrepo.kernel.RdfLexicon.PAGE_OF;
import static org.fcrepo.kernel.utils.FedoraTypesUtils.isInternalNode;
Expand Down Expand Up @@ -105,10 +104,9 @@ private Triple[] containerContext(final Node pageContext) {
create(pageContext, MEMBERS_INLINED.asNode(),
createLiteral(TRUE.toString())),
create(subject(), type.asNode(), CONTAINER.asNode()),
create(subject(), MEMBERSHIP_SUBJECT.asNode(), subject()),
create(subject(), MEMBERSHIP_PREDICATE.asNode(), HAS_CHILD
.asNode()),
create(subject(), MEMBERSHIP_OBJECT.asNode(), MEMBER_SUBJECT
create(subject(), type.asNode(), DIRECT_CONTAINER.asNode()),
create(subject(), MEMBERSHIP_RESOURCE.asNode(), subject()),
create(subject(), HAS_MEMBER_RELATION.asNode(), HAS_CHILD
.asNode())};
}

Expand Down
Expand Up @@ -21,13 +21,12 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static com.hp.hpl.jena.vocabulary.RDF.type;
import static org.fcrepo.kernel.RdfLexicon.CONTAINER;
import static org.fcrepo.kernel.RdfLexicon.DIRECT_CONTAINER;
import static org.fcrepo.kernel.RdfLexicon.HAS_CHILD;
import static org.fcrepo.kernel.RdfLexicon.HAS_PARENT;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_OBJECT;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_PREDICATE;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_SUBJECT;
import static org.fcrepo.kernel.RdfLexicon.HAS_MEMBER_RELATION;
import static org.fcrepo.kernel.RdfLexicon.MEMBERSHIP_RESOURCE;
import static org.fcrepo.kernel.RdfLexicon.MEMBERS_INLINED;
import static org.fcrepo.kernel.RdfLexicon.MEMBER_SUBJECT;
import static org.fcrepo.kernel.RdfLexicon.PAGE;
import static org.fcrepo.kernel.RdfLexicon.PAGE_OF;
import static org.fcrepo.kernel.RdfLexicon.JCR_NAMESPACE;
Expand Down Expand Up @@ -135,13 +134,12 @@ public void testNotContainer() throws RepositoryException, IOException {
assertFalse(actual.contains(testPage, MEMBERS_INLINED, actual
.createTypedLiteral(true)));
assertFalse(actual.contains(testSubject, type, CONTAINER));
assertFalse(actual.contains(testSubject, type, DIRECT_CONTAINER));

assertFalse(actual.contains(testSubject, MEMBERSHIP_SUBJECT,
assertFalse(actual.contains(testSubject, MEMBERSHIP_RESOURCE,
testSubject));
assertFalse(actual.contains(testSubject, MEMBERSHIP_PREDICATE,
assertFalse(actual.contains(testSubject, HAS_MEMBER_RELATION,
HAS_CHILD));
assertFalse(actual.contains(testSubject, MEMBERSHIP_OBJECT,
MEMBER_SUBJECT));

}

Expand All @@ -165,15 +163,14 @@ public void testForLDPTriples() throws RepositoryException, IOException {
// check for LDP-specified node information
assertTrue(
"Didn't find node described as being the subject of membership!",
results.contains(testSubject, MEMBERSHIP_SUBJECT, testSubject));
results.contains(testSubject, MEMBERSHIP_RESOURCE, testSubject));
assertTrue("Didn't find node described as being an LDP Container!",
results.contains(testSubject, type, CONTAINER));
assertTrue(
"Didn't find node described as have an LDP membership object!",
results.contains(testSubject, MEMBERSHIP_OBJECT, MEMBER_SUBJECT));
assertTrue("Didn't find node described as being an LDP DirectContainer!",
results.contains(testSubject, type, DIRECT_CONTAINER));
assertTrue(
"Didn't find node described as using the correct LDP membership predicate!",
results.contains(testSubject, MEMBERSHIP_PREDICATE, HAS_CHILD));
results.contains(testSubject, HAS_MEMBER_RELATION, HAS_CHILD));
}

@Before
Expand Down
Expand Up @@ -300,17 +300,14 @@ public final void shouldIncludeContainerInfoWithMixinTypeContainer()

final Resource graphSubject = testSubjects.getSubject(mockNode.getPath());
assertTrue(actual.contains(graphSubject, type, actual
.createProperty(LDP_NAMESPACE + "Container")));
.createProperty(LDP_NAMESPACE + "DirectContainer")));

assertTrue(actual.contains(graphSubject, actual
.createProperty(LDP_NAMESPACE + "membershipSubject"),
.createProperty(LDP_NAMESPACE + "membershipResource"),
graphSubject));
assertTrue(actual.contains(graphSubject,actual
.createProperty(LDP_NAMESPACE + "membershipPredicate"),
assertTrue(actual.contains(graphSubject, actual
.createProperty(LDP_NAMESPACE + "hasMemberRelation"),
HAS_CHILD));
assertTrue(actual.contains(graphSubject,actual
.createProperty(LDP_NAMESPACE + "membershipObject"),
actual.createResource(LDP_NAMESPACE + "MemberSubject")));
}

@Test
Expand Down

0 comments on commit f33a0c0

Please sign in to comment.