org.eaglei.repository.model
Class NamedGraph

java.lang.Object
  extended by org.eaglei.repository.model.ImmutableObjectModel
      extended by org.eaglei.repository.model.WritableObjectModel
          extended by org.eaglei.repository.model.NamedGraph
All Implemented Interfaces:
java.lang.Comparable<NamedGraph>

@HasContentCache
public final class NamedGraph
extends WritableObjectModel
implements java.lang.Comparable<NamedGraph>

 Named Graph object model, collects metadata about the named graph
 stored in repo's intenal metadata graph.  NG is implemented as a Sesame
 context, named by the "name" URI.  It has these attributes:
  * name - URI of the context
  * label - text string to describe graph to users
  * graph type - enum identifying hte purpose of its contents
  * provenance metadata
  * access control (admin metadata)

 

Author:
Larry Stone Started June 7, 2010

Method Summary
 int compareTo(NamedGraph o)
          
static void decache()
          Invalidate the entire NG cache, called when RDF has changed.
 void decacheInstance()
          Invalidate local cache after changes to RDF.
 boolean equals(java.lang.Object b)
          Consider two NGs equal if the names are equal, never mind the metadata.
static NamedGraph find(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI name)
          Returns a named graph object, or null if this is not a valid named graph OR context.
static java.util.List<NamedGraph> findAll(javax.servlet.http.HttpServletRequest request)
          Get an iterable collection of all known named graphs AND Contexts.
static NamedGraph findOrCreate(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI name, boolean createp)
          Returns a named graph object, or null if this is not a valid named graph OR context and createp was false.
 java.lang.String getLabel()
          Getter for the field label.
 long getSize(javax.servlet.http.HttpServletRequest request)
          Return the number of non-inferred statements in the named graph.
 NamedGraphType getType()
          Getter for the field type.
 java.lang.String getTypeLabel()
          Getter for the field typeLabel.
 org.openrdf.model.URI getTypeURI()
          Getter for the field type, but returns URI form.
 org.openrdf.model.URI getURI()
          Getter for the field name.
 int hashCode()
          
 boolean isAnonymousReadable()
          Can be read by anonymous user (i.e.
 boolean isManaged()
          When true, graph has metadata and is managed by repository.
 void setLabel(javax.servlet.http.HttpServletRequest request, java.lang.String nl)
          Setter for the field label.
 void setType(javax.servlet.http.HttpServletRequest request, NamedGraphType nt)
          Setter for the field type.
 void setType(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI nt)
          Setter for the field type.
 void update(javax.servlet.http.HttpServletRequest request)
          This gets called to force out changes, but not "commit" them.
 
Methods inherited from class org.eaglei.repository.model.WritableObjectModel
commit, isDirty, setDirty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

decache

public static void decache()
Invalidate the entire NG cache, called when RDF has changed. It's cheap enough to reload, and changes are very infrequent.


decacheInstance

public void decacheInstance()
Invalidate local cache after changes to RDF.

Overrides:
decacheInstance in class WritableObjectModel

update

public void update(javax.servlet.http.HttpServletRequest request)
            throws javax.servlet.ServletException
This gets called to force out changes, but not "commit" them. If anything actually changed, decache.

Overrides:
update in class WritableObjectModel
Parameters:
request - the HTTP request object from the servlet
Throws:
javax.servlet.ServletException

findAll

public static java.util.List<NamedGraph> findAll(javax.servlet.http.HttpServletRequest request)
                                          throws javax.servlet.ServletException
Get an iterable collection of all known named graphs AND Contexts. If there is no Named Graph metadata for a Sesame context, its isManaged() method will return false. Note that named graphs are ONLY listed ONCE even if there is duplicate metadata.

Parameters:
request - a HttpServletRequest object.
Returns:
all named graphs in a Collection object.
Throws:
javax.servlet.ServletException - if any.

find

public static NamedGraph find(javax.servlet.http.HttpServletRequest request,
                              org.openrdf.model.URI name)
                       throws javax.servlet.ServletException
Returns a named graph object, or null if this is not a valid named graph OR context.

Parameters:
request - a HttpServletRequest object.
name - name of named-graph or context, a URI object.
Returns:
a org.eaglei.repository.NamedGraph object representing named graph, or null if no graph or context exists.
Throws:
javax.servlet.ServletException - if any problems

findOrCreate

public static NamedGraph findOrCreate(javax.servlet.http.HttpServletRequest request,
                                      org.openrdf.model.URI name,
                                      boolean createp)
                               throws javax.servlet.ServletException
Returns a named graph object, or null if this is not a valid named graph OR context and createp was false.

Parameters:
request - a HttpServletRequest object.
name - name of named-graph or context, a URI object.
createp - a boolean, true if graph should be created
Returns:
a org.eaglei.repository.NamedGraph object representing named graph, or null if no graph or context exists UNLESS createp is true.
Throws:
javax.servlet.ServletException - if any problems.

getURI

public org.openrdf.model.URI getURI()

Getter for the field name.

Specified by:
getURI in class ImmutableObjectModel
Returns:
a URI object.

getLabel

public java.lang.String getLabel()

Getter for the field label.

Specified by:
getLabel in class ImmutableObjectModel
Returns:
a String object.

getType

public NamedGraphType getType()

Getter for the field type.

Returns:
a URI object.

getTypeURI

public org.openrdf.model.URI getTypeURI()

Getter for the field type, but returns URI form.

Returns:
a URI object.

getTypeLabel

public java.lang.String getTypeLabel()

Getter for the field typeLabel.

Returns:
a String object.

isAnonymousReadable

public boolean isAnonymousReadable()
Can be read by anonymous user (i.e. general public) if true.

Returns:
a boolean, true if graph is publically readable.

getSize

public long getSize(javax.servlet.http.HttpServletRequest request)
             throws javax.servlet.ServletException
Return the number of non-inferred statements in the named graph.

Returns:
count of non-inferred statements in the named graph.
Throws:
javax.servlet.ServletException

isManaged

public boolean isManaged()
When true, graph has metadata and is managed by repository. False for unmanaged sesame contexts.

Returns:
a boolean, true when graph is known NamedGraph.

setLabel

public void setLabel(javax.servlet.http.HttpServletRequest request,
                     java.lang.String nl)
              throws javax.servlet.ServletException

Setter for the field label.

Parameters:
request - a HttpServletRequest object.
nl - a String object.
Throws:
javax.servlet.ServletException - if any.

setType

public void setType(javax.servlet.http.HttpServletRequest request,
                    org.openrdf.model.URI nt)
             throws javax.servlet.ServletException

Setter for the field type.

Parameters:
request - a HttpServletRequest object.
nt - a org.eaglei.repository.NamedGraph.NamedGraphType object.
Throws:
javax.servlet.ServletException - if any.

setType

public void setType(javax.servlet.http.HttpServletRequest request,
                    NamedGraphType nt)
             throws javax.servlet.ServletException

Setter for the field type.

Parameters:
request - a HttpServletRequest object.
nt - a URI object.
Throws:
javax.servlet.ServletException - if any.

equals

public boolean equals(java.lang.Object b)
Consider two NGs equal if the names are equal, never mind the metadata.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(NamedGraph o)

Specified by:
compareTo in interface java.lang.Comparable<NamedGraph>


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