-
Notifications
You must be signed in to change notification settings - Fork 188
/
SqaleTableMapping.java
136 lines (122 loc) · 6.24 KB
/
SqaleTableMapping.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 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 java.util.function.Function;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.dsl.*;
import org.jetbrains.annotations.NotNull;
import com.evolveum.midpoint.repo.sqale.delta.item.*;
import com.evolveum.midpoint.repo.sqale.filtering.RefItemFilterProcessor;
import com.evolveum.midpoint.repo.sqale.filtering.UriItemFilterProcessor;
import com.evolveum.midpoint.repo.sqale.mapping.SqaleItemSqlMapper;
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType;
import com.evolveum.midpoint.repo.sqale.qmodel.object.QObject;
import com.evolveum.midpoint.repo.sqlbase.filtering.item.EnumItemFilterProcessor;
import com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor;
import com.evolveum.midpoint.repo.sqlbase.filtering.item.SimpleItemFilterProcessor;
import com.evolveum.midpoint.repo.sqlbase.filtering.item.TimestampItemFilterProcessor;
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryTableMapping;
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase;
import com.evolveum.midpoint.repo.sqlbase.querydsl.UuidPath;
/**
* Mapping superclass with common functions for {@link QObject} and non-objects (e.g. containers).
*
* @param <S> schema type
* @param <Q> type of entity path
* @param <R> row type related to the {@link Q}
* @see QueryTableMapping
*/
public abstract class SqaleTableMapping<S, Q extends FlexibleRelationalPathBase<R>, R>
extends QueryTableMapping<S, Q, R>
implements SqaleMappingMixin<S, Q, R> {
protected SqaleTableMapping(
@NotNull String tableName,
@NotNull String defaultAliasName,
@NotNull Class<S> schemaType,
@NotNull Class<Q> queryType) {
super(tableName, defaultAliasName, schemaType, queryType);
}
/** Returns the mapper creating the string filter/delta processors from context. */
@Override
protected SqaleItemSqlMapper stringMapper(
Function<EntityPath<?>, StringPath> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new SimpleItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new SimpleItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
/** Returns the mapper creating the integer filter/delta processors from context. */
@Override
public SqaleItemSqlMapper integerMapper(
Function<EntityPath<?>, NumberPath<Integer>> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new SimpleItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new SimpleItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
/** Returns the mapper creating the boolean filter/delta processors from context. */
@Override
protected SqaleItemSqlMapper booleanMapper(Function<EntityPath<?>, BooleanPath> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new SimpleItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new SimpleItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
/** Returns the mapper creating the UUID filter/delta processors from context. */
@Override
protected SqaleItemSqlMapper uuidMapper(Function<EntityPath<?>, UuidPath> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new SimpleItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new SimpleItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
/** Returns the mapper creating the timestamp filter/delta processors from context. */
@Override
protected <T extends Comparable<T>> SqaleItemSqlMapper timestampMapper(
Function<EntityPath<?>, DateTimePath<T>> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new TimestampItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new TimestampItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
/** Returns the mapper creating the polystring filter/delta processors from context. */
@Override
protected SqaleItemSqlMapper polyStringMapper(
@NotNull Function<EntityPath<?>, StringPath> origMapping,
@NotNull Function<EntityPath<?>, StringPath> normMapping) {
return new SqaleItemSqlMapper(
ctx -> new PolyStringItemFilterProcessor(ctx, origMapping, normMapping),
ctx -> new PolyStringItemDeltaProcessor(ctx, origMapping, normMapping),
origMapping);
}
/** Returns the mapper creating the reference filter/delta processors from context. */
protected SqaleItemSqlMapper refMapper(
Function<EntityPath<?>, UuidPath> rootToOidPath,
Function<EntityPath<?>, EnumPath<MObjectType>> rootToTypePath,
Function<EntityPath<?>, NumberPath<Integer>> rootToRelationIdPath) {
return new SqaleItemSqlMapper(
ctx -> new RefItemFilterProcessor(ctx,
rootToOidPath, rootToTypePath, rootToRelationIdPath),
ctx -> new RefItemDeltaProcessor(ctx,
rootToOidPath, rootToTypePath, rootToRelationIdPath));
}
/** Returns the mapper creating the cached URI filter/delta processors from context. */
protected SqaleItemSqlMapper uriMapper(
Function<EntityPath<?>, NumberPath<Integer>> rootToPath) {
return new SqaleItemSqlMapper(
ctx -> new UriItemFilterProcessor(ctx, rootToPath),
ctx -> new UriItemDeltaProcessor(ctx, rootToPath));
}
/** Returns the mapper creating the enum filter/delta processors from context. */
public <E extends Enum<E>> SqaleItemSqlMapper enumMapper(
@NotNull Function<EntityPath<?>, EnumPath<E>> rootToQueryItem) {
return new SqaleItemSqlMapper(
ctx -> new EnumItemFilterProcessor<>(ctx, rootToQueryItem),
ctx -> new EnumItemDeltaProcessor<>(ctx, rootToQueryItem),
rootToQueryItem);
}
}