public class BlueprintsPersistenceBackend extends AbstractPersistenceBackend
PersistenceBackend that is responsible of low-level access to a Blueprints database.
It wraps an existing Blueprints database and provides facilities to create and retrieve elements, map PersistentEObjects to Vertex elements in order to speed up attribute access, and manage a set of lightweight
caches to improve access time of Vertex from their corresponding PersistentEObject.
This class is used in DirectWriteBlueprintsStore and DirectWriteBlueprintsCacheManyStore to access
and manipulate the database.
Instances of BlueprintsPersistenceBackend are created by BlueprintsPersistenceBackendFactory that
provides an usable KeyIndexableGraph that can be manipulated by this wrapper.
| Modifier and Type | Field and Description |
|---|---|
static String |
KEY_ECLASS_NAME
The property key used to set metaclass name in metaclass
Vertexs. |
static String |
KEY_EPACKAGE_NSURI
|
static String |
KEY_INSTANCE_OF
The label of type conformance
Edges. |
static String |
KEY_METACLASSES
The name of the index entry holding metaclass
Vertexs. |
static String |
KEY_NAME
The index key used to retrieve metaclass
Vertexs. |
static String |
NAME
The literal description of this back-end.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BlueprintsPersistenceBackend(KeyIndexableGraph baseGraph)
Constructs a new
BlueprintsPersistenceBackend wrapping the provided baseGraph. |
| Modifier and Type | Method and Description |
|---|---|
Vertex |
addVertex(Id id)
Create a new vertex, add it to the graph, and return the newly created vertex.
|
void |
close()
In our case, it cleanly stops the underlying database.
|
void |
copyTo(BlueprintsPersistenceBackend target)
Copies all the contents of this back-end to the target one.
|
Map<EClass,Iterable<Vertex>> |
getAllInstances(EClass eClass,
boolean strict)
Back-end specific computation of
Resource.getAllContents(). |
IdGraph<KeyIndexableGraph> |
getGraph()
Provides a direct access to the underlying graph.
|
Vertex |
getOrCreateVertex(PersistentEObject object)
Return the vertex corresponding to the provided
PersistentEObject. |
Vertex |
getVertex(Id id)
Returns the vertex corresponding to the provided
id. |
boolean |
isClosed()
Returns whether the underlying database is closed.
|
PersistentEObject |
reifyVertex(Vertex vertex)
Reifies the given
Vertex as a PersistentEObject. |
PersistentEObject |
reifyVertex(Vertex vertex,
EClass eClass)
Reifies the given
Vertex as an PersistentEObject. |
void |
save()
Saves the modifications of the owned
EObjects in the underlying database. |
public static final String NAME
public static final String KEY_ECLASS_NAME
Vertexs.public static final String KEY_EPACKAGE_NSURI
public static final String KEY_INSTANCE_OF
Edges.public static final String KEY_METACLASSES
Vertexs.public static final String KEY_NAME
Vertexs.protected BlueprintsPersistenceBackend(KeyIndexableGraph baseGraph)
BlueprintsPersistenceBackend wrapping the provided baseGraph.
This constructor initialize the caches and create the metaclass index.
This constructor is protected. To create a new BlueprintsPersistenceBackend use BlueprintsPersistenceBackendFactory.createPersistentBackend(java.io.File, Map).
baseGraph - the base KeyIndexableGraph used to access the databaseBlueprintsPersistenceBackendFactorypublic boolean isClosed()
PersistenceBackendtrue if the database is closed, otherwise falsepublic void close()
PersistenceBackendIn our case, it cleanly stops the underlying database.
public void save()
PersistenceBackendEObjects in the underlying database.public Map<EClass,Iterable<Vertex>> getAllInstances(EClass eClass, boolean strict)
PersistenceBackendResource.getAllContents().public Vertex addVertex(Id id)
id - the identifier of the Vertexpublic Vertex getVertex(Id id)
id. If no vertex corresponds to that id, then
return null.public Vertex getOrCreateVertex(PersistentEObject object)
PersistentEObject. If no vertex corresponds to that
EObject, then the corresponding Vertex together with its KEY_INSTANCE_OF relationship is
created.object - the PersistentEObject to findEObject or null when no such vertex existspublic PersistentEObject reifyVertex(Vertex vertex)
Vertex as a PersistentEObject.
The method guarantees that the same PersistentEObject is returned for a given Vertex in
subsequent calls, unless the PersistentEObject returned in previous calls has been already garbage
collected.
This method behaves like reifyVertex(vertex, null).
vertex - the Vertex to reifyPersistentEObject representing the given vertexpublic PersistentEObject reifyVertex(Vertex vertex, EClass eClass)
Vertex as an PersistentEObject.
The method guarantees that the same PersistentEObject is returned for a given Vertex in
subsequent calls, unless the PersistentEObject returned in previous calls has been already garbage
collected.
vertex - the Vertex to reifyeClass - the expected EClass of the reified object. Can be set to null if not known.PersistentEObject representing the given vertexpublic void copyTo(BlueprintsPersistenceBackend target)
target - the BlueprintsPersistenceBackend to copy the elements topublic IdGraph<KeyIndexableGraph> getGraph()
This method is public for tool compatibility (see the Mogwaï) framework, NeoEMF consistency is not guaranteed if the graph is modified manually.
Copyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.