Class ViewHelpers
java.lang.Object
org.fcrepo.http.commons.responses.ViewHelpers
General view helpers for rendering HTML responses
- Author:
- awoods, ajs6f
-
Method Summary
Modifier and TypeMethodDescriptionintaddOne(int i) Yes, we really did create a method to increment a given int.org.apache.jena.graph.NodeConvert a URI string to an RDF nodestatic org.apache.jena.graph.NodeCreate a URI Node from the provided Stringstatic org.apache.jena.graph.NodegetContentNode(org.apache.jena.graph.Node subject) Get the content-bearing node for the given subjectstatic ViewHelpersViewHelpers is a singleton.getNamespacePrefix(org.apache.jena.shared.PrefixMapping mapping, String ns, boolean compact) Get the namespace prefix (or the namespace URI itself, if no prefix is available) from a prefix mappinggetNodeBreadcrumbs(javax.ws.rs.core.UriInfo uriInfo, org.apache.jena.graph.Node subject) Generate url to local name breadcrumbs for a given node's treeintgetNumChildren(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Get the number of child resources associated with the arg 'subject' as specified by the triple found in the arg 'graph' with the predicate RdfLexicon.HAS_CHILD_COUNT.getObjectsAsString(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.rdf.model.Resource predicate, boolean uriAsLink) Get the string version of the object that matches the given subject and predicategetObjectTitle(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node sub) Get the canonical title of a subject from the graphIterator<org.apache.jena.graph.Node> getOrderedVersions(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node subject, org.apache.jena.rdf.model.Resource predicate) Return an iterator of Triples for versions in order that they were created.org.apache.jena.graph.NodegetOriginalResource(String subjectUri) Same as above but takes a string.org.apache.jena.graph.NodegetOriginalResource(org.apache.jena.graph.Node subject) Returns the original resource as a URI Node if the subject represents a memento uri; otherwise it returns the subject parameter.getPrefixPreamble(org.apache.jena.shared.PrefixMapping mapping) Get a prefix preamble appropriate for a SPARQL-UPDATE query from a prefix mapping objectgetResourceId(org.apache.jena.rdf.model.Resource res) Get the ID of a resource, this is the URI, blank node ID or just the local name.List<org.apache.jena.graph.Triple> getSortedTriples(org.apache.jena.rdf.model.Model model, Iterator<org.apache.jena.graph.Triple> it) Sort a Iterator of Triples alphabetically by its subject, predicate, and objectstatic StringFind a key in a map and format it as a stringgetVersionDate(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Gets a modification date of a subject from the graphgetVersionLabel(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Get the date time as the version label.Iterator<org.apache.jena.graph.Node> getVersions(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Return an iterator of Triples for versions.getVersionSubjectUrl(javax.ws.rs.core.UriInfo uriInfo, org.apache.jena.graph.Node subject) Gets the URL of the node whose version is represented by the current node.static booleanisManagedProperty(org.apache.jena.graph.Node property) Test if a Predicate is managedbooleanisRdfResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, String namespace, String resource) Determines whether the subject is kind of RDF resourcebooleanisRootResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Is the subject the repository root resource.booleanisVersionedNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Determines whether the subject is of type memento:Memento.booleanisWritable(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Determines whether the subject is writable true if node is writablestatic Stringparameterize(String source) Transform a source string to something appropriate for HTML idsorg.apache.jena.rdf.model.ResourceProxying access to the RDFS class static propertyorg.apache.jena.rdf.model.PropertyProxying access to the RDFS domain static propertyorg.apache.jena.rdf.model.PropertyrdfType()Proxying access to the RDF type static property
-
Method Details
-
getInstance
ViewHelpers is a singleton. Initialize or return the existing object- Returns:
- an instance of ViewHelpers
-
getVersions
public Iterator<org.apache.jena.graph.Node> getVersions(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Return an iterator of Triples for versions.- Parameters:
graph- the graphsubject- the subject- Returns:
- iterator
-
getOrderedVersions
public Iterator<org.apache.jena.graph.Node> getOrderedVersions(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node subject, org.apache.jena.rdf.model.Resource predicate) Return an iterator of Triples for versions in order that they were created.- Parameters:
g- the graphsubject- the subjectpredicate- the predicate- Returns:
- iterator
-
getVersionSubjectUrl
public String getVersionSubjectUrl(javax.ws.rs.core.UriInfo uriInfo, org.apache.jena.graph.Node subject) Gets the URL of the node whose version is represented by the current node. The current implementation assumes the URI of that node will be the same as the breadcrumb entry that precedes one with the path "fcr:versions".- Parameters:
uriInfo- the uri infosubject- the subject- Returns:
- the URL of the node
-
getVersionLabel
public String getVersionLabel(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Get the date time as the version label.- Parameters:
graph- the graphsubject- the subject- Returns:
- the datetime in RFC 1123 format.
-
getVersionDate
public Instant getVersionDate(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Gets a modification date of a subject from the graph- Parameters:
graph- the graphsubject- the subject- Returns:
- the modification date if it exists
-
getObjectTitle
Get the canonical title of a subject from the graph- Parameters:
graph- the graphsub- the subject- Returns:
- canonical title of the subject in the graph
-
getResourceId
Get the ID of a resource, this is the URI, blank node ID or just the local name. Used in resource.vsl- Parameters:
res- The resource to get the ID for- Returns:
- The ID as a string.
-
isWritable
Determines whether the subject is writable true if node is writable- Parameters:
graph- the graphsubject- the subject- Returns:
- whether the subject is writable
-
isVersionedNode
public boolean isVersionedNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Determines whether the subject is of type memento:Memento.- Parameters:
graph- the graphsubject- the subject- Returns:
- whether the subject is a versioned node
-
getObjectsAsString
public String getObjectsAsString(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.rdf.model.Resource predicate, boolean uriAsLink) Get the string version of the object that matches the given subject and predicate- Parameters:
graph- the graphsubject- the subjectpredicate- the predicateuriAsLink- the boolean value of uri as link- Returns:
- string version of the object
-
getOriginalResource
Returns the original resource as a URI Node if the subject represents a memento uri; otherwise it returns the subject parameter.- Parameters:
subject- the subject- Returns:
- a URI node of the original resource.
-
getOriginalResource
Same as above but takes a string. NB: This method is currently used in fcrepo-http-api/src/main/resources/views/default.vsl- Parameters:
subjectUri- the URI- Returns:
- a node
-
getNumChildren
Get the number of child resources associated with the arg 'subject' as specified by the triple found in the arg 'graph' with the predicate RdfLexicon.HAS_CHILD_COUNT.- Parameters:
graph- of triplessubject- for which child resources is sought- Returns:
- number of child resources
-
getNodeBreadcrumbs
public Map<String,String> getNodeBreadcrumbs(javax.ws.rs.core.UriInfo uriInfo, org.apache.jena.graph.Node subject) Generate url to local name breadcrumbs for a given node's tree- Parameters:
uriInfo- the uri infosubject- the subject- Returns:
- breadcrumbs
-
getSortedTriples
public List<org.apache.jena.graph.Triple> getSortedTriples(org.apache.jena.rdf.model.Model model, Iterator<org.apache.jena.graph.Triple> it) Sort a Iterator of Triples alphabetically by its subject, predicate, and object- Parameters:
model- the modelit- the iterator of triples- Returns:
- iterator of alphabetized triples
-
isRdfResource
public boolean isRdfResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, String namespace, String resource) Determines whether the subject is kind of RDF resource- Parameters:
graph- the graphsubject- the subjectnamespace- the namespaceresource- the resource- Returns:
- whether the subject is kind of RDF resource
-
isRootResource
public boolean isRootResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject) Is the subject the repository root resource.- Parameters:
graph- The graphsubject- The current subject- Returns:
- true if has rdf:type http://fedora.info/definitions/v4/repository#RepositoryRoot
-
asLiteralStringNode
Convert a URI string to an RDF node- Parameters:
r- the uri string- Returns:
- RDF node representation of the given string
-
addOne
Yes, we really did create a method to increment a given int. You can't do math in a velocity template.- Parameters:
i- the given integer- Returns:
- maths
-
rdfType
Proxying access to the RDF type static property- Returns:
- RDF type property
-
rdfsDomain
Proxying access to the RDFS domain static property- Returns:
- RDFS domain property
-
rdfsClass
Proxying access to the RDFS class static property- Returns:
- RDFS class resource
-
getContentNode
Get the content-bearing node for the given subject- Parameters:
subject- the subject- Returns:
- content-bearing node for the given subject
-
createURI
Create a URI Node from the provided String- Parameters:
uri- from which a URI Node will be created- Returns:
- URI Node
-
parameterize
Transform a source string to something appropriate for HTML ids- Parameters:
source- the source string- Returns:
- transformed source string
-
isManagedProperty
Test if a Predicate is managed- Parameters:
property- the property- Returns:
- whether the property is managed
-
getString
Find a key in a map and format it as a string- Parameters:
input- map of objects.key- the key to locate in the map.- Returns:
- the result string.
-