public static class BaseResources.ReadWrite<BE> extends Traversal<BE,E> implements Resources.ReadWrite
| Constructor and Description |
|---|
ReadWrite(TraversalContext<BE,Resource> context) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup(Id id,
BE entityRepresentation)
A hook that can run additional clean up logic inside the delete transaction.
|
Resources.Single |
create(Resource.Blueprint blueprint)
Creates a new entity at the current position in the inventory traversal.
|
void |
delete(Id id) |
protected Query |
doCreate(B blueprint)
A helper method to be used in the implementation of the
WriteInterface.create(Blueprint) method. |
Resources.Single |
get(String id)
Tries to find a single entity in the current position in the inventory traversal.
|
Resources.Multiple |
getAll(Filter[][] filters)
Returns access interface to all entities conforming to the provided filters in the current position in the
inventory traversal.
|
protected String |
getProposedId(Resource.Blueprint blueprint)
Extracts the proposed ID from the blueprint or identifies the ID through some other means.
|
protected void |
preUpdate(Id id,
BE entityRepresentation,
U update)
A hook that can run additional logic inside the update transaction before anything has been persisted to the
backend database.
|
protected BE |
relate(BE source,
BE target,
String relationshipName) |
void |
update(Id id,
U update) |
protected EntityAndPendingNotifications<Resource> |
wireUpNewEntity(BE entity,
Resource.Blueprint blueprint,
CanonicalPath parentPath,
BE parent)
Wires up the freshly created entity in the appropriate places in inventory.
|
getSingle, isApplicable, mutating, readOnlyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdelete, updatedescendgetAllpublic ReadWrite(TraversalContext<BE,Resource> context)
protected String getProposedId(Resource.Blueprint blueprint)
blueprint - the blueprint of the entity to be createdprotected EntityAndPendingNotifications<Resource> wireUpNewEntity(BE entity, Resource.Blueprint blueprint, CanonicalPath parentPath, BE parent)
The wiring up might result in new relationships being created or other "notifiable" actions - the returned object needs to reflect that so that the notification can correctly be emitted.
entity - the freshly created, uninitialized entityblueprint - the blueprint that it prescribes how the entity should be initializedparentPath - the path to the parent entityparent - the actual parent entitypublic Resources.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<Resources.Multiple>filters - the sets of filters to applypublic Resources.Single get(String id) throws EntityNotFoundException
ResolvingToSingleget in interface ResolvingToSingle<Resources.Single,String>id - the identification of sorts of the entity to find in the current traversal positionEntityNotFoundExceptionpublic Resources.Single create(Resource.Blueprint blueprint) throws EntityAlreadyExistsException
WriteInterfaceblueprint - the blueprint to be used to create the new entityEntityAlreadyExistsException - if the entity already existsprotected final Query doCreate(B blueprint)
WriteInterface.create(Blueprint) method.
The callers may merely use the returned query and construct a new *Single instance using it.
blueprint - the blueprint of the new entitypublic final void update(Id id,
U update)
throws EntityNotFoundException
EntityNotFoundExceptionpublic final void delete(Id id)
throws EntityNotFoundException
EntityNotFoundExceptionprotected void cleanup(Id id,
BE entityRepresentation)
This hook is called prior to anything being deleted.
By default this does nothing.
id - the id of the entity being deletedentityRepresentation - the backend specific representation of the entityprotected void preUpdate(Id id,
BE entityRepresentation,
U update)
By default, this does nothing
id - the id of the entity being updatedentityRepresentation - the backend representation of the updated entityupdate - the update objectprotected BE relate(BE source,
BE target,
String relationshipName)
Copyright © 2015 Red Hat, Inc.. All rights reserved.