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:
QueryTableMapping
public class QueryModelMapping<S,Q extends FlexibleRelationalPathBase<R>,R> extends Object
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, soaddRelationResolver(com.evolveum.midpoint.prism.path.ItemName, com.evolveum.midpoint.repo.sqlbase.mapping.item.ItemRelationResolver)
is available.
-
-
Constructor Summary
Constructors Constructor Description QueryModelMapping(@NotNull Class<S> schemaType, @NotNull Class<Q> queryType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryModelMapping<S,Q,R>
addItemMapping(@NotNull QName itemName, @NotNull ItemSqlMapper itemMapper)
Adds information how item (attribute) from schema type is mapped to query, especially for condition creating purposes.<N> QueryModelMapping<N,Q,R>
addNestedMapping(@NotNull ItemName itemName, @NotNull Class<N> nestedSchemaType)
Creates relation resolver for nested mapping and returns the mapping so the nested items can be mapped in a fluent matter.QueryModelMapping<S,Q,R>
addRelationResolver(@NotNull ItemName itemName, @NotNull ItemRelationResolver itemRelationResolver)
@Nullable ItemSqlMapper
getItemMapper(QName itemName)
ReturnsItemSqlMapper
for providedItemName
or `null`.@Nullable ItemRelationResolver
getRelationResolver(ItemName itemName)
ReturnsItemRelationResolver
for providedItemName
or `null`.@NotNull ItemSqlMapper
itemMapper(QName itemName)
ReturnsItemSqlMapper
for providedItemName
or throws.Class<Q>
queryType()
@NotNull ItemRelationResolver
relationResolver(ItemName itemName)
ReturnsItemRelationResolver
for providedItemName
or throws.Class<S>
schemaType()
Returns schema type as class - refers to midPoint schema, not DB schema.
-
-
-
Method Detail
-
schemaType
public Class<S> schemaType()
Returns schema type as class - refers to midPoint schema, not DB schema.
-
addItemMapping
public QueryModelMapping<S,Q,R> addItemMapping(@NotNull @NotNull QName itemName, @NotNull @NotNull ItemSqlMapper 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(ItemName, ItemRelationResolver)
for that purpose. TheItemSqlMapper
works as a factory forFilterProcessor
that can processObjectFilter
related to theItemName
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,R> addRelationResolver(@NotNull @NotNull ItemName itemName, @NotNull @NotNull ItemRelationResolver itemRelationResolver)
-
itemMapper
@NotNull public final @NotNull ItemSqlMapper itemMapper(QName itemName) throws QueryException
ReturnsItemSqlMapper
for providedItemName
or throws. This is later used to createItemFilterProcessor
.- Throws:
QueryException
- if the mapper for the item is not found
-
getItemMapper
@Nullable public final @Nullable ItemSqlMapper getItemMapper(QName itemName)
ReturnsItemSqlMapper
for providedItemName
or `null`.
-
relationResolver
@NotNull public final @NotNull ItemRelationResolver relationResolver(ItemName itemName) throws QueryException
ReturnsItemRelationResolver
for providedItemName
or throws. Relation resolver helps with traversal over all-but-last components of item paths.- Throws:
QueryException
- if the resolver for the item is not found
-
getRelationResolver
@Nullable public final @Nullable ItemRelationResolver getRelationResolver(ItemName itemName)
ReturnsItemRelationResolver
for providedItemName
or `null`.
-
addNestedMapping
public <N> QueryModelMapping<N,Q,R> addNestedMapping(@NotNull @NotNull ItemName itemName, @NotNull @NotNull Class<N> nestedSchemaType)
Creates relation resolver for nested mapping and returns the mapping so the nested items can be mapped in a fluent matter.
-
-