Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-6319: little progress with condition mapping
- Loading branch information
Showing
9 changed files
with
261 additions
and
31 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
29 changes: 29 additions & 0 deletions
29
repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/pure/SqlPathContext.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,29 @@ | ||
package com.evolveum.midpoint.repo.sql.pure; | ||
|
||
import com.evolveum.midpoint.repo.sql.pure.mapping.QueryModelMapping; | ||
|
||
/** | ||
* SQL path context with mapping information. | ||
*/ | ||
public class SqlPathContext { | ||
|
||
private final FlexibleRelationalPathBase<?> path; | ||
private final QueryModelMapping<?, ?> mapping; | ||
|
||
public SqlPathContext(FlexibleRelationalPathBase<?> path, QueryModelMapping<?, ?> mapping) { | ||
this.path = path; | ||
this.mapping = mapping; | ||
} | ||
|
||
public FlexibleRelationalPathBase<?> path() { | ||
return path; | ||
} | ||
|
||
public <T extends FlexibleRelationalPathBase<?>> T path(Class<T> pathType) { | ||
return pathType.cast(path); | ||
} | ||
|
||
public QueryModelMapping<?, ?> mapping() { | ||
return mapping; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/pure/SqlQueryContext.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,42 @@ | ||
package com.evolveum.midpoint.repo.sql.pure; | ||
|
||
import static com.evolveum.midpoint.repo.sql.pure.SqlQueryExecutor.QUERYDSL_CONFIGURATION; | ||
|
||
import java.sql.Connection; | ||
|
||
import com.querydsl.core.types.Predicate; | ||
import com.querydsl.sql.SQLQuery; | ||
|
||
import com.evolveum.midpoint.repo.sql.pure.mapping.QueryModelMapping; | ||
|
||
/** | ||
* Context information about SQL query. | ||
* Works as a kind of accumulator where information are added as the object query is interpreted. | ||
*/ | ||
public class SqlQueryContext extends SqlPathContext { | ||
|
||
private final SQLQuery<?> query; | ||
|
||
public SqlQueryContext( | ||
FlexibleRelationalPathBase<?> root, | ||
QueryModelMapping<?, ?> rootMapping) { | ||
super(root, rootMapping); | ||
query = new SQLQuery<>(QUERYDSL_CONFIGURATION).from(root); | ||
} | ||
|
||
public FlexibleRelationalPathBase<?> root() { | ||
return path(); | ||
} | ||
|
||
public <T extends FlexibleRelationalPathBase<?>> T root(Class<T> rootType) { | ||
return path(rootType); | ||
} | ||
|
||
public SQLQuery<?> query(Connection connection) { | ||
return query.clone(connection); | ||
} | ||
|
||
public void addPredicate(Predicate predicate) { | ||
query.where(predicate); | ||
} | ||
} |
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
Oops, something went wrong.