org.openrdf.elmo.sesame
Class SesameManager

java.lang.Object
  extended by org.openrdf.elmo.sesame.SesameManager
All Implemented Interfaces:
EntityManager, ElmoManager
Direct Known Subclasses:
HiveMindSesameManager

public class SesameManager
extends Object
implements ElmoManager, EntityManager

Handles operations of ElmoManager and EntityManager.

Author:
James Leigh

Constructor Summary
SesameManager()
           
 
Method Summary
 QName asQName(Resource resource)
          Deprecated. 
 void clear()
           
 void close()
          Closes any transactions or connections in the manager.
 void close(Iterator<?> iter)
          Close an Iterator created by iterate() immediately, instead of waiting until the iteration is complete or connection is closed.
 boolean contains(Object entity)
          Check if the instance belongs to the current persistence context.
<T> T
create(Class<T> concept, Class<?>... concepts)
          Assigns type to a new anonymous entity.
<T> T
create(QName qname, Class<T> concept, Class<?>... concepts)
          Assigns concept to the new named entity.
 Memento createMemento()
          Creates a new Memento Object that represents the current state of the Bean pool.
 Query createNamedQuery(String name)
           
 SesameQuery createNativeQuery(String serql)
           
 SesameQuery createNativeQuery(String serql, Class concept)
           
 SesameQuery createNativeQuery(String serql, String nil)
           
 SesameQuery createQuery(String query)
          Creates an ElmoQuery to evaluate the query string.
<T> T
designate(Class<T> concept, Class<?>... concepts)
          Deprecated. 
<T> T
designate(Class<T> concept, QName qname)
          Deprecated. 
<T> T
designate(Class<T> concept, Resource resource)
          Deprecated. 
<T> T
designate(QName qname, Class<T> concept, Class<?>... concepts)
          Assigns concept to the named entity subject.
<T> T
designate(Resource resource, Class<T> concept, Class<?>... concepts)
           
<T> T
designateEntity(Class<T> concept, Object entity)
          Deprecated. 
<T> T
designateEntity(Object entity, Class<T> concept, Class<?>... concepts)
          Assigns concept to the given entity and return a new object reference that implements the given concept.
<T> T
find(Class<T> concept, Object qname)
           
 SesameEntity find(QName qname)
          Retrieves the rdf:type, creates a Java Bean class and instantiates it.
 SesameEntity find(Resource resource)
           
<T> Iterable<T>
findAll(Class<T> javaClass)
          Creates an iteration of entities that implement this role.
 void flush()
           
 ContextAwareConnection getConnection()
           
 Object getDelegate()
           
 FlushModeType getFlushMode()
           
 Object getInstance(Value value)
           
 String getLanguage()
           
 LiteralManager<URI,Literal> getLiteralManager()
           
 Locale getLocale()
          Locale this manager was created with.
 Value getLocalizedValue(Object instance)
           
<T> T
getReference(Class<T> concept, Object qname)
           
 ResourceManager<Resource> getResourceManager()
           
 RoleMapper<URI> getRoleMapper()
           
 EntityTransaction getTransaction()
          Returns the resource-level transaction object.
 Value getValue(Object instance)
           
 boolean isOpen()
          If this manager currently has an open connection to the repository.
 void joinTransaction()
           
 void lock(Object entity, LockModeType mode)
           
<T> T
merge(T bean)
          Copies all non-null values from bean into an entity managed by this manager.
 void persist(Object bean)
          Copies all non-null values from bean into an entity managed by this manager.
 void redoMemento(Memento memento)
          Replays changes made after this memento object was created.
 void refresh(Object entity)
          If entity implements Refreshable, its method Refreshable.refresh() will be called.
 void remove(Object entity)
          Removes the given entity or subject and all implementing roles.
 Entity removeDesignation(Class<?> concept, Object entity)
          Deprecated. 
 Entity removeDesignation(Object entity, Class<?>... concepts)
          Removes the concept designation from this entity.
<T> T
rename(T bean, QName qname)
          Removes all the references to the given entity and replaces them with references to the new qname.
