use of org.jooq.Record1 in project jOOQ by jOOQ.
the class SQLiteDatabase method getTables0.
@Override
protected List<TableDefinition> getTables0() throws SQLException {
List<TableDefinition> result = new ArrayList<>();
CommonTableExpression<Record1<String>> virtualTables = name("virtual_tables").fields("name").as(select(coalesce(SQLiteMaster.NAME, inline(""))).from(SQLITE_MASTER).where(SQLiteMaster.SQL.likeIgnoreCase(inline("%create virtual table%"))));
for (Record record : create().with(virtualTables).select(SQLiteMaster.NAME, when(SQLiteMaster.TYPE.eq(inline("view")), inline(TableType.VIEW.name())).else_(inline(TableType.TABLE.name())).as("table_type"), SQLiteMaster.SQL).from(SQLITE_MASTER).where(SQLiteMaster.TYPE.in("table", "view")).and(getIncludeSystemTables() ? noCondition() : SQLiteMaster.NAME.notLike(all(inline("%!_content"), inline("%!_segments"), inline("%!_segdir"), inline("%!_docsize"), inline("%!_stat"))).escape('!').or(SQLiteMaster.NAME.like(inline("%!_content")).escape('!').and(replace(SQLiteMaster.NAME, inline("_content")).notIn(selectFrom(virtualTables)))).or(SQLiteMaster.NAME.like(inline("%!_segments")).escape('!').and(replace(SQLiteMaster.NAME, inline("_segments")).notIn(selectFrom(virtualTables)))).or(SQLiteMaster.NAME.like(inline("%!_segdir")).escape('!').and(replace(SQLiteMaster.NAME, inline("_segdir")).notIn(selectFrom(virtualTables)))).or(SQLiteMaster.NAME.like(inline("%!_docsize")).escape('!').and(replace(SQLiteMaster.NAME, inline("_docsize")).notIn(selectFrom(virtualTables)))).or(SQLiteMaster.NAME.like(inline("%!_stat")).escape('!').and(replace(SQLiteMaster.NAME, inline("_stat")).notIn(selectFrom(virtualTables))))).orderBy(SQLiteMaster.NAME)) {
String name = record.get(SQLiteMaster.NAME);
TableType tableType = record.get("table_type", TableType.class);
String source = record.get(SQLiteMaster.SQL);
result.add(new SQLiteTableDefinition(getSchemata().get(0), name, "", tableType, source));
}
return result;
}
use of org.jooq.Record1 in project collect by openforis.
the class DynamicTableDao method exists.
public boolean exists(String table, NameValueEntry[] filters, String[] notNullColumns) {
Lookup lookupTable = getLookupTable(table);
SelectJoinStep<Record1<Integer>> select = dsl().selectCount().from(lookupTable);
addFilterConditions(lookupTable, select, filters);
addNotNullConditions(lookupTable, select, notNullColumns);
Record record = select.fetchOne();
Integer count = (Integer) record.getValue(0);
return count > 0;
}
use of org.jooq.Record1 in project collect by openforis.
the class RecordDao method selectWorkflowSequenceNumber.
private Select<Record1<Integer>> selectWorkflowSequenceNumber(int recordId, Step step, boolean notRejected) {
Condition condition = OFC_RECORD_DATA.RECORD_ID.eq(recordId);
if (notRejected) {
condition = condition.and(OFC_RECORD_DATA.STATE.isNull());
}
if (step != null) {
condition = condition.and(OFC_RECORD_DATA.STEP.eq(step.getStepNumber()));
}
Select<Record1<Integer>> query = dsl.select(max(OFC_RECORD_DATA.SEQ_NUM)).from(OFC_RECORD_DATA).where(condition);
return query;
}
Aggregations