Search in sources :

Example 1 with DomainConstraints

use of org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints 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)

Example 2 with DomainConstraints

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

the class HSQLDBDatabase method getDomains0.

@Override
protected List<DomainDefinition> getDomains0() throws SQLException {
    List<DomainDefinition> result = new ArrayList<>();
    DomainConstraints dc = DOMAIN_CONSTRAINTS.as("dc");
    for (Record record : create().select(dc.domains().DOMAIN_SCHEMA, dc.domains().DOMAIN_NAME, dc.domains().DATA_TYPE, dc.domains().CHARACTER_MAXIMUM_LENGTH, dc.domains().NUMERIC_PRECISION, dc.domains().NUMERIC_SCALE, dc.domains().DOMAIN_DEFAULT, dc.checkConstraints().CHECK_CLAUSE).from(dc).where(dc.domains().DOMAIN_SCHEMA.in(getInputSchemata())).orderBy(dc.domains().DOMAIN_SCHEMA, dc.domains().DOMAIN_NAME)) {
        SchemaDefinition schema = getSchema(record.get(dc.domains().DOMAIN_SCHEMA));
        DataTypeDefinition baseType = new DefaultDataTypeDefinition(this, schema, record.get(dc.domains().DATA_TYPE), record.get(dc.domains().CHARACTER_MAXIMUM_LENGTH), record.get(dc.domains().NUMERIC_PRECISION), record.get(dc.domains().NUMERIC_SCALE), true, record.get(dc.domains().DOMAIN_DEFAULT));
        DefaultDomainDefinition domain = new DefaultDomainDefinition(schema, record.get(dc.domains().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 : 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)2 Record (org.jooq.Record)2 DataTypeDefinition (org.jooq.meta.DataTypeDefinition)2 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)2 DefaultDomainDefinition (org.jooq.meta.DefaultDomainDefinition)2 DomainDefinition (org.jooq.meta.DomainDefinition)2 SchemaDefinition (org.jooq.meta.SchemaDefinition)2 DomainConstraints (org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints)2 Domains (org.jooq.meta.hsqldb.information_schema.tables.Domains)1