Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo-sqale: added UriItemFilterProcessor, the rest or QObject is mapped
- Loading branch information
Showing
5 changed files
with
115 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/UriItemFilterProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale; | ||
|
||
import java.util.function.Function; | ||
|
||
import com.querydsl.core.types.EntityPath; | ||
import com.querydsl.core.types.Predicate; | ||
import com.querydsl.core.types.dsl.NumberPath; | ||
|
||
import com.evolveum.midpoint.prism.query.PropertyValueFilter; | ||
import com.evolveum.midpoint.repo.sqlbase.QueryException; | ||
import com.evolveum.midpoint.repo.sqlbase.SqlQueryContext; | ||
import com.evolveum.midpoint.repo.sqlbase.filtering.ValueFilterValues; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.item.ItemFilterProcessor; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.item.ItemSqlMapper; | ||
|
||
/** | ||
* Filter processor for URI item paths - represented as strings in schema and by int ID in DB. | ||
* TODO: if used for order it would require join to QUri, otherwise it just sorts by URI ID. | ||
*/ | ||
public class UriItemFilterProcessor extends ItemFilterProcessor<PropertyValueFilter<String>> { | ||
|
||
/** | ||
* Returns the mapper function creating the ref-filter processor from query context. | ||
*/ | ||
public static ItemSqlMapper mapper( | ||
Function<EntityPath<?>, NumberPath<Integer>> rootToPath) { | ||
return new ItemSqlMapper(ctx -> new UriItemFilterProcessor(ctx, rootToPath)); | ||
} | ||
|
||
private final NumberPath<Integer> path; | ||
|
||
private UriItemFilterProcessor( | ||
SqlQueryContext<?, ?, ?> context, | ||
Function<EntityPath<?>, NumberPath<Integer>> rootToPath) { | ||
super(context); | ||
this.path = rootToPath.apply(context.path()); | ||
} | ||
|
||
@Override | ||
public Predicate process(PropertyValueFilter<String> filter) throws QueryException { | ||
return createBinaryCondition(filter, path, | ||
ValueFilterValues.from(filter, | ||
u -> ((SqaleRepoContext) context.sqlRepoContext()).searchCachedUriId(u))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters