Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improving comments, very minor cleanup
  • Loading branch information
escowles committed Jul 31, 2015
1 parent 8a2e747 commit db621e7
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 27 deletions.
Expand Up @@ -28,6 +28,8 @@
import static org.fcrepo.kernel.api.RdfLexicon.WRITABLE;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s
* indicating whether this resource is writable or not.
* @author cabeer
* @since 10/1/14
*/
Expand Down
Expand Up @@ -33,6 +33,8 @@
import static org.slf4j.LoggerFactory.getLogger;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link Triple}s linking from this resource
* to its child nodes.
* @author cabeer
* @author ajs6f
* @since 9/16/14
Expand Down
Expand Up @@ -28,6 +28,8 @@
import com.hp.hpl.jena.rdf.model.Resource;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s linking
* between a content node and its description.
* @author cabeer
* @author ajs6f
* @since 10/16/14
Expand All @@ -45,13 +47,11 @@ public ContentRdfContext(final FedoraResource resource,

// if there's an accessible jcr:content node, include information about it
if (resource instanceof NonRdfSourceDescription) {
final FedoraResource contentNode = ((NonRdfSourceDescription) resource()).getDescribedResource();
final Node subject = uriFor(resource());
final Node contentSubject = uriFor(contentNode);
// add triples representing parent-to-content-child relationship
concat(create(subject, DESCRIBES.asNode(), contentSubject));

// add triple representing parent-to-content-child relationship
final Node contentSubject = uriFor(((NonRdfSourceDescription) resource()).getDescribedResource());
concat(create(uriFor(resource()), DESCRIBES.asNode(), contentSubject));
} else if (resource instanceof FedoraBinary) {
// add triple linking from the resource to its description
final FedoraResource description = ((FedoraBinary) resource).getDescription();
concat(create(uriFor(resource), DESCRIBED_BY.asNode(), uriFor(description)));
}
Expand Down
Expand Up @@ -29,6 +29,8 @@
import static org.fcrepo.kernel.modeshape.identifiers.NodeResourceConverter.nodeConverter;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s about
* child nodes of the special "#" node, representing their subjects as hash URIs.
* @author cabeer
* @author ajs6f
* @since 10/9/14
Expand Down
Expand Up @@ -53,6 +53,8 @@
import static org.slf4j.LoggerFactory.getLogger;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link Triple}s linking from LDP
* DirectContainers or IndirectContainers to their members.
* @author cabeer
* @author ajs6f
* @since 9/25/14
Expand Down Expand Up @@ -88,32 +90,37 @@ private Iterator<Triple> membershipContext(final Iterator<Property> properties)
}

