Search in sources :

Example 1 with UserDSLContext

use of org.openforis.collect.persistence.UserDao.UserDSLContext in project collect by openforis.

the class UserDao method loadByUserName.

public User loadByUserName(String userName, Boolean enabled) {
    UserDSLContext dsl = dsl();
    SelectConditionStep<OfcUserRecord> query = dsl.selectFrom(OFC_USER).where(OFC_USER.USERNAME.equal(userName));
    if (enabled != null) {
        String enabledFlag = enabled ? "Y" : "N";
        query.and(OFC_USER.ENABLED.equal(enabledFlag));
    }
    Record r = query.fetchOne();
    User user = r != null ? dsl.fromRecord(r) : null;
    return user;
}
Also used : User(org.openforis.collect.model.User) UserDSLContext(org.openforis.collect.persistence.UserDao.UserDSLContext) OfcUserRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord) Record(org.jooq.Record) OfcUserRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord) OfcUserRoleRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRoleRecord)

Example 2 with UserDSLContext

use of org.openforis.collect.persistence.UserDao.UserDSLContext in project collect by openforis.

the class UserDao method getUserId.

public int getUserId(String username) {
    UserDSLContext jf = dsl();
    Record record = jf.select(OFC_USER.ID).from(OFC_USER).where(OFC_USER.USERNAME.equal(username)).fetchOne();
    Integer id = record.getValue(OFC_USER.ID);
    return id;
}
Also used : UserDSLContext(org.openforis.collect.persistence.UserDao.UserDSLContext) Record(org.jooq.Record) OfcUserRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord) OfcUserRoleRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRoleRecord)

Example 3 with UserDSLContext

use of org.openforis.collect.persistence.UserDao.UserDSLContext in project collect by openforis.

the class UserDao method loadAll.

@Override
public List<User> loadAll() {
    UserDSLContext dsl = dsl();
    Result<OfcUserRecord> r = dsl.selectFrom(OFC_USER).orderBy(OFC_USER.USERNAME).fetch();
    List<User> users = r != null ? dsl.fromResult(r) : null;
    return users;
}
Also used : User(org.openforis.collect.model.User) UserDSLContext(org.openforis.collect.persistence.UserDao.UserDSLContext) OfcUserRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord)

Example 4 with UserDSLContext

use of org.openforis.collect.persistence.UserDao.UserDSLContext in project collect by openforis.

the class UserDao method loadById.

@Override
public User loadById(Integer id) {
    UserDSLContext dsl = dsl();
    SelectQuery<?> query = dsl.selectByIdQuery(id);
    Record r = query.fetchOne();
    User user = r != null ? dsl.fromRecord(r) : null;
    return user;
}
Also used : User(org.openforis.collect.model.User) UserDSLContext(org.openforis.collect.persistence.UserDao.UserDSLContext) Record(org.jooq.Record) OfcUserRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord) OfcUserRoleRecord(org.openforis.collect.persistence.jooq.tables.records.OfcUserRoleRecord)

Aggregations

UserDSLContext (org.openforis.collect.persistence.UserDao.UserDSLContext)4 OfcUserRecord (org.openforis.collect.persistence.jooq.tables.records.OfcUserRecord)4 Record (org.jooq.Record)3 User (org.openforis.collect.model.User)3 OfcUserRoleRecord (org.openforis.collect.persistence.jooq.tables.records.OfcUserRoleRecord)3