Skip to content

Commit

Permalink
repo-sqale: javadoc for ExtensionItemSqlMapper and ExtensionMapping
Browse files Browse the repository at this point in the history
Also stateless ExtensionItemSqlMapper is instantiated in constructor
of ExtensionMapping, not every time in getItemMapper().
  • Loading branch information
virgo47 committed Jun 29, 2021
1 parent 75452bc commit 147d449
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -24,7 +24,11 @@
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase;

/**
* TODO: this much "lazier" than normal item mapper, we'll get to ext definitions only here, not sooner.
* Extension item mapper that is much lazier than {@link SqaleItemSqlMapper} for typical column.
* Normally the mapper knows how to get from the query/update contextual information to the columns.
* This mapper only knows the way to the JSONB column and lets extension item filter/delta
* processors to do the rest of the work based on the context and item information contained in
* the filter/modification.
*
* @param <Q> entity path owning the mapped item
* @param <R> row type with the mapped item
Expand All @@ -48,6 +52,7 @@ public ExtensionItemSqlMapper(
// - sorting by ext does not make sense, we want to sort by ext->something (or ->>)
// - that also means that we don't want to return Path but Expression instead
// - but sorting by ext/something is not yet supported in SqlQueryContext.processOrdering
// In short, we will not even get here
return rootToExtensionPath.apply(entityPath);
}

Expand Down
Expand Up @@ -22,8 +22,8 @@
/**
* This acts like a container mapping for extension/attributes containers.
* Compared to other subclasses of {@link QueryModelMapping} this does NOT use the item mapping
* and resolver maps, but instead creates the mapper on the fly with currently available information
* and lets the extension mapper/resolver do the real work.
* and resolver maps, but instead returns the same stateless mapper which then delegates
* all the real work to item filter/delta processors (see {@link ExtensionItemSqlMapper}).
* This allows for dynamic mapping which is needed especially for shadow attributes.
*
* @param <Q> type of entity path
Expand All @@ -33,7 +33,7 @@ public class ExtensionMapping<Q extends FlexibleRelationalPathBase<R>, R>
extends QueryModelMapping<Containerable, Q, R> {

private final MExtItemHolderType holderType;
private final Function<Q, JsonbPath> rootToExtensionPath;
private final ExtensionItemSqlMapper<Q, R> itemMapper;

protected ExtensionMapping(
@NotNull MExtItemHolderType holderType,
Expand All @@ -42,12 +42,12 @@ protected ExtensionMapping(
super(Containerable.class, queryType);

this.holderType = holderType;
this.rootToExtensionPath = rootToExtensionPath;
this.itemMapper = new ExtensionItemSqlMapper<>(rootToExtensionPath, holderType);
}

@Override
public @Nullable ItemSqlMapper<Q, R> getItemMapper(QName itemName) {
return new ExtensionItemSqlMapper<>(rootToExtensionPath, holderType);
return itemMapper;
}

public MExtItemHolderType holderType() {
Expand Down

0 comments on commit 147d449

Please sign in to comment.