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> T |
convert(E entityRepresentation,
Class<T> entityType)
Converts the provided representation object to an inventory element of provided type.
|
void |
delete(E entity)
Simply deletes the entity from the storage.
|
void |
deleteStructuredData(E dataRepresentation)
Deletes the structured data represented by the provided object.
|
E |
descendToData(E dataEntityRepresentation,
RelativePath dataPath)
Given the representation of the data entity, this will return the representation of a structured data element
on the given path "inside" the data entity.
|
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<?> |
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.
|
InputStream |
getGraphSON(String tenantId)
See the javadoc in
Inventory.getGraphSON(String) |
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) |
<T extends Entity<?,?>> |
getTransitiveClosureOver(CanonicalPath startingPoint,
Relationships.Direction direction,
Class<T> clazz,
String... relationshipNames) |
Iterator<E> |
getTransitiveClosureOver(E startingPoint,
Relationships.Direction direction,
String... relationshipNames)
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,
Blueprint blueprint)
Persists a new entity with the provided assigned path.
|
E |
persist(StructuredData structuredData)
Persists the structured data and returns a reference to it.
|
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> Page<T> |
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.
|
Page<E> |
traverse(E startingPoint,
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.
|
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> traverse(E startingPoint, Query query, Pager pager)
startingPoint - the element which should be the starting point of the traversalquery - the query to performpager - pager to limit the number of results withPage<E> query(Query query, Pager pager)
The difference between this method and traverse(Object, Query, Pager) is that this method performs
a graph-wide query, while traverse starts from a single element.
query - the query to executepager - the page to return<T> 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, Relationships.Direction direction, String... relationshipNames)
startingPoint - the starting elementdirection - any of the valid directions including
Relationships.Direction#both.relationshipNames - the names of the relationships to follow when composing the transitive closureboolean 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<?> 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> T convert(E entityRepresentation, Class<T> entityType)
This must support all the concrete subclasses of AbstractElement, StructuredData and
ShallowStructuredData.
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 descendToData(E dataEntityRepresentation, RelativePath dataPath)
dataEntityRepresentation - the representation of the DataEntity
instancedataPath - the path in the data to descend to.org.hawkular.inventory.api.Datas.Single#data(RelativePath)E 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, Blueprint blueprint)
path - the canonical path to the entityblueprint - the blueprint of the entityE persist(StructuredData structuredData)
structuredData - the structured data to persistvoid 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 deleteStructuredData(E dataRepresentation)
dataRepresentation - the backend-specific object representing the structured data to deletevoid commit(InventoryBackend.Transaction transaction) throws CommitFailureException
transaction - the transaction to commitCommitFailureExceptionvoid rollback(InventoryBackend.Transaction transaction)
transaction - the transaction to roll backInputStream getGraphSON(String tenantId)
Inventory.getGraphSON(String)<T extends Entity<?,?>> Iterator<T> getTransitiveClosureOver(CanonicalPath startingPoint, Relationships.Direction direction, Class<T> clazz, String... relationshipNames)
Copyright © 2015 Red Hat, Inc.. All rights reserved.