Search in sources :

Example 1 with Domains

use of org.jooq.meta.hsqldb.information_schema.tables.Domains in project jOOQ by jOOQ.

the class H2Database method getDomains2_0.

private List<DomainDefinition> getDomains2_0() {
    List<DomainDefinition> result = new ArrayList<>();
    Domains d = Tables.DOMAINS.as("d");
    DomainConstraints dc = DOMAIN_CONSTRAINTS.as("dc");
    for (Record record : create().select(d.DOMAIN_SCHEMA, d.DOMAIN_NAME, d.DATA_TYPE, d.CHARACTER_MAXIMUM_LENGTH, coalesce(d.DATETIME_PRECISION, d.NUMERIC_PRECISION).as(d.NUMERIC_PRECISION), d.NUMERIC_SCALE, d.DOMAIN_DEFAULT, dc.checkConstraints().CHECK_CLAUSE).from(d).leftJoin(dc).on(d.DOMAIN_CATALOG.eq(dc.DOMAIN_CATALOG)).and(d.DOMAIN_SCHEMA.eq(dc.DOMAIN_SCHEMA)).and(d.DOMAIN_NAME.eq(dc.DOMAIN_NAME)).where(d.DOMAIN_SCHEMA.in(getInputSchemata())).and(d.DATA_TYPE.ne(inline("ENUM"))).orderBy(d.DOMAIN_SCHEMA, d.DOMAIN_NAME)) {
        SchemaDefinition schema = getSchema(record.get(d.DOMAIN_SCHEMA));
        DataTypeDefinition baseType = new DefaultDataTypeDefinition(this, schema, record.get(d.DATA_TYPE), record.get(d.CHARACTER_MAXIMUM_LENGTH), record.get(d.NUMERIC_PRECISION), record.get(d.NUMERIC_SCALE), true, record.get(d.DOMAIN_DEFAULT));
        DefaultDomainDefinition domain = new DefaultDomainDefinition(schema, record.get(d.DOMAIN_NAME), baseType);
        if (!StringUtils.isBlank(record.get(dc.checkConstraints().CHECK_CLAUSE)))
            domain.addCheckClause(record.get(dc.checkConstraints().CHECK_CLAUSE));
        result.add(domain);
    }
    return result;
}
Also used : Domains(org.jooq.meta.hsqldb.information_schema.tables.Domains) DefaultDomainDefinition(org.jooq.meta.DefaultDomainDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultDomainDefinition(org.jooq.meta.DefaultDomainDefinition) DomainDefinition(org.jooq.meta.DomainDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) DomainConstraints(org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 Record (org.jooq.Record)1 DataTypeDefinition (org.jooq.meta.DataTypeDefinition)1 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)1 DefaultDomainDefinition (org.jooq.meta.DefaultDomainDefinition)1 DomainDefinition (org.jooq.meta.DomainDefinition)1 SchemaDefinition (org.jooq.meta.SchemaDefinition)1 DomainConstraints (org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints)1 Domains (org.jooq.meta.hsqldb.information_schema.tables.Domains)1