-
Notifications
You must be signed in to change notification settings - Fork 188
/
SqaleSupportService.java
72 lines (58 loc) · 2.46 KB
/
SqaleSupportService.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 org.jetbrains.annotations.NotNull;
import com.evolveum.midpoint.repo.sqale.qmodel.common.QUri;
import com.evolveum.midpoint.repo.sqlbase.SqlSupportService;
import com.evolveum.midpoint.schema.SchemaService;
import com.evolveum.midpoint.util.QNameUtil;
/**
* Extension of {@link SqlSupportService} adding Sqale features like {@link UriCache} support.
*/
public class SqaleSupportService extends SqlSupportService {
private static SqaleSupportService instance;
public SqaleSupportService(SchemaService schemaService, SqaleRepoContext sqaleRepoContext) {
super(schemaService, sqaleRepoContext);
instance = this;
}
public static SqaleSupportService getInstance() {
return instance;
}
private SqaleRepoContext sqaleRepoContext() {
return (SqaleRepoContext) sqlRepoContext;
}
/**
* Returns ID for relation QName or {@link UriCache#UNKNOWN_ID} without going to the database.
* Relation is normalized before consulting {@link UriCache}.
* Never returns null; returns default ID for configured default relation if provided with null.
*/
public @NotNull Integer searchCachedRelationId(QName qName) {
return sqaleRepoContext().searchCachedUriId(QNameUtil.qNameToUri(normalizeRelation(qName)));
}
/** Returns ID for cached URI without going to the database. */
public Integer resolveUriToId(String uri) {
return sqaleRepoContext().resolveUriToId(uri);
}
/** Returns ID for cached URI without going to the database. */
public Integer resolveUriToId(QName uri) {
return sqaleRepoContext().resolveUriToId(uri);
}
/**
* Returns ID for relation QName creating new {@link QUri} row in DB as needed.
* Relation is normalized before consulting the cache.
* Never returns null, returns default ID for configured default relation.
*/
public Integer processCacheableRelation(QName qName) {
return processCacheableUri(
QNameUtil.qNameToUri(normalizeRelation(qName)));
}
/** Returns ID for URI creating new cache row in DB as needed. */
public Integer processCacheableUri(String uri) {
return sqaleRepoContext().processCacheableUri(uri);
}
}