@Override public RESP_R withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(responsesTable) .where(DSL.field(KB_PAYMENT_ID).equal(kbPaymentId.toString())) .and(DSL.field(TRANSACTION_TYPE).equal(TransactionType.AUTHORIZE.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).desc()) .limit(1) .fetchOne(); } });
@Override public Account getAdminAccount() { return create() .selectFrom(ACCOUNT) .where(ACCOUNT.STATE.in(getActiveStates()) .and(ACCOUNT.KIND.eq(AccountConstants.ADMIN_KIND))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne(); }
@Override public Account getAccountByUuid(String uuid) { return create() .selectFrom(ACCOUNT) .where(ACCOUNT.UUID.eq(uuid) .and(ACCOUNT.STATE.in(getActiveStates()))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne(); }
@Override public Account getAdminAccountExclude(long accountId) { return create() .selectFrom(ACCOUNT) .where(ACCOUNT.STATE.in(getAccountActiveStates()) .and(ACCOUNT.KIND.eq(AccountConstants.ADMIN_KIND)) .and(ACCOUNT.ID.ne(accountId))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne(); }
.where(ACCOUNT.STATE.in(accountDao.getAccountActiveStates()) .and(ACCOUNT.KIND.eq(AccountConstants.ADMIN_KIND))) .orderBy(ACCOUNT.ID.asc()).limit(1).fetchOne();
@Override public LocalPage getById(Language language, int pageId) throws DaoException { DSLContext context = getJooq(); try { Record record = context.select(). from(Tables.LOCAL_PAGE). where(Tables.LOCAL_PAGE.PAGE_ID.eq(pageId)). and(Tables.LOCAL_PAGE.LANG_ID.eq(language.getId())). limit(1). fetchOne(); return buildLocalPage(record); } finally { freeJooq(context); } }
@Override public int getUnivPageId(Language language, int localPageId) throws DaoException { DSLContext context = getJooq(); try { Record record = context.select() .from(Tables.UNIVERSAL_PAGE) .where(Tables.UNIVERSAL_PAGE.LANG_ID.eq(language.getId())) .and(Tables.UNIVERSAL_PAGE.PAGE_ID.eq(localPageId)) .and(Tables.UNIVERSAL_PAGE.ALGORITHM_ID.eq(algorithmId)) .limit(1) // TODO: Remove .fetchOne(); if (record == null) { return -1; } else { return record.getValue(Tables.UNIVERSAL_PAGE.UNIV_ID); } } finally { freeJooq(context); } }
/** * Returns the local page id for that language, or -1 if it does not exist * @param language * @param universalId * @return * @throws DaoException */ @Override public int getLocalId(Language language, int universalId) throws DaoException { DSLContext context = getJooq(); try { Record record = context.select() .from(Tables.UNIVERSAL_PAGE) .where(Tables.UNIVERSAL_PAGE.LANG_ID.eq(language.getId())) .and(Tables.UNIVERSAL_PAGE.UNIV_ID.eq(universalId)) .and(Tables.UNIVERSAL_PAGE.ALGORITHM_ID.eq(algorithmId)) .limit(1) // TODO: Remove .fetchOne(); if (record == null) { return -1; } else { return record.getValue(Tables.UNIVERSAL_PAGE.PAGE_ID); } } finally { freeJooq(context); } }
@Override public LocalPage getByTitle(Title title, NameSpace nameSpace) throws DaoException { DSLContext context = getJooq(); try { Record record = context.select(). from(Tables.LOCAL_PAGE). where(Tables.LOCAL_PAGE.TITLE.eq(title.getCanonicalTitle())). and(Tables.LOCAL_PAGE.LANG_ID.eq(title.getLanguage().getId())). and(Tables.LOCAL_PAGE.NAME_SPACE.eq(nameSpace.getArbitraryId())). limit(1). fetchOne(); return buildLocalPage(record); } finally { freeJooq(context); } }