Search in sources :

Example 56 with Record1

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;
}
Also used : TableType(org.jooq.TableOptions.TableType) ArrayList(java.util.ArrayList) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) Record1(org.jooq.Record1)

Example 57 with Record1

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;
}
Also used : Lookup(org.openforis.collect.persistence.jooq.tables.Lookup) Record(org.jooq.Record) LookupRecord(org.openforis.collect.persistence.jooq.tables.records.LookupRecord) Record1(org.jooq.Record1)

Example 58 with Record1

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;
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Aggregations

Record1 (org.jooq.Record1)58 Condition (org.jooq.Condition)22 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)16 DSLContext (org.jooq.DSLContext)14 Select (org.jooq.Select)10 ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)9 EntityReference (org.finos.waltz.model.EntityReference)8 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8 Record (org.jooq.Record)7 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)5 EntityKind (org.finos.waltz.model.EntityKind)5 EntityReference (com.khartec.waltz.model.EntityReference)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)4 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)4 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)4 DSL (org.jooq.impl.DSL)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3