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 type
R - row type related to the SqaleUpdateContext
Direct Known Subclasses:
ContainerTableUpdateContext, ExtensionUpdateContext, NestedContainerUpdateContext, RootUpdateContext, ShadowReferenceAttributesUpdateContext

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 Details

    • 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 known ItemPath 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

  • Method Details

    • 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 in finishExecutionOwn(). Updates for subtree are executed first. Insert and delete clauses were all executed by ItemDeltaValueProcessors 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)