-
Notifications
You must be signed in to change notification settings - Fork 188
/
SqaleUpdateContext.java
71 lines (55 loc) · 2.23 KB
/
SqaleUpdateContext.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
/*
* 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 javax.xml.namespace.QName;
import com.querydsl.core.types.Path;
import com.evolveum.midpoint.repo.sqale.qmodel.ref.QOwnedByMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.ref.TransformerForOwnedBy;
import com.evolveum.midpoint.repo.sqlbase.JdbcSession;
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
public abstract class SqaleUpdateContext<S, Q extends FlexibleRelationalPathBase<R>, R> {
protected final Trace logger = TraceManager.getTrace(getClass());
protected final SqaleTransformerSupport transformerSupport;
protected final JdbcSession jdbcSession;
protected final S object;
protected final R row;
public SqaleUpdateContext(SqaleTransformerSupport sqlTransformerSupport,
JdbcSession jdbcSession, S object, R row) {
this.transformerSupport = sqlTransformerSupport;
this.jdbcSession = jdbcSession;
this.object = object;
this.row = row;
}
public SqaleTransformerSupport transformerSupport() {
return transformerSupport;
}
public Integer processCacheableRelation(QName relation) {
return transformerSupport.processCacheableRelation(relation);
}
public Integer processCacheableUri(String uri) {
return transformerSupport.processCacheableUri(uri);
}
public JdbcSession jdbcSession() {
return jdbcSession;
}
public S schemaObject() {
return object;
}
public R row() {
return row;
}
public abstract Q path();
public abstract <P extends Path<T>, T> void set(P path, T value);
@SuppressWarnings("UnusedReturnValue")
public <TS, TR> TR insertOwnedRow(QOwnedByMapping<TS, TR, R> mapping, TS schemaObject) {
TransformerForOwnedBy<TS, TR, R> transformer =
mapping.createTransformer(transformerSupport());
return transformer.insert(schemaObject, row, jdbcSession);
}
}