/**
* Get the member relations assert on the subject by the given node
* @param container
* Get the member relations asserted on the subject by the given node
* @param container to check for members
* @return
* @throws RepositoryException
*/
private Iterator<Triple> memberRelations(final FedoraResource container) throws RepositoryException {
final com.hp.hpl.jena.graph.Node memberRelation;

if (container.hasProperty(LDP_HAS_MEMBER_RELATION)) {
// if there is an ldp:memberRelation property, use its value as the predicate
final Property property = container.getProperty(LDP_HAS_MEMBER_RELATION);
memberRelation = createURI(property.getString());
} else if (container.hasType(LDP_BASIC_CONTAINER)) {
// otherwise, use ldp:hasMember for BasicContainers
memberRelation = LDP_MEMBER.asNode();
} else {
// if we can't find a suitable predicate, then there's nothing for us to do
return emptyIterator();
}

final String insertedContainerProperty;

if (container.hasType(LDP_INDIRECT_CONTAINER)) {
if (container.hasProperty(LDP_INSERTED_CONTENT_RELATION)) {
// IndirectContainers should declare the insertedContentRelation to identify the container
insertedContainerProperty = container.getProperty(LDP_INSERTED_CONTENT_RELATION).getString();
} else {
return emptyIterator();
}
} else {
// other containers used a fixed property
insertedContainerProperty = MEMBER_SUBJECT.getURI();
}

Expand All @@ -123,8 +130,11 @@ private Iterator<Triple> memberRelations(final FedoraResource container) throws
? uriFor(((NonRdfSourceDescription) child).getDescribedResource()) : uriFor(child);

if (insertedContainerProperty.equals(MEMBER_SUBJECT.getURI())) {
// in the simple case, we can create the link
return singletonIterator(create(subject(), memberRelation, childSubject));
}

// for IndirectContainers, we need to find the property or an inbound reference to it
String insertedContentProperty = getPropertyNameFromPredicate(resource().getNode(),
createResource(insertedContainerProperty), null);

Expand Down
Expand Up @@ -42,6 +42,8 @@
import static org.fcrepo.kernel.modeshape.rdf.impl.ReferencesRdfContext.REFERENCE_TYPES;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s linking
* to LDP Containers from their members.
* @author cabeer
* @author ajs6f
* @since 10/7/14
Expand Down
Expand Up @@ -32,6 +32,7 @@
import com.hp.hpl.jena.rdf.model.Resource;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains RDF type {@link Triple}s for LDP resources.
* @author cabeer
* @since 9/16/14
*/
Expand Down
Expand Up @@ -70,7 +70,7 @@ public FedoraResource resource() {
}

/**
* @return local {@link org.fcrepo.kernel.api.identifiers.IdentifierConverter}
* @return local {@link org.fcrepo.kernel.api.identifiers.IdentifierConverter} to convert URIs to FedoraResources.
*/
public IdentifierConverter<Resource, FedoraResource> translator() {
return idTranslator;
Expand All @@ -85,7 +85,7 @@ protected com.hp.hpl.jena.graph.Node uriFor(final FedoraResource resource) {
}

/**
* @return local {@link org.fcrepo.kernel.api.identifiers.IdentifierConverter}
* @return local {@link org.fcrepo.kernel.api.identifiers.IdentifierConverter} to convert JCR Nodes to URIs.
*/
public Converter<Node, Resource> nodeConverter() {
return nodeToResource(idTranslator);
Expand Down
Expand Up @@ -49,7 +49,7 @@
import javax.jcr.nodetype.NodeTypeManager;

/**
* Assemble {@link Triple}s derived from the {@link NodeType}s in a repository.
* {@link RdfStream} that contains {@link Triple}s derived from the {@link NodeType}s in a repository.
*
* @author cbeer
*/
Expand Down
Expand Up @@ -28,6 +28,8 @@
import static org.slf4j.LoggerFactory.getLogger;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s linking
* from a resource to its parent.
* @author cabeer
* @author ajs6f
* @since 9/16/14
Expand Down
Expand Up @@ -41,7 +41,8 @@
import java.util.function.Function;

/**
* Accumulate inbound references to a given resource
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains inbound references ({@link Triple}s linking
* to this resource from other resources), including references managed by LDP Containers.
*
* @author cabeer
* @author escowles
Expand All @@ -65,19 +66,13 @@ public ReferencesRdfContext(final FedoraResource resource,
throws RepositoryException {
super(resource, idTranslator);
property2triple = new PropertyToTriple(resource.getNode().getSession(), idTranslator);
putReferencesIntoContext(resource.getNode());
concat(flatMap(allReferences(resource.getNode()), property2triple));
concat(flatMap(flatMap( allReferences(resource.getNode()), potentialProxies), triplesForValue));
}

private void putReferencesIntoContext(final Node node) throws RepositoryException {
Iterator<Property> references = node.getReferences();
Iterator<Property> weakReferences = node.getWeakReferences();
Iterator<Property> allReferences = Iterators.concat(references, weakReferences);
concat(flatMap(allReferences, property2triple));

references = node.getReferences();
weakReferences = node.getWeakReferences();
allReferences = Iterators.concat(references, weakReferences);
concat(flatMap(flatMap( allReferences, potentialProxies), triplesForValue));
/* Get a combined iterator of inbound references and weak references. */
private static Iterator<Property> allReferences(final Node node) throws RepositoryException {
return Iterators.concat(node.getReferences(), node.getWeakReferences());
}

/* References from LDP indirect containers are generated dynamically by LdpContainerRdfContext, so they won't
Expand Down
Expand Up @@ -46,7 +46,8 @@
import com.hp.hpl.jena.graph.Triple;

/**
* Assemble {@link Triple}s derived from the root of a repository.
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link Triple}s derived from the root of a
* repository, including repository configuration and metrics.
*
* @author ajs6f
* @since Oct 18, 2013
Expand Down
Expand Up @@ -39,7 +39,8 @@
import static org.fcrepo.kernel.modeshape.utils.FedoraTypesUtils.isBlankNode;

/**
* Embed triples describing all skolem nodes in the RDF stream
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains {@link com.hp.hpl.jena.graph.Triple}s
* describing all skolem nodes (blank nodes that have been assigned identifiers) in the RDF stream.
*
* @author cabeer
* @author ajs6f
Expand Down
Expand Up @@ -43,6 +43,8 @@
import static org.slf4j.LoggerFactory.getLogger;

/**
* {@link org.fcrepo.kernel.api.utils.iterators.RdfStream} that contains RDF type {@link Triple}s for the resource's
* primary type and mixins.
* @author cabeer
* @author ajs6f
* @since 10/1/14
Expand Down
Expand Up @@ -45,8 +45,7 @@


/**
* {@link RdfStream} that supplies {@link Triple}s concerning
* the versions of a selected {@link Node}.
* {@link RdfStream} that contains {@link Triple}s about the versions of a selected {@link Node}.
*
* @author ajs6f
* @since Oct 15, 2013
Expand Down

0 comments on commit db621e7

Please sign in to comment.