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 ofItemDeltaValueProcessor
is then created for `channel` based on the type of the property (in this caseUriItemDeltaProcessor
) 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 methodfinishExecution()
called from theRootUpdateContext
. Subclasses implement their specific logic infinishExecutionOwn()
.
-
-
Field Summary
Fields Modifier and Type Field Description protected JdbcSession
jdbcSession
protected Trace
logger
protected SqaleUpdateContext<?,?,?>
parentContext
Parent is typically used to do some work for the child like when nested container uses the parent's UPDATE clause.protected R
row
protected Map<ItemPath,SqaleUpdateContext<?,?,?>>
subcontexts
Map of subcontext for knownItemPath
sub-paths relative to this context.
-
Constructor Summary
Constructors Constructor Description SqaleUpdateContext(SqaleRepoContext repositoryContext, JdbcSession jdbcSession, R row)
SqaleUpdateContext(SqaleUpdateContext<?,?,?> parentContext, R row)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addSubcontext(ItemPath itemPath, SqaleUpdateContext<?,?,?> subcontext)
abstract Q
entityPath()
Returns entity path (table) for the context.<O> O
findValueOrItem(@NotNull ItemPath path)
<O> O
findValueOrItem(@NotNull Object... path)
protected void
finishExecution()
Executes collected updates if applicable including all subcontexts.protected abstract void
finishExecutionOwn()
SqaleUpdateContext<?,?,?>
getSubcontext(ItemPath itemPath)
<TS,TR>
TRinsertOwnedRow(QOwnedByMapping<TS,TR,R> mapping, TS schemaObject)
boolean
isOverwrittenId(Long id)
JdbcSession
jdbcSession()
abstract QueryModelMapping<S,Q,R>
mapping()
SqaleRepoContext
repositoryContext()
R
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 Detail
-
logger
protected final Trace logger
-
jdbcSession
protected final JdbcSession jdbcSession
-
row
protected final R row
-
parentContext
protected final SqaleUpdateContext<?,?,?> parentContext
Parent is typically used to do some work for the child like when nested container uses the parent's UPDATE clause.
-
subcontexts
protected final Map<ItemPath,SqaleUpdateContext<?,?,?>> 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 Detail
-
SqaleUpdateContext
public SqaleUpdateContext(SqaleRepoContext repositoryContext, JdbcSession jdbcSession, R row)
-
SqaleUpdateContext
public SqaleUpdateContext(SqaleUpdateContext<?,?,?> parentContext, R row)
-
-
Method Detail
-
repositoryContext
public SqaleRepoContext repositoryContext()
-
jdbcSession
public JdbcSession jdbcSession()
-
row
public R row()
-
entityPath
public abstract Q 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
public abstract QueryModelMapping<S,Q,R> 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,R> mapping, TS schemaObject) throws SchemaException
- Throws:
SchemaException
-
getSubcontext
public SqaleUpdateContext<?,?,?> getSubcontext(ItemPath itemPath)
-
addSubcontext
public void addSubcontext(ItemPath itemPath, SqaleUpdateContext<?,?,?> subcontext)
-
finishExecution
protected final void finishExecution() throws SchemaException, RepositoryException
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
protected abstract void finishExecutionOwn() throws SchemaException, RepositoryException
- Throws:
SchemaException
RepositoryException
-
findValueOrItem
public final <O> O findValueOrItem(@NotNull @NotNull Object... path)
-
findValueOrItem
public <O> O findValueOrItem(@NotNull @NotNull ItemPath path)
-
isOverwrittenId
public boolean isOverwrittenId(Long id)
-
-