Search in sources :

Example 1 with MUri

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;
}
Also used : JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) MUri(com.evolveum.midpoint.repo.sqale.qmodel.common.MUri)

Example 2 with MUri

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;
}
Also used : JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) MUri(com.evolveum.midpoint.repo.sqale.qmodel.common.MUri)

Example 3 with MUri

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());
}
Also used : JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) MUri(com.evolveum.midpoint.repo.sqale.qmodel.common.MUri) QUri(com.evolveum.midpoint.repo.sqale.qmodel.common.QUri)

Aggregations

MUri (com.evolveum.midpoint.repo.sqale.qmodel.common.MUri)3 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)3 QUri (com.evolveum.midpoint.repo.sqale.qmodel.common.QUri)1