Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo-sqale: SqaleModelMapping->STableM, added SqaleNestedMapping
- Loading branch information
Showing
11 changed files
with
142 additions
and
80 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
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
30 changes: 0 additions & 30 deletions
30
repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/SqaleModelMapping.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
.../repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/SqaleNestedMapping.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,58 @@ | ||
/* | ||
* 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.qmodel; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.prism.path.ItemName; | ||
import com.evolveum.midpoint.repo.sqale.RefTableItemFilterProcessor; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.ref.QReferenceMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.item.ItemSqlMapper; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.item.NestedMappingResolver; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; | ||
|
||
/** | ||
* Sqale implementation for nested mapping with support for sqale specific types. | ||
* This allows for fluent calls of methods like {@link #addRefMapping(QName, QReferenceMapping)} | ||
* which depend on sqale-specific types like {@link QReferenceMapping} in this example. | ||
*/ | ||
public class SqaleNestedMapping<S, Q extends FlexibleRelationalPathBase<R>, R> | ||
extends QueryModelMapping<S, Q, R> { | ||
|
||
protected SqaleNestedMapping(@NotNull Class<S> schemaType, @NotNull Class<Q> queryType) { | ||
super(schemaType, queryType); | ||
} | ||
|
||
@Override | ||
public SqaleNestedMapping<S, Q, R> addItemMapping( | ||
@NotNull QName itemName, @NotNull ItemSqlMapper itemMapper) { | ||
super.addItemMapping(itemName, itemMapper); | ||
return this; | ||
} | ||
|
||
// TODO will the version for RefItemFilterProcessor be useful too? Yes, if it needs relation mapping too! | ||
public final SqaleNestedMapping<S, Q, R> addRefMapping( | ||
@NotNull QName itemName, @NotNull QReferenceMapping qReferenceMapping) { | ||
((QueryModelMapping<?, ?, ?>) this).addItemMapping(itemName, | ||
RefTableItemFilterProcessor.mapper(qReferenceMapping)); | ||
// TODO add relation mapping too | ||
return this; | ||
} | ||
|
||
/** Nested mapping adaptation for repo-sqale. */ | ||
@Override | ||
public <N> SqaleNestedMapping<N, Q, R> nestedMapping( | ||
@NotNull ItemName itemName, @NotNull Class<N> nestedSchemaType) { | ||
SqaleNestedMapping<N, Q, R> nestedMapping = | ||
new SqaleNestedMapping<>(nestedSchemaType, queryType()); | ||
addRelationResolver(itemName, new NestedMappingResolver<>(nestedMapping)); | ||
return nestedMapping; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/SqaleTableMapping.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,56 @@ | ||
/* | ||
* 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.qmodel; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.prism.path.ItemName; | ||
import com.evolveum.midpoint.repo.sqale.RefTableItemFilterProcessor; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.QObject; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.ref.QReferenceMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryTableMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.mapping.item.NestedMappingResolver; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; | ||
|
||
/** | ||
* Mapping superclass with common functions for {@link QObject} and non-objects (e.g. containers). | ||
* | ||
* @see QueryTableMapping | ||
*/ | ||
public abstract class SqaleTableMapping<S, Q extends FlexibleRelationalPathBase<R>, R> | ||
extends QueryTableMapping<S, Q, R> { | ||
|
||
protected SqaleTableMapping( | ||
@NotNull String tableName, | ||
@NotNull String defaultAliasName, | ||
@NotNull Class<S> schemaType, | ||
@NotNull Class<Q> queryType) { | ||
super(tableName, defaultAliasName, schemaType, queryType); | ||
} | ||
|
||
/** Nested mapping adaptation for repo-sqale. */ | ||
@Override | ||
public <N> SqaleNestedMapping<N, Q, R> nestedMapping( | ||
@NotNull ItemName itemName, @NotNull Class<N> nestedSchemaType) { | ||
SqaleNestedMapping<N, Q, R> nestedMapping = | ||
new SqaleNestedMapping<>(nestedSchemaType, queryType()); | ||
addRelationResolver(itemName, new NestedMappingResolver<>(nestedMapping)); | ||
return nestedMapping; | ||
} | ||
|
||
// TODO will the version for RefItemFilterProcessor be useful too? | ||
// Yes, if it needs relation mapping too! | ||
public final void addRefMapping( | ||
@NotNull QName itemName, @NotNull QReferenceMapping qReferenceMapping) { | ||
((QueryModelMapping<?, ?, ?>) this).addItemMapping(itemName, | ||
RefTableItemFilterProcessor.mapper(qReferenceMapping)); | ||
// TODO add relation mapping too | ||
} | ||
} |
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
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.