public static class BaseMetrics.ReadAssociate<BE> extends Traversal<BE,E> implements Metrics.ReadAssociate
| Constructor and Description |
|---|
ReadAssociate(TraversalContext<BE,Metric> context) |
| Modifier and Type | Method and Description |
|---|---|
Relationship |
associate(Path id)
Adds a pre-existing entity into the relation with the current entity.
|
Relationship |
associationWith(Path path)
Finds the relationship with the entity with the provided id.
|
protected Relationship |
createAssociation(Class<? extends Entity<?,?>> sourceType,
Relationships.WellKnown relationship,
BE target) |
protected Relationship |
deleteAssociation(Class<? extends Entity<?,?>> sourceType,
Relationships.WellKnown relationship,
BE target) |
Relationship |
disassociate(Path id)
Removes an entity from the relation with the current entity.
|
Metrics.Single |
get(Path id)
Tries to find a single entity in the current position in the inventory traversal.
|
Metrics.Multiple |
getAll(Filter[][] filters)
Returns access interface to all entities conforming to the provided filters in the current position in the
inventory traversal.
|
protected Relationship |
getAssociation(Class<? extends Entity<?,?>> sourceType,
Path targetPath,
Relationships.WellKnown rel) |
getSingle, isApplicable, mutating, readOnlyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllpublic ReadAssociate(TraversalContext<BE,Metric> context)
public Relationship associate(Path id) throws EntityNotFoundException, RelationAlreadyExistsException
inventory.tenants().get(tenantId).environments().get(envId).resources().get(rId).metrics().associate(
RelativePath.to().up().metric(metricId));
In here the associate method will add a new metric (identified by the metricId) to the
resource identified by the rId.
The provided path can be a RelativePath (as in the above example)
which is evaluated against the current position in the graph - the
up() call will move up the path from the resource
to the environment and the metric() call will the move to a metric in that environment.
The provided path can also be a CanonicalPath in which case it is
fully evaluated and the entity on that path is associated (provided the path points to the correct type of
entity and all the rules specific for the association of the two types of entities are fulfilled).
id - the path to a pre-existing entity to be related to the entity on the current position in the
inventory traversal.EntityNotFoundExceptionRelationAlreadyExistsExceptionpublic Relationship disassociate(Path id) throws EntityNotFoundException
id - the id of the entity to remove from the relation with the current entity.EntityNotFoundExceptionfor explanation of how the current entity and the relation is determined.public Relationship associationWith(Path path) throws RelationNotFoundException
path - the id of the entity to find the relation withRelationNotFoundException - if a relation with an entity of given id doesn't existfor the discussion of how the entity and the relationship is determinedpublic Metrics.Multiple getAll(Filter[][] filters)
ResolvingToMultipleThe filters parameter is actually composed of individual sets of filters each of which is applied to the "source" entities. Each set can have multiple filters that are then applied one after another on their intermediate results. This becomes useful when you want to filter by sources having some kind of relationships with other entities and in addition filter on the sources themselves, too. E.g.:
inventory.tenants().getAll(new Filter[][]{{Related.by("myRel"), With.type(ResourceType.class)},
{With.id("asf")}}).entities();
The filter above would first check that the tenants in question have a relationship called "myRel" with some
resource types and then would also check if the tenant has ID "asf".getAll in interface ResolvingToMultiple<Metrics.Multiple>filters - the sets of filters to applypublic Metrics.Single get(Path id) throws EntityNotFoundException
ResolvingToSingleget in interface ResolvingToSingle<Metrics.Single,Path>id - the identification of sorts of the entity to find in the current traversal positionEntityNotFoundExceptionprotected Relationship createAssociation(Class<? extends Entity<?,?>> sourceType, Relationships.WellKnown relationship, BE target)
protected Relationship deleteAssociation(Class<? extends Entity<?,?>> sourceType, Relationships.WellKnown relationship, BE target)
protected Relationship getAssociation(Class<? extends Entity<?,?>> sourceType, Path targetPath, Relationships.WellKnown rel)
Copyright © 2015 Red Hat, Inc.. All rights reserved.