<T> T
rename(T bean, Resource dest)
           
 void setConnection(ContextAwareConnection connection)
           
 void setFlushMode(FlushModeType mode)
           
 void setLiteralManager(LiteralManager<URI,Literal> manager)
           
 void setLocale(Locale locale)
           
 void setResourceManager(ResourceManager<Resource> manager)
           
 void setRoleMapper(RoleMapper<URI> mapper)
           
 void undoMemento(Memento memento)
          Rolls-back any changes made after this memento object was created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SesameManager

public SesameManager()
Method Detail

getConnection

public ContextAwareConnection getConnection()

setConnection

public void setConnection(ContextAwareConnection connection)

getTransaction

public EntityTransaction getTransaction()
Description copied from interface: ElmoManager
Returns the resource-level transaction object. The EntityTransaction instance may be used serially to begin and commit multiple transactions.

Specified by:
getTransaction in interface EntityManager
Specified by:
getTransaction in interface ElmoManager
Returns:
EntityTransaction instance

joinTransaction

public void joinTransaction()
Specified by:
joinTransaction in interface EntityManager

getLocale

public Locale getLocale()
Description copied from interface: ElmoManager
Locale this manager was created with.

Specified by:
getLocale in interface ElmoManager
Returns:
Locale or null

setLocale

public void setLocale(Locale locale)

getLanguage

public String getLanguage()

getResourceManager

public ResourceManager<Resource> getResourceManager()

setResourceManager

public void setResourceManager(ResourceManager<Resource> manager)

getLiteralManager

public LiteralManager<URI,Literal> getLiteralManager()

setLiteralManager

public void setLiteralManager(LiteralManager<URI,Literal> manager)

getRoleMapper

public RoleMapper<URI> getRoleMapper()

setRoleMapper

public void setRoleMapper(RoleMapper<URI> mapper)

isOpen

public boolean isOpen()
Description copied from interface: ElmoManager
If this manager currently has an open connection to the repository.

Specified by:
isOpen in interface EntityManager
Specified by:
isOpen in interface ElmoManager
Returns:
true if the connection is open.

close

public void close()
Description copied from interface: ElmoManager
Closes any transactions or connections in the manager.

Specified by:
close in interface EntityManager
Specified by:
close in interface ElmoManager

close

public void close(Iterator<?> iter)
Description copied from interface: ElmoManager
Close an Iterator created by iterate() immediately, instead of waiting until the iteration is complete or connection is closed.

Specified by:
close in interface ElmoManager

flush

public void flush()
Specified by:
flush in interface EntityManager

clear

public void clear()
Specified by:
clear in interface EntityManager

getFlushMode

public FlushModeType getFlushMode()
Specified by:
getFlushMode in interface EntityManager

setFlushMode

public void setFlushMode(FlushModeType mode)
Specified by:
setFlushMode in interface EntityManager

getDelegate

public Object getDelegate()
Specified by:
getDelegate in interface EntityManager

createMemento

public Memento createMemento()
Description copied from interface: ElmoManager
Creates a new Memento Object that represents the current state of the Bean pool. Once created the returned Object will track any further changes on this Bean pool.

Specified by:
createMemento in interface ElmoManager
Returns:
A memento object that can undone subsequent changes.
See Also:
ElmoManager.undoMemento(Memento)

undoMemento

public void undoMemento(Memento memento)
Description copied from interface: ElmoManager
Rolls-back any changes made after this memento object was created. The memento object does not have to have been created from this Bean pool. It is the responsibility of the caller to ensure that it is safe to roll-back this set of changes. Any referenced object instances modified by this change need to be externally refreshed. Any referenced object instances removed or renamed by this change must no longer be used by this or any other processes.

Specified by:
undoMemento in interface ElmoManager
Parameters:
memento - Transaction to be rolled-back.
See Also:
ElmoManager.createMemento()

redoMemento

public void redoMemento(Memento memento)
Description copied from interface: ElmoManager
Replays changes made after this memento object was created. The memento object does not have to have been created from this Bean pool.

Specified by:
redoMemento in interface ElmoManager
Parameters:
memento - Transaction to be repeated.
See Also:
ElmoManager.createMemento(), ElmoManager.undoMemento(Memento)

getInstance

public Object getInstance(Value value)

getValue

