E - the type of the backend-specific objects representing the inventory entities and relationships. It is
assumed that the backend is "untyped" and stores all different inventory entities using this single type.public interface InventoryBackend<E> extends AutoCloseable
| Modifier and Type | Interface and Description |
|---|---|
static class |
InventoryBackend.Transaction
Represents a transaction being performed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
commit(InventoryBackend.Transaction transaction)
Commits the transaction.
|
<T extends AbstractElement<?,?>> |
convert(E entityRepresentation,
Class<T> entityType)
Converts the provided representation object to a inventory element of provided type.
|
void |
delete(E entity)
Simply deletes the entity from the storage.
|
CanonicalPath |
extractCanonicalPath(E entityRepresentation)
Each element (including relationships) stores the canonical path to it.
|
String |
extractId(E entityRepresentation)
The element type is opaque from the point of the caller.
|
String |
extractRelationshipName(E relationship) |
Class<? extends AbstractElement<?,?>> |
extractType(E entityRepresentation)
Similar to
extractId(Object) but extracts the type of element from the representation. |
E |
find(CanonicalPath element)
Tries to find an element at given canonical path.
|
E |
getRelationship(E source,
E target,
String relationshipName)
Get a single relationship with the provided name between the source and target.
|
Set<E> |
getRelationships(E entity,
Relationships.Direction direction,
String... names)
Similar to
hasRelationship(Object, Relationships.Direction, String) but this method actually returns
the relationship objects. |
E |
getRelationshipSource(E relationship) |
E |
getRelationshipTarget(E relationship) |
Iterator<E> |
getTransitiveClosureOver(E startingPoint,
String relationshipName,
Relationships.Direction direction)
Going from the starting poing, this will return an iterator over all elements that are connected to the starting
point using relationships with provided name and recursively down to the elements connected in the same way to
them.
|
boolean |
hasRelationship(E source,
E target,
String relationshipName)
Checks whether there exists a relationship with given name between the provided entities.
|
boolean |
hasRelationship(E entity,
Relationships.Direction direction,
String relationshipName)
Checks whether there exists any relationship in given direction relative to the given entity with given name.
|
E |
persist(CanonicalPath path,
AbstractElement.Blueprint blueprint)
Persists a new entity with the provided assigned path.
|
Page<E> |
query(Query query,
Pager pager)
Translates the query to the backend-specific representation and runs it, returning a correct page of results
as prescribed by the provided pager object.
|
<T extends AbstractElement<?,?>> |
query(Query query,
Pager pager,
Function<E,T> conversion,
Function<T,Boolean> filter)
A variant of the
query(Query, Pager) method which in addition to querying also converts the results
using the provided conversion function and, more importantly, filters the results using the provided (possibly
null) filter function PRIOR TO paging is applied. |
E |
relate(E sourceEntity,
E targetEntity,
String name,
Map<String,Object> properties)
Creates a new relationship from source to target with given name and properties.
|
void |
rollback(InventoryBackend.Transaction transaction)
Rolls back the transaction.
|
InventoryBackend.Transaction |
startTransaction(boolean mutating)
Starts a transaction in the backend.
|
void |
update(E entity,
AbstractElement.Update update)
Updates given entity with the data provided in the update object.
|
closeInventoryBackend.Transaction startTransaction(boolean mutating)
mutating - whether there will be calls mutating the data or notE find(CanonicalPath element) throws ElementNotFoundException
element - the canonical path of the element to findElementNotFoundException - if the element is not foundPage<E> query(Query query, Pager pager)
query - the query to executepager - the page to return<T extends AbstractElement<?,?>> Page<T> query(Query query, Pager pager, Function<E,T> conversion, Function<T,Boolean> filter)
query(Query, Pager) method which in addition to querying also converts the results
using the provided conversion function and, more importantly, filters the results using the provided (possibly
null) filter function PRIOR TO paging is applied.
Because the total count and the paging is dependent on the filtering it needs to be applied during the querying process and not only after the fact be the caller.
T - the type of the returned elementsquery - the query to performpager - the page to retrieveconversion - a conversion function to apply on the elements, never nullfilter - possibly null filter to filter the results withIterator<E> getTransitiveClosureOver(E startingPoint, String relationshipName, Relationships.Direction direction)
startingPoint - the starting elementrelationshipName - the name of the relationship to follow when composing the transitive closuredirection - any of the valid directions including
Relationships.Direction.both.boolean hasRelationship(E entity, Relationships.Direction direction, String relationshipName)
entity - the entity in questiondirection - the direction the relationship should have relative to the entity (
Relationships.Direction.both means "any" in this
context).relationshipName - the name of the relationship to seekgetRelationships(Object, Relationships.Direction, String...)boolean hasRelationship(E source, E target, String relationshipName)
source - the source of the relationshiptarget - the target of the relationshiprelationshipName - the name of the relationshipSet<E> getRelationships(E entity, Relationships.Direction direction, String... names)
hasRelationship(Object, Relationships.Direction, String) but this method actually returns
the relationship objects.entity - the entity in questiondirection - the direction in which the relationships should be goingnames - the names of the relationships to returnhasRelationship(Object, Relationships.Direction, String)E getRelationship(E source, E target, String relationshipName) throws ElementNotFoundException
source - the source of the relationshiptarget - the target of the relationshiprelationshipName - the name of the relationshipElementNotFoundException - if the relationship is not foundIllegalArgumentException - if source or target are not entities or relationship name is nullE getRelationshipSource(E relationship)
relationship - the relationship in questionE getRelationshipTarget(E relationship)
relationship - the relationship in questionString extractRelationshipName(E relationship)
relationship - the relationship in questionString extractId(E entityRepresentation)
entityRepresentation - the object representing an elementClass<? extends AbstractElement<?,?>> extractType(E entityRepresentation)
extractId(Object) but extracts the type of element from the representation.entityRepresentation - the representation object.CanonicalPath extractCanonicalPath(E entityRepresentation)
entityRepresentation - the representation object<T extends AbstractElement<?,?>> T convert(E entityRepresentation, Class<T> entityType)
T - the desired type of the elemententityRepresentation - the object representing the elemententityType - the desired type of the elementClassCastException - if the representation object doesn't correspond to the provided typeE relate(E sourceEntity, E targetEntity, String name, Map<String,Object> properties)
sourceEntity - the source of the relationshiptargetEntity - the target of the relationshipname - the name of the relationshipproperties - the properties of the relationship, may be nullIllegalArgumentException - if source or target are relationships themselves or if name is nullE persist(CanonicalPath path, AbstractElement.Blueprint blueprint)
path - the canonical path to the entityblueprint - the blueprint of the entityvoid update(E entity, AbstractElement.Update update)
entity - the entity to updateupdate - the update objectIllegalArgumentException - if the entity is of different type than the updatevoid delete(E entity)
entity - the entity to deletevoid commit(InventoryBackend.Transaction transaction) throws CommitFailureException
transaction - the transaction to commitCommitFailureExceptionvoid rollback(InventoryBackend.Transaction transaction)
transaction - the transaction to roll backCopyright © 2015 Red Hat, Inc.. All rights reserved.