use of com.evolveum.midpoint.repo.sqale.qmodel.common.MUri in project midpoint by Evolveum.
the class UriCache method retrieveUriFromDb.
private String retrieveUriFromDb(Integer id) {
MUri row;
try (JdbcSession jdbcSession = jdbcSessionSupplier.get().startReadOnlyTransaction()) {
row = jdbcSession.newQuery().select(QUri.DEFAULT).from(QUri.DEFAULT).where(QUri.DEFAULT.id.eq(id)).fetchOne();
}
if (row == null) {
return null;
}
updateMaps(row);
return row.uri;
}
use of com.evolveum.midpoint.repo.sqale.qmodel.common.MUri in project midpoint by Evolveum.
the class UriCache method retrieveIdFromDb.
private Integer retrieveIdFromDb(String uriString) {
MUri row;
try (JdbcSession jdbcSession = jdbcSessionSupplier.get().startReadOnlyTransaction()) {
row = jdbcSession.newQuery().select(QUri.DEFAULT).from(QUri.DEFAULT).where(QUri.DEFAULT.uri.eq(uriString)).fetchOne();
}
if (row == null) {
return null;
}
updateMaps(row);
return row.id;
}
use of com.evolveum.midpoint.repo.sqale.qmodel.common.MUri in project midpoint by Evolveum.
the class UriCache method initialize.
/**
* Initializes the URI cache.
* Provided {@link JdbcSession} supplier will be used for later writes as well.
*/
public synchronized void initialize(Supplier<JdbcSession> jdbcSessionSupplier) {
this.jdbcSessionSupplier = jdbcSessionSupplier;
// this can be called repeatedly in tests, so the clear may be necessary
idToUri.clear();
uriToId.clear();
QUri uri = QUri.DEFAULT;
List<MUri> result;
try (JdbcSession jdbcSession = jdbcSessionSupplier.get().startReadOnlyTransaction()) {
result = jdbcSession.newQuery().select(uri).from(uri).fetch();
jdbcSession.commit();
}
for (MUri row : result) {
updateMaps(row);
}
LOGGER.info("URI cache initialized with {} items.", result.size());
}
Aggregations