public Value getValue(Object instance)

getLocalizedValue

public Value getLocalizedValue(Object instance)

contains

public boolean contains(Object entity)
Description copied from interface: ElmoManager
Check if the instance belongs to the current persistence context.

Specified by:
contains in interface EntityManager
Specified by:
contains in interface ElmoManager
Returns:
true if the instance belongs to the current persistence context.

create

public <T> T create(Class<T> concept,
                    Class<?>... concepts)
Description copied from interface: ElmoManager
Assigns type to a new anonymous entity.

Specified by:
create in interface ElmoManager
Parameters:
concept - interface to be translated to rdf:type.
concepts - additional interfaces to be translated to rdf:type.
Returns:
Java Bean representing the subject.

create

public <T> T create(QName qname,
                    Class<T> concept,
                    Class<?>... concepts)
Description copied from interface: ElmoManager
Assigns concept to the new named entity.

Specified by:
create in interface ElmoManager
Parameters:
qname - URI of the new entity that does not exist in the repository.
concept - interface to be translated to rdf:type.
concepts - additional interfaces to be translated to rdf:type.
Returns:
Java Bean representing the subject.

designate

@Deprecated
public <T> T designate(Class<T> concept,
                                  Class<?>... concepts)
Deprecated. 

Description copied from interface: ElmoManager
Assigns type to a new anonymous entity. Use create instead.

Specified by:
designate in interface ElmoManager
Parameters:
concept - interface to be translated to rdf:type.
concepts - additional interfaces to be translated to rdf:type.
Returns:
Java Bean representing the subject.

designate

public <T> T designate(QName qname,
                       Class<T> concept,
                       Class<?>... concepts)
Description copied from interface: ElmoManager
Assigns concept to the named entity subject.

Specified by:
designate in interface ElmoManager
Parameters:
qname - URI of the entity that may exist in the repository.
concept - interface to be translated to rdf:type.
concepts - additional interfaces to be translated to rdf:type.
Returns:
Java Bean representing the subject.

designate

@Deprecated
public <T> T designate(Class<T> concept,
                                  QName qname)
Deprecated. 

Description copied from interface: ElmoManager
Assigns concept to the named entity subject.

Specified by:
designate in interface ElmoManager
Parameters:
concept - interface to be translated to rdf:type.
qname - URI of the entity.
Returns:
Java Bean representing the subject.

designate

public <T> T designate(Resource resource,
                       Class<T> concept,
                       Class<?>... concepts)

designate

@Deprecated
public <T> T designate(Class<T> concept,
                                  Resource resource)
Deprecated. 


designateEntity

@Deprecated
public <T> T designateEntity(Class<T> concept,
                                        Object entity)
Deprecated. 

Description copied from interface: ElmoManager
Assigns concept to the given entity and return a new object reference that implements the given concept.

Specified by:
designateEntity in interface ElmoManager
Parameters:
concept - interface to be translated to rdf:type.
entity - An existing entity retrieved from this manager.
Returns:
Java Bean representing entity that implements concept.

designateEntity

public <T> T designateEntity(Object entity,
                             Class<T> concept,
                             Class<?>... concepts)
Description copied from interface: ElmoManager
Assigns concept to the given entity and return a new object reference that implements the given concept.

Specified by:
designateEntity in interface ElmoManager
Parameters:
entity - An existing entity retrieved from this manager.
concept - interface to be translated to rdf:type.
concepts - additional interfaces to be translated to rdf:type.
Returns:
Java Bean representing entity that implements concept.

removeDesignation

@Deprecated
public Entity removeDesignation(Class<?> concept,
                                           Object entity)
Deprecated. 

Description copied from interface: ElmoManager
Removes the concept designation from this entity.

Specified by:
removeDesignation in interface ElmoManager
Parameters:
concept - interface to be translated to rdf:type.
entity - An existing entity retrieved from this manager.
Returns:
Java Bean representing entity that does not implement concept.

removeDesignation

public Entity removeDesignation(Object entity,
                                Class<?>... concepts)
Description copied from interface: ElmoManager
Removes the concept designation from this entity.

