Class QueryModelMapping<S,Q extends FlexibleRelationalPathBase<R>,R>
java.lang.Object
com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMapping<S,Q,R>
- Type Parameters:
S
- schema typeQ
- type of entity pathR
- row type related to theQueryModelMapping
- Direct Known Subclasses:
ExtensionMapping
,QueryTableMapping
,SqaleNestedMapping
Common mapping functionality that covers the need for mapping from item paths
to table columns, but also to nested embedded mappings (e.g. metadata).
This also works as implementation for nested mappings like `metadata` that contain attributes
resolved to the same query type - e.g. `metadata/createTimestamp`.
While `metadata` is resolved on the master mapping (for the query type representing table)
the nested `createTimestamp` is resolved by nested mapper implemented by this type.
Nested mapping can still contain relations, so
addRelationResolver(javax.xml.namespace.QName, com.evolveum.midpoint.repo.sqlbase.mapping.ItemRelationResolver<Q, R, ?, ?>)
is available.
Supertype QName
type is used instead of ItemName
for registration keys to
support also technical paths like parent (..).-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQueryModelMapping
(@NotNull Class<S> schemaType, @NotNull Class<Q> queryType) -
Method Summary
Modifier and TypeMethodDescriptionaddItemMapping
(@NotNull QName itemName, @NotNull ItemSqlMapper<Q, R> itemMapper) Adds information how item (attribute) from schema type is mapped to query, especially for condition creating purposes.addRelationResolver
(@NotNull QName itemName, @NotNull ItemRelationResolver<Q, R, ?, ?> itemRelationResolver) @Nullable ItemSqlMapper<Q,
R> getItemMapper
(QName itemName) ReturnsItemSqlMapper
for providedQName
or `null`.final @NotNull Map<QName,
ItemSqlMapper<Q, R>> Returns copy of the map of the item mappings.<TQ extends FlexibleRelationalPathBase<TR>,
TR>
@Nullable ItemRelationResolver<Q,R, TQ, TR> getRelationResolver
(QName itemName) ReturnsItemRelationResolver
for providedItemName
or `null`.final @NotNull ItemSqlMapper<Q,
R> itemMapper
(QName itemName) ReturnsItemSqlMapper
for providedQName
or throws.final <TQ extends FlexibleRelationalPathBase<TR>,
TR>
@NotNull ItemRelationResolver<Q,R, TQ, TR> relationResolver
(ItemPath path) ReturnsItemRelationResolver
for the first component of the providedItemPath
or throws if the resolver is not found.Returns schema type as class - refers to midPoint schema, not DB schema.
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
QueryModelMapping
-
-
Method Details
-
schemaType
Returns schema type as class - refers to midPoint schema, not DB schema. -
queryType
-
addItemMapping
public QueryModelMapping<S,Q, addItemMappingR> (@NotNull @NotNull QName itemName, @NotNull @NotNull ItemSqlMapper<Q, R> itemMapper) Adds information how item (attribute) from schema type is mapped to query, especially for condition creating purposes. This is not usable for complex item path resolution, seeaddRelationResolver(QName, ItemRelationResolver)
for that purpose. TheItemSqlMapper
works as a factory forFilterProcessor
that can processObjectFilter
related to theQName
specified as the first parameter. It is not possible to use filter processor directly because at the time of mapping specification we don't have the actual query path representing the entity or the column. These paths are non-static properties of query class instances. TheItemSqlMapper
also provides so-called "primary mapping" to a column for ORDER BY part of the filter. But there can be additional column mappings specified as for some types (e.g. poly-strings) there may be other than 1-to-1 mapping. Construction of theItemSqlMapper
is typically simplified by static methods#mapper()
provided on various*ItemFilterProcessor
classes. This works as a "processor factory-factory" and makes table mapping specification simpler.- Parameters:
itemName
- item name from schema type (seeF_*
constants on schema types)itemMapper
- mapper wrapping the information about column mappings working also as a factory forFilterProcessor
-
addRelationResolver
public QueryModelMapping<S,Q, addRelationResolverR> (@NotNull @NotNull QName itemName, @NotNull @NotNull ItemRelationResolver<Q, R, ?, ?> itemRelationResolver) -
itemMapper
ReturnsItemSqlMapper
for providedQName
or throws. This is later used to createItemValueFilterProcessor
.- Throws:
QueryException
- if the mapper for the item is not found
-
getItemMapper
ReturnsItemSqlMapper
for providedQName
or `null`. -
relationResolver
@NotNull public final <TQ extends FlexibleRelationalPathBase<TR>,TR> @NotNull ItemRelationResolver<Q,R, relationResolverTQ, TR> (ItemPath path) throws QueryException ReturnsItemRelationResolver
for the first component of the providedItemPath
or throws if the resolver is not found. Relation resolver helps with traversal over all-but-last components of item paths. ItemPath is used instead of QName to encapsulate corner cases like parent segment.- Type Parameters:
TQ
- type of target entity pathTR
- row type related to the target entity pathQueryModelMapping
- Throws:
QueryException
- if the resolver for the item is not found
-
getRelationResolver
@Nullable public <TQ extends FlexibleRelationalPathBase<TR>,TR> @Nullable ItemRelationResolver<Q,R, getRelationResolverTQ, TR> (QName itemName) ReturnsItemRelationResolver
for providedItemName
or `null`.- Type Parameters:
TQ
- type of target entity pathTR
- row type related to the target entity pathQueryModelMapping
-
getItemMappings
Returns copy of the map of the item mappings. -
itemDefinition
-