org.eaglei.repository
Class Provenance

java.lang.Object
  extended by org.eaglei.repository.Provenance

public class Provenance
extends java.lang.Object

Utility class to manage provenance metadata on all objects. An instance is attached to a resource URI, typically either a named graph or eagle-i resource instance, which it describes. Methods that change the "last modified" date of anything also update the global last-modified timestamp, maintained by the DataRepository singleton.

Version:
$Id: $
Author:
Larry Stone

Field Summary
static org.openrdf.model.URI PROVENANCE_GRAPH
          Graph where provenance metadata is stored.
 
Constructor Summary
Provenance(org.openrdf.model.URI uri)
          Return the singleton instance.
 
Method Summary
static org.openrdf.model.Literal getDateTime(java.util.Date when)
          Utility translation method, returns typed literal of specified moment
 java.lang.String getField(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI field)
          commit - commit any changes made to this object (and any others)
 java.lang.String getLabel(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI field)
          Labels for provenance value URIs are stored in the same map as fields
static boolean isProvenancePredicate(org.openrdf.model.URI pp)
          True if URI is a provenance predicate, this function is really a predicate predicate.
 void setCreated(javax.servlet.http.HttpServletRequest request, java.util.Date when)
          Convenience method to set Created provenance values, upon creation.
 void setMediated(javax.servlet.http.HttpServletRequest request, java.util.Date when)
          Convenience method to set provenance values for "mediated" creation, i.e.
 void setModified(javax.servlet.http.HttpServletRequest request, java.util.Date when)
          Convenience method to set provenance values upon last modification.
 void setProvenance(org.openrdf.repository.RepositoryConnection rc, org.openrdf.model.URI term, org.openrdf.model.Value value)
          Set provenance values directly, bypass e.g.
 void setSource(javax.servlet.http.HttpServletRequest request, java.lang.String source, java.util.Date sourceModified)
          Add/replace the Source provenance fields: dcterms:source -> bnode dcterms:identifier -> filename or URI it came from dcterms:modified -> last-mod date of source
 void setSource(org.openrdf.repository.RepositoryConnection rc, org.openrdf.model.Value source, org.openrdf.model.Value sourceModified)
          Convenience method to set source provenance: identifier and last-mod time of resource ingested into a graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVENANCE_GRAPH

public static final org.openrdf.model.URI PROVENANCE_GRAPH
Graph where provenance metadata is stored.

Constructor Detail

Provenance

public Provenance(org.openrdf.model.URI uri)
Return the singleton instance.

Method Detail

isProvenancePredicate

public static boolean isProvenancePredicate(org.openrdf.model.URI pp)
True if URI is a provenance predicate, this function is really a predicate predicate. only in RDF.

Parameters:
pp - a URI object.
Returns:
true if pp names a provenance predicate.

setCreated

public void setCreated(javax.servlet.http.HttpServletRequest request,
                       java.util.Date when)
Convenience method to set Created provenance values, upon creation. Also sets Modified provenance metadata automatically, since the last-modified date is used to judge when a resource needs to be re-indexed.

Parameters:
request - a HttpServletRequest object.
when - time at which it was created

setMediated

public void setMediated(javax.servlet.http.HttpServletRequest request,
                        java.util.Date when)
Convenience method to set provenance values for "mediated" creation, i.e. when instance already contains a dcterms:creator that has to be preserved. Record the creating user as dcterms:mediator instead.

Parameters:
request - a HttpServletRequest object.
when - time at which it was created

setModified

public void setModified(javax.servlet.http.HttpServletRequest request,
                        java.util.Date when)
Convenience method to set provenance values upon last modification.

Parameters:
request - a HttpServletRequest object.
when - time at which it was last modified

setProvenance

public void setProvenance(org.openrdf.repository.RepositoryConnection rc,
                          org.openrdf.model.URI term,
                          org.openrdf.model.Value value)
Set provenance values directly, bypass e.g. the automatic use of current authenticated user. Needed on rare occasions such as bootstrap graph setup where the actor is the system itself. THIS IS DANGEROUS, since it does NOT type-check that the value of a time property (e.g. dcterms:modified) is a calendar literal.

Parameters:
rc - a RepositoryConnection object.
term - provenance predicate, a URI object.
value - a Value object.

setSource

public void setSource(javax.servlet.http.HttpServletRequest request,
                      java.lang.String source,
                      java.util.Date sourceModified)
Add/replace the Source provenance fields: dcterms:source -> bnode dcterms:identifier -> filename or URI it came from dcterms:modified -> last-mod date of source

Parameters:
request - a HttpServletRequest object.
source - value of identifier, a String object.
sourceModified - mod time for source or null if unknown.

setSource

public void setSource(org.openrdf.repository.RepositoryConnection rc,
                      org.openrdf.model.Value source,
                      org.openrdf.model.Value sourceModified)
Convenience method to set source provenance: identifier and last-mod time of resource ingested into a graph. This is worth the trouble since it is useful to test for graphs that need updating. THIS IS DANGEROUS, since it does NOT type-check that the value of a time property (e.g. dcterms:modified) is a calendar literal.

Parameters:
rc - a RepositoryConnection object.
source - value of identifier, a String object.
sourceModified - mod time for source or null if unknown.

getDateTime

public static org.openrdf.model.Literal getDateTime(java.util.Date when)
Utility translation method, returns typed literal of specified moment

Parameters:
when - a Date object.
Returns:
specified 'when' as a Literal object.

getField

public java.lang.String getField(javax.servlet.http.HttpServletRequest request,
                                 org.openrdf.model.URI field)

commit - commit any changes made to this object (and any others)

Parameters:
request - a HttpServletRequest object.
field - the URI of the metadata field
Returns:
value of the field or null if not set
Throws:
javax.servlet.ServletException - if any.

getLabel

public java.lang.String getLabel(javax.servlet.http.HttpServletRequest request,
                                 org.openrdf.model.URI field)
Labels for provenance value URIs are stored in the same map as fields



Copyright © 2009-2010 Eagle-I. All Rights Reserved.