Specified by:
removeDesignation in interface ElmoManager
Parameters:
entity - An existing entity retrieved from this manager.
concepts - interface to be translated to rdf:type.
Returns:
Java Bean representing entity that does not implement concept.

rename

public <T> T rename(T bean,
                    QName qname)
Description copied from interface: ElmoManager
Removes all the references to the given entity and replaces them with references to the new qname. It is the responsibility of the caller to ensure that any object references to this resource are replaced with the returned object. Previous referenced objects must no longer be used and any cached values must be refreshed.

Specified by:
rename in interface ElmoManager
Parameters:
bean - current Entity to be renamed
qname - new qualified name of the entity
Returns:
entity with the given qname.

rename

public <T> T rename(T bean,
                    Resource dest)

find

public SesameEntity find(QName qname)
Description copied from interface: ElmoManager
Retrieves the rdf:type, creates a Java Bean class and instantiates it.

Specified by:
find in interface ElmoManager
Parameters:
qname - URI of the entity.
Returns:
JavaBean representing the subject.

asQName

@Deprecated
public QName asQName(Resource resource)
Deprecated. 


find

public SesameEntity find(Resource resource)

find

public <T> T find(Class<T> concept,
                  Object qname)
Specified by:
find in interface EntityManager

getReference

public <T> T getReference(Class<T> concept,
                          Object qname)
Specified by:
getReference in interface EntityManager

refresh

public void refresh(Object entity)
Description copied from interface: ElmoManager
If entity implements Refreshable, its method Refreshable.refresh() will be called. This call instructs entities that their property values may have changed and they should reload them as needed.

Specified by:
refresh in interface EntityManager
Specified by:
refresh in interface ElmoManager

merge

public <T> T merge(T bean)
Description copied from interface: ElmoManager
Copies all non-null values from bean into an entity managed by this manager. If bean implements Entity its QName will be used to look up the managed entity, otherwise a new anonymous entity will be created.

Specified by:
merge in interface EntityManager
Specified by:
merge in interface ElmoManager
Parameters:
bean - with values that shoud be merged
Returns:
managed entity it was merged with

persist

public void persist(Object bean)
Description copied from interface: ElmoManager
Copies all non-null values from bean into an entity managed by this manager. If bean implements Entity its QName will be used to look up the managed entity, otherwise a new anonymous entity will be created.

Specified by:
persist in interface EntityManager
Specified by:
persist in interface ElmoManager
Parameters:
bean - with values that shoud be merged

createQuery

public SesameQuery createQuery(String query)
Description copied from interface: ElmoManager
Creates an ElmoQuery to evaluate the query string.

Specified by:
createQuery in interface EntityManager
Specified by:
createQuery in interface ElmoManager
Parameters:
query - rdf query in the configured language - default SPARQL.
Returns:
ElmoQuery.

createNativeQuery

public SesameQuery createNativeQuery(String serql)
Specified by:
createNativeQuery in interface EntityManager

createNativeQuery

public SesameQuery createNativeQuery(String serql,
                                     Class concept)
Specified by:
createNativeQuery in interface EntityManager

createNativeQuery

public SesameQuery createNativeQuery(String serql,
                                     String nil)
Specified by:
createNativeQuery in interface EntityManager

createNamedQuery

public Query createNamedQuery(String name)
Specified by:
createNamedQuery in interface EntityManager

findAll

public <T> Iterable<T> findAll(Class<T> javaClass)
Description copied from interface: ElmoManager
Creates an iteration of entities that implement this role.

Specified by:
findAll in interface ElmoManager
Parameters:
javaClass - concept or behaviour to be translated to one or more rdf:types.
Returns:
Iterable entities that implement role.

remove

public void remove(Object entity)
Description copied from interface: ElmoManager
Removes the given entity or subject and all implementing roles. It is the responsibility of the caller to ensure this entity or any other object referencing it are no longer used and any object that may have cached a value containing this is refreshed.

Specified by:
remove in interface EntityManager
Specified by:
remove in interface ElmoManager
Parameters:
entity - to be removed from the pool and repository.

lock

public void lock(Object entity,
                 LockModeType mode)
Specified by:
lock in interface EntityManager


Copyright © 2004-2008 Aduna. All Rights Reserved.