Skip to content

Commit

Permalink
Don't inline triples from the parent object, and don't include child …
Browse files Browse the repository at this point in the history
…triples unless we're inlining other triples for those objects
  • Loading branch information
cbeer committed Apr 17, 2014
1 parent 0e2d3dc commit 2d49b77
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
Expand Up @@ -88,16 +88,14 @@ public HierarchyRdfContext(final javax.jcr.Node node,
LOGGER.trace("Determined that this node is not a container.");
}

if (options.membershipEnabled() || options.containmentEnabled()) {
if (node.getDepth() > 0) {
LOGGER.trace("Determined that this node has a parent.");
concat(parentContext());
}
if (node.getDepth() > 0) {
LOGGER.trace("Determined that this node has a parent.");
concat(parentContext());
}

if (node.hasNodes()) {
LOGGER.trace("Found children of this node.");
concat(childrenContext());
}
if ((options.membershipEnabled() || options.containmentEnabled()) && node.hasNodes()) {
LOGGER.trace("Found children of this node.");
concat(childrenContext());
}
}

Expand All @@ -116,14 +114,7 @@ private Iterator<Triple> parentContext() throws RepositoryException {

final RdfStream parentStream = new RdfStream();

if (options.membershipEnabled()) {
parentStream.concat(create(subject(), HAS_PARENT.asNode(), parentNodeSubject),
create(parentNodeSubject, HAS_CHILD.asNode(), subject()));
}

if (options.containmentEnabled()) {
parentStream.concat(new PropertiesRdfContext(parentNode, graphSubjects(), lowLevelStorageService()));
}
parentStream.concat(create(subject(), HAS_PARENT.asNode(), parentNodeSubject));

return parentStream;
}
Expand Down Expand Up @@ -161,15 +152,16 @@ public Iterator<Triple> apply(final javax.jcr.Node child) {


if (options.membershipEnabled()) {
childStream.concat(create(childSubject, HAS_PARENT.asNode(), subject()),
create(subject(), HAS_CHILD.asNode(), childSubject));
childStream.concat(create(subject(), HAS_CHILD.asNode(), childSubject));
}

if (options.containmentEnabled()) {

childStream.concat(
new PropertiesRdfContext(child, graphSubjects(), lowLevelStorageService())
);
childStream.concat(create(subject(), CONTAINS.asNode(), childSubject));
childStream.concat(create(childSubject, HAS_PARENT.asNode(), subject()),
create(subject(), CONTAINS.asNode(), childSubject));
}

return childStream;
Expand Down
Expand Up @@ -83,8 +83,6 @@ public void testParentTriples() throws RepositoryException, IOException {
logRdf("Retrieved RDF for testParentTriples(): ", actual);
assertTrue("Node doesn't have a parent!", actual.contains(testSubject,
HAS_PARENT, testParentSubject));
assertTrue("Node doesn't have a parent!", actual.contains(
testParentSubject, HAS_CHILD, testSubject));
}

@Test
Expand Down
Expand Up @@ -23,7 +23,6 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createTypedLiteral;
import static com.hp.hpl.jena.vocabulary.RDF.type;
import static java.lang.Boolean.TRUE;
import static java.util.Arrays.asList;
import static javax.jcr.PropertyType.BINARY;
import static javax.jcr.PropertyType.NAME;
Expand All @@ -39,7 +38,6 @@
import static org.fcrepo.kernel.RdfLexicon.HAS_MESSAGE_DIGEST;
import static org.fcrepo.kernel.RdfLexicon.HAS_NAMESPACE_PREFIX;
import static org.fcrepo.kernel.RdfLexicon.HAS_NAMESPACE_URI;
import static org.fcrepo.kernel.RdfLexicon.HAS_PARENT;
import static org.fcrepo.kernel.RdfLexicon.HAS_SIZE;
import static org.fcrepo.kernel.RdfLexicon.HAS_VERSION;
import static org.fcrepo.kernel.RdfLexicon.HAS_VERSION_LABEL;
Expand Down Expand Up @@ -74,10 +72,8 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

import javax.jcr.Node;
Expand Down Expand Up @@ -111,7 +107,6 @@
import org.fcrepo.kernel.services.LowLevelStorageService;
import org.fcrepo.kernel.testutilities.TestPropertyIterator;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.modeshape.jcr.api.NamespaceRegistry;
Expand Down Expand Up @@ -334,7 +329,7 @@ public void shouldIncludeFullChildNodeInformationInsideWindow()
final Model actual =
testObj.getTreeTriples(mockNode, options).asModel();
assertEquals(2, Iterators.size(actual
.listSubjectsWithProperty(HAS_PARENT)));
.listObjectsOfProperty(testSubjects.getSubject(mockNode.getPath()), HAS_CHILD)));
verify(mockChildNode, never()).getProperties();
}

Expand Down

0 comments on commit 2d49b77

Please sign in to comment.