|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object i3.dragos.gm.core.filter.FilteringGraphPool
public class FilteringGraphPool
A GraphPool
implementation that hides top level graphs whose
names start with a specific prefix.
All methods from the GraphPool
interface are modified to not
allow the creation and removal of top level graphs with reserved names and to
filter out these graphs from the results of get*
methods.
For working directly with the underlying unfiltered graph pool the method
turnFilteringOff()
is provided. The method
turnFilteringOn()
reactivates filtering mechanism. Both methods
affect both the graph pool and the associated schema instance.
Constructor Summary | |
---|---|
FilteringGraphPool(GraphPool pool,
java.lang.String prefix)
Creates a new FilteringGraphPool . |
Method Summary | |
---|---|
void |
clear(boolean alsoClearSchema)
Removes every graph entity from this graph pool, and possibly every class declaration from the schema. |
void |
close()
Closes the graph pool and frees all temporary resources used by it. |
Graph |
createTopLevelGraph(java.lang.String name,
GraphClass type)
Creates a new (top-level) graph with the given name. |
boolean |
existsTopLevelGraph(java.lang.String name)
Returns true if a graph identified by the name is stored
in the pool and false otherwise. |
java.util.Collection<? extends GraphEntity> |
getAllInstances(GraphEntityClass id)
Returns all instances of a GraphEntityClass contained in the pool. |
java.util.Map<java.lang.String,java.io.Serializable> |
getAllMetaAttributes()
Returns a map containing all currently set meta-attribute key-value pairs. |
java.util.Collection<? extends Graph> |
getAllTopLevelGraphs()
Returns all top-level graphs (those which have no parent graph) stored in this graph pool. |
DataSourceURL |
getDataSourceURL()
Returns the URL to the data source of this graph pool. |
boolean |
getForceExistenceCheckOnRead()
Tells wether the existence of any entity or entity class is checked before performing a reading operation. |
GraphEntity |
getGraphEntityByInternalIdentifier(java.io.Serializable identifier)
Retrieves a GraphEntity by its internal identifier. |
DefaultGraphPoolChecker |
getGraphPoolChecker()
Returns the GraphPoolChecker of the wrapped graph pool. |
java.io.Serializable |
getMetaAttribute(java.lang.String key)
Returns the current value of a meta-attribute. |
FilteringSchema |
getSchema()
Returns the schema used for all elements in this graph pool. |
Graph |
getTopLevelGraphByName(java.lang.String name)
Returns the top-level graph identified by the specified name. |
GraphPool |
getWrappedGraphPool()
Returns the wrapped graph pool, null if none. |
Wrapper |
getWrapper()
Returns the Wrapper currently used by the GraphPool. |
void |
init()
Initializes a graph pool. |
boolean |
isFilteringOn()
Returns true if filtering mechanism is turned on. |
boolean |
isMetaAttributeKeyReserved(java.lang.String key)
Checks whether a meta-attribute key is reserved for internal use. |
boolean |
isMetaAttributeSet(java.lang.String key)
Checks whether a meta-attribute is set. |
void |
open()
Prepares the graph pool for normal operation. |
void |
removeAllAttributeInstances(Attribute attribute)
Removes every instance of an attribute from the pool. |
void |
removeAllInstances(GraphEntityClass id)
Removes every instance of a GraphEntityClass from the pool. |
void |
removeTopLevelGraph(Graph graph)
Deletes a top-level graph. |
void |
reorganizePool()
Reorganizes the entire graph pool. |
void |
setForceExistenceCheckOnRead(boolean b)
Sets wether the existence of any entity or entity class is checked before performing a reading operation. |
void |
setMetaAttribute(java.lang.String key,
java.io.Serializable value)
Sets a meta-attribute. |
void |
setWrapper(Wrapper w)
Sets the Wrapper to be used by the GraphPool. |
void |
turnFilteringOff()
Deactivates filtering mechanism both of the schema and of the associated graph pool instance. |
void |
turnFilteringOn()
Activates filtering mechanism both of the schema and of the associated graph pool instance. |
void |
unsetMetaAttribute(java.lang.String key)
Removes a meta-attribute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FilteringGraphPool(GraphPool pool, java.lang.String prefix) throws DragosException
FilteringGraphPool
.
pool
- the wrapped GraphPool
instance.prefix
- the prefix that determines which top level graphs are
filtered out.
DragosException
- if something went wrongMethod Detail |
---|
public GraphPool getWrappedGraphPool()
null
if none.
If there is more than one instance of any sub-interface or implementing class in the wrapper chain, partial unwrapping (needed mostly to access newly defined methods) may not work as expected. It is up to the application to ensure that no wrapper is included more than once.
This method must work even when the GraphPool is closed.
getWrappedGraphPool
in interface GraphPool
null
if none.GraphPoolFactory.unwrapGraphPoolTill(GraphPool, ExtensionDescriptor)
public DataSourceURL getDataSourceURL()
null
.
This method must work even when the GraphPool is closed.
getDataSourceURL
in interface GraphPool
public FilteringSchema getSchema() throws DragosException
This method must work even when the GraphPool is closed.
getSchema
in interface GraphPool
DragosException
- if something went wrong.public void init() throws GraphPoolException
init
method must be called first
DataSource
and accessible via the TransactionManagerFactory
GraphPool.open()
init
in interface GraphPool
GraphPoolException
- if something went wrong.public Graph createTopLevelGraph(java.lang.String name, GraphClass type) throws EntityNotFoundException, DragosException, java.lang.IllegalArgumentException, EntityAlreadyExistsException
Behaves exactly like
GraphPool.createTopLevelGraph(String, GraphClass)
except that name
is not allowed to start with the reserved
prefix.
createTopLevelGraph
in interface GraphPool
name
- The name of the graph.type
- The graphs type.
java.lang.IllegalArgumentException
- if name
is
null
or starts with reserved prefix.
EntityNotFoundException
- if the type could not be found.
EntityAlreadyExistsException
- if a graph with this name already
exists.
GraphEntityInstantiationException
- if type is declared as an abstract class.
DragosException
- if something went wrong.public boolean existsTopLevelGraph(java.lang.String name) throws DragosException
true
if a graph identified by the name is stored
in the pool and false
otherwise.
Behaves exactly like
GraphPool.existsTopLevelGraph(String)
except
that name
is not allowed to start with the reserved
prefix.
existsTopLevelGraph
in interface GraphPool
name
- The name of the graph.
true
if a graph identified by the name is stored
in the pool and false
otherwise.
java.lang.IllegalArgumentException
- if name
starts with
reserved prefix.
DragosException
- if something went wrong.public void removeTopLevelGraph(Graph graph) throws EntityNotFoundException, DragosException
See Graph.removeGraphEntity(GraphEntity)
for a detailed
description on the deletion process.
Any non-top-level graphs should be deleted by calling
Graph.removeGraphEntity(GraphEntity)
on their parent graph instead.
Behaves exactly like
GraphPool.existsTopLevelGraph(String)
except
that an EntityNotFoundException
is thrown if the graph
entity with the given internal identifier is filtered out.
removeTopLevelGraph
in interface GraphPool
graph
- The graph.
EntityNotFoundException
- if the graph is not a top-level graph in
this GraphPool.
DragosException
- if something went wrong.public java.util.Collection<? extends Graph> getAllTopLevelGraphs() throws DragosException
Graph
.
Behaves exactly like
GraphPool.getAllTopLevelGraphs()
except that
all top level graphs whose names start with the specified prefix are
filtered out.
getAllTopLevelGraphs
in interface GraphPool
DragosException
- in case of internal errors.public Graph getTopLevelGraphByName(java.lang.String name) throws EntityNotFoundException, DragosException, java.lang.IllegalArgumentException
Behaves exactly like
GraphPool.getTopLevelGraphByName(String)
except that name
is not allowed to start with the reserved
prefix.
getTopLevelGraphByName
in interface GraphPool
name
- The name of the graph.
java.lang.IllegalArgumentException
- if name
starts with
reserved prefix.
EntityNotFoundException
- if the graph does not exist.
DragosException
- if something else went wrong.public GraphEntity getGraphEntityByInternalIdentifier(java.io.Serializable identifier) throws EntityNotFoundException, DragosException
Behaves exactly like
GraphPool.getGraphEntityByInternalIdentifier(Serializable)
except that an EntityNotFoundException
is thrown if the
graph entity with the given internal identifier is filtered out.
getGraphEntityByInternalIdentifier
in interface GraphPool
identifier
- The internal identifier.
EntityNotFoundException
- if the graph entity does not exist.
DragosException
- if something else went wrong.public void clear(boolean alsoClearSchema) throws DragosException
GraphPoolEvent
is required.
Attention: no filtering of reserved entities.
TODO: filtered clearing of schema is not possible at the moment
clear
in interface GraphPool
alsoClearSchema
- Whether Schema.clear()
should be called
after successful removal of all entities in the pool.
DragosException
- if something went wrong.public java.util.Collection<? extends GraphEntity> getAllInstances(GraphEntityClass id) throws EntityNotFoundException, DragosException
Behaves exactly like
GraphPool.getAllInstances(GraphEntityClass)
except that an EntityNotFoundException
is thrown if the
given graph entity class is filtered out of the schema.
getAllInstances
in interface GraphPool
id
- The class whose instances are to be returned.
EntityNotFoundException
- if the class was not found in the schema.
DragosException
- if something went wrong.public void removeAllInstances(GraphEntityClass id) throws EntityNotFoundException, DragosException
Deletion must follow the general procedure for deletion of
graph entities, described at Graph.removeGraphEntity(GraphEntity)
.
The easiest way to ensure this is to proceed as follows for every graph entity in this pool:
GraphPool.removeTopLevelGraph(Graph)
.Graph.removeGraphEntity(GraphEntity)
on their parent graph.Implementation notice: Some instances might already be deleted due to cascading removal of entities processed before, so take care when iterating through the instances.
Behaves exactly like
GraphPool.removeAllInstances(GraphEntityClass)
except that an EntityNotFoundException
is thrown if the
given graph entity class is filtered out of the schema.
removeAllInstances
in interface GraphPool
id
- The class whose instances are to be deleted.
EntityNotFoundException
- if the class was not found in the schema.
DragosException
- if something went wrong.public void removeAllAttributeInstances(Attribute attribute) throws EntityNotFoundException, DragosException
Behaves exactly like
GraphPool.removeAllInstances(GraphEntityClass)
except that an EntityNotFoundException
is thrown if the
graph entity class the attribute is defined for is filtered out of the
schema.
removeAllAttributeInstances
in interface GraphPool
attribute
- The attribute whose instances are to be deleted.
EntityNotFoundException
- if the attribute definition was not found
in the schema.
DragosException
- if something went wrong.public void reorganizePool() throws EntityInUseException, DragosException
Any information that is used by applications to access any kind of information externally visible (like internal identifiers) will not be modified.
Caution: This method should only be used by privileged application modules because exclusive access to the graph pool is required in general.
reorganizePool
in interface GraphPool
EntityInUseException
- if the graph use by some other component.
DragosException
- if something went wrong.public void close() throws GraphPoolException
This method must work even when the GraphPool is closed.
close
in interface GraphPool
GraphPoolException
- if something went wrong.GraphPool.open()
public void open() throws GraphPoolException
This method must work even when the GraphPool is closed.
open
in interface GraphPool
GraphPoolException
- if something went wrong.GraphPool.close()
public void setForceExistenceCheckOnRead(boolean b)
setForceExistenceCheckOnRead
in interface GraphPool
b
- The new value of the flag.public boolean getForceExistenceCheckOnRead()
getForceExistenceCheckOnRead
in interface GraphPool
public Wrapper getWrapper()
NullWrapper
upon creation, and
GraphPool.setWrapper(Wrapper)
does not allow a null
argument, the returned value is guaranteed not to be null
.
The Wrapper itself must not be modified after it has been set,
the wrapping mechanism should be immutable! Rationale: We want
to allow the caching of wrapped entities, and changes directly to
the Wrapper will not be noticed by the GraphPool, meaning entities
wrapped according to the old rules may remain in the caches and still be
returned!
To change the Wrapper, e.g. add a new layer to a MultiWrapper
,
create a completely new Wrapper and set it using this method. The
GraphPool will take this as a sign to discard not only the old Wrapper,
but also any caches associated with it!
This method must work even when the GraphPool is closed.
getWrapper
in interface GraphPool
Wrapper
public void setWrapper(Wrapper w) throws DragosException
NullWrapper
(which is the
default Wrapper set upon GraphPool creation)
This method must work even when the GraphPool is closed.
setWrapper
in interface GraphPool
w
- the Wrapper to be used by the GraphPool (must not be
null
).
DragosException
- if something went wrong.Wrapper
public DefaultGraphPoolChecker getGraphPoolChecker()
getGraphPoolChecker
in interface GraphPool
GraphPool.getGraphPoolChecker()
public java.util.Map<java.lang.String,java.io.Serializable> getAllMetaAttributes() throws DragosException
getAllMetaAttributes
in interface MetaAttributable
Map
containing key-value pairs for all set meta-attributes.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public java.io.Serializable getMetaAttribute(java.lang.String key) throws EntityNotFoundException, DragosException
getMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.
EntityNotFoundException
- if no meta-attribute with that name exists.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public boolean isMetaAttributeKeyReserved(java.lang.String key) throws DragosException
isMetaAttributeKeyReserved
in interface MetaAttributable
key
- The key in question.
true
if this meta-attribute key is reserved, false
otherwise.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public boolean isMetaAttributeSet(java.lang.String key) throws EntityNotFoundException, DragosException
isMetaAttributeSet
in interface MetaAttributable
key
- The key that identifies the meta attribute.
true
if the meta-attribute is set, false
otherwise.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.
EntityNotFoundException
public void setMetaAttribute(java.lang.String key, java.io.Serializable value) throws EntityInUseException, DragosException
setMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.value
- The (new) value of this meta-attribute.
EntityInUseException
- if a key name is reserved for internal use.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public void unsetMetaAttribute(java.lang.String key) throws EntityInUseException, DragosException
unsetMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.
EntityInUseException
- if a key name is reserved for internal use.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public boolean isFilteringOn()
true
if filtering mechanism is turned on.
true
if filtering mechanism is turned on.public void turnFilteringOn()
public void turnFilteringOff()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |