Class SqaleUpdateContext<S,Q extends FlexibleRelationalPathBase<R>,R>
java.lang.Object
com.evolveum.midpoint.repo.sqale.update.SqaleUpdateContext<S,Q,R>
- Type Parameters:
S
- schema type of the mapped object (potentially in nested mapping)Q
- query entity typeR
- row type related to theSqaleUpdateContext
- Direct Known Subclasses:
ContainerTableUpdateContext
,ExtensionUpdateContext
,NestedContainerUpdateContext
,RootUpdateContext
public abstract class SqaleUpdateContext<S,Q extends FlexibleRelationalPathBase<R>,R>
extends Object
Update context manages state information related to the currently executed modify operation.
Contexts can be nested for any non-trivial updates where each instance matches the changed item
and its mapping.
RootUpdateContext
is the top level parent context that holds the main object.
For example, given a path `assignment/1/metadata/channel`:
* RootUpdateContext
is created for the object, imagine it at the root of the path.
* ContainerTableUpdateContext
is created for `assignment/1` part under the root context.
* NestedContainerUpdateContext
is created for `metadata` part.
* One of ItemDeltaValueProcessor
is then created for `channel` based on the type of
the property (in this case UriItemDeltaProcessor
) which processes actual values and
uses the context above to do so.
In this example channel is single-valued property and will be changed adding a `SET` clause
to the `UPDATE` held by the container table update context.
This `UPDATE` will use proper `WHERE` clause negotiated between this context and its parent,
which in this case is the root context, using also the container ID provided in the item path.
Nested container context merely "focuses" from assignment container to its metadata, but the
table is still the same.
This class also coordinates final update execution for the whole context tree implemented
as a template method finishExecution()
called from the RootUpdateContext
.
Subclasses implement their specific logic in finishExecutionOwn()
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final JdbcSession
protected final Trace
protected final SqaleUpdateContext<?,
?, ?> Parent is typically used to do some work for the child like when nested container uses the parent's UPDATE clause.protected final R
protected final Map<ItemPath,
SqaleUpdateContext<?, ?, ?>> Map of subcontext for knownItemPath
sub-paths relative to this context. -
Constructor Summary
ConstructorDescriptionSqaleUpdateContext
(SqaleRepoContext repositoryContext, JdbcSession jdbcSession, R row) SqaleUpdateContext
(SqaleUpdateContext<?, ?, ?> parentContext, R row) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubcontext
(ItemPath itemPath, SqaleUpdateContext<?, ?, ?> subcontext) abstract Q
Returns entity path (table) for the context.<O> O
findValueOrItem
(@NotNull ItemPath path) final <O> O
findValueOrItem
(@NotNull Object... path) protected final void
Executes collected updates if applicable including all subcontexts.protected abstract void
SqaleUpdateContext<?,
?, ?> getSubcontext
(ItemPath itemPath) <TS,
TR> TR insertOwnedRow
(QOwnedByMapping<TS, TR, R> mapping, TS schemaObject) boolean
isOverwrittenId
(Long id) abstract QueryModelMapping<S,
Q, R> mapping()
row()
abstract <P extends com.querydsl.core.types.Path<T>,
T>
voidset
(P path, com.querydsl.core.types.Expression<T> value) abstract <P extends com.querydsl.core.types.Path<T>,
T>
voidset
(P path, T value) abstract <P extends com.querydsl.core.types.Path<T>,
T>
voidsetNull
(P path)
-
Field Details
-
logger
-
jdbcSession
-
row
-
parentContext
Parent is typically used to do some work for the child like when nested container uses the parent's UPDATE clause. -
subcontexts
Map of subcontext for knownItemPath
sub-paths relative to this context.ItemName
is not enough to represent multi-value container paths like `assignment/1`. PathKeyedMap is used to ignore rare, but possible, namespace discrepancies (MID-8258). Ignoring namespaces here is acceptable, because it is only used for known built-in containers.
-
-
Constructor Details
-
SqaleUpdateContext
-
SqaleUpdateContext
-
-
Method Details
-
repositoryContext
-
jdbcSession
-
row
-
entityPath
Returns entity path (table) for the context. This is NOT the path for item column, which can be actually multiple columns (ref, poly) or just part of the value in the column (JSONB). -
mapping
-
set
public abstract <P extends com.querydsl.core.types.Path<T>,T> void set(P path, T value) -
set
public abstract <P extends com.querydsl.core.types.Path<T>,T> void set(P path, com.querydsl.core.types.Expression<T> value) -
setNull
public abstract <P extends com.querydsl.core.types.Path<T>,T> void setNull(P path) -
insertOwnedRow
public <TS,TR> TR insertOwnedRow(QOwnedByMapping<TS, TR, throws SchemaExceptionR> mapping, TS schemaObject) - Throws:
SchemaException
-
getSubcontext
-
addSubcontext
-
finishExecution
Executes collected updates if applicable including all subcontexts. Implement the logic for one context infinishExecutionOwn()
. Updates for subtree are executed first. Insert and delete clauses were all executed byItemDeltaValueProcessor
s already.- Throws:
SchemaException
RepositoryException
-
finishExecutionOwn
- Throws:
SchemaException
RepositoryException
-
findValueOrItem
-
findValueOrItem
-
isOverwrittenId
-