Search in sources :

Example 21 with DataTypeDefinition

use of org.jooq.meta.DataTypeDefinition in project jOOQ by jOOQ.

the class XMLDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Sequence sequence : info().getSequences()) {
        if (getInputSchemata().contains(sequence.getSequenceSchema())) {
            SchemaDefinition schema = getSchema(sequence.getSequenceSchema());
            DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, sequence.getDataType(), sequence.getCharacterMaximumLength(), sequence.getNumericPrecision(), sequence.getNumericScale(), false, (String) null);
            result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type, sequence.getComment(), sequence.getStartValue(), sequence.getIncrement(), sequence.getMinimumValue(), sequence.getMaximumValue(), Boolean.TRUE.equals(sequence.isCycleOption()), sequence.getCache()));
        }
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Sequence(org.jooq.util.xml.jaxb.Sequence) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 22 with DataTypeDefinition

use of org.jooq.meta.DataTypeDefinition in project jOOQ by jOOQ.

the class XMLRoutineDefinition method init0.

@Override
protected void init0() {
    for (Parameter parameter : info.getParameters()) {
        Name parameterRoutineName = name(parameter.getSpecificCatalog(), parameter.getSpecificSchema(), parameter.getSpecificPackage(), parameter.getSpecificName());
        if (specificName.equals(parameterRoutineName)) {
            DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), parameter.getDataType(), parameter.getCharacterMaximumLength(), parameter.getNumericPrecision(), parameter.getNumericScale(), null, parameter.getParameterDefault());
            ParameterDefinition p = new DefaultParameterDefinition(this, parameter.getParameterName(), parameter.getOrdinalPosition(), type, !StringUtils.isBlank(parameter.getParameterDefault()), StringUtils.isBlank(parameter.getParameterName()), parameter.getComment());
            switch(parameter.getParameterMode()) {
                case IN:
                    addParameter(InOutDefinition.IN, p);
                    break;
                case INOUT:
                    addParameter(InOutDefinition.INOUT, p);
                    break;
                case OUT:
                    addParameter(InOutDefinition.OUT, p);
                    break;
            }
        }
    }
}
Also used : DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Parameter(org.jooq.util.xml.jaxb.Parameter) DefaultParameterDefinition(org.jooq.meta.DefaultParameterDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) Name(org.jooq.Name) ParameterDefinition(org.jooq.meta.ParameterDefinition) DefaultParameterDefinition(org.jooq.meta.DefaultParameterDefinition)

Example 23 with DataTypeDefinition

use of org.jooq.meta.DataTypeDefinition in project jOOQ by jOOQ.

the class FirebirdDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : sequences(getInputSchemata())) {
        SchemaDefinition schema = getSchemata().get(0);
        DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, FirebirdDataType.BIGINT.getTypeName());
        result.add(new DefaultSequenceDefinition(schema, record.get(RDB$GENERATORS.RDB$GENERATOR_NAME), type, null, record.get(RDB$GENERATORS.RDB$INITIAL_VALUE), record.get(RDB$GENERATORS.RDB$GENERATOR_INCREMENT), null, null, false, null));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 24 with DataTypeDefinition

use of org.jooq.meta.DataTypeDefinition in project jOOQ by jOOQ.

the class FirebirdDatabase method getDomains0.

@Override
protected List<DomainDefinition> getDomains0() throws SQLException {
    List<DomainDefinition> result = new ArrayList<>();
    Rdb$fields f = RDB$FIELDS;
    for (Record record : create().select(trim(f.RDB$FIELD_NAME).as(f.RDB$FIELD_NAME), CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), DSL.bitOr(f.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(f.RDB$NULL_FLAG), trim(f.RDB$VALIDATION_SOURCE).as(f.RDB$VALIDATION_SOURCE), trim(f.RDB$DEFAULT_SOURCE).as(f.RDB$DEFAULT_SOURCE)).from(f).where(f.RDB$FIELD_NAME.notLike(any("RDB$%", "SEC$%", "MON$%"))).orderBy(f.RDB$FIELD_NAME)) {
        SchemaDefinition schema = getSchemata().get(0);
        DataTypeDefinition baseType = new DefaultDataTypeDefinition(this, schema, record.get("FIELD_TYPE", String.class), record.get("CHAR_LEN", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(f.RDB$NULL_FLAG) == 0, record.get(f.RDB$DEFAULT_SOURCE) == null ? null : record.get(f.RDB$DEFAULT_SOURCE).replaceAll("(?i:default )", ""));
        DefaultDomainDefinition domain = new DefaultDomainDefinition(schema, record.get(f.RDB$FIELD_NAME), baseType);
        if (!StringUtils.isBlank(record.get(f.RDB$VALIDATION_SOURCE)))
            domain.addCheckClause(record.get(f.RDB$VALIDATION_SOURCE).replaceAll("(?i:check )", ""));
        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) Rdb$fields(org.jooq.meta.firebird.rdb.tables.Rdb$fields) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition)

Example 25 with DataTypeDefinition

use of org.jooq.meta.DataTypeDefinition in project jOOQ by jOOQ.

the class CUBRIDDatabase method getSequences0.

@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
    List<SequenceDefinition> result = new ArrayList<>();
    for (Record record : create().select(DB_SERIAL.NAME, DB_SERIAL.MAX_VAL).from(DB_SERIAL).fetch()) {
        BigInteger value = defaultIfNull(record.get(DB_SERIAL.MAX_VAL, BigInteger.class), BigInteger.valueOf(Long.MAX_VALUE));
        DataTypeDefinition type = getDataTypeForMAX_VAL(getSchemata().get(0), value);
        result.add(new DefaultSequenceDefinition(getSchemata().get(0), record.get(DB_SERIAL.NAME), type));
    }
    return result;
}
Also used : DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) Record(org.jooq.Record) DataTypeDefinition(org.jooq.meta.DataTypeDefinition)

Aggregations

DataTypeDefinition (org.jooq.meta.DataTypeDefinition)33 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)31 Record (org.jooq.Record)26 ArrayList (java.util.ArrayList)23 SchemaDefinition (org.jooq.meta.SchemaDefinition)18 ColumnDefinition (org.jooq.meta.ColumnDefinition)12 DefaultColumnDefinition (org.jooq.meta.DefaultColumnDefinition)11 DefaultParameterDefinition (org.jooq.meta.DefaultParameterDefinition)8 ParameterDefinition (org.jooq.meta.ParameterDefinition)7 SequenceDefinition (org.jooq.meta.SequenceDefinition)7 DefaultSequenceDefinition (org.jooq.meta.DefaultSequenceDefinition)6 DefaultDomainDefinition (org.jooq.meta.DefaultDomainDefinition)5 DomainDefinition (org.jooq.meta.DomainDefinition)5 Name (org.jooq.Name)3 PgNamespace (org.jooq.meta.postgres.pg_catalog.tables.PgNamespace)3 PgType (org.jooq.meta.postgres.pg_catalog.tables.PgType)3 BigInteger (java.math.BigInteger)2 Rdb$fields (org.jooq.meta.firebird.rdb.tables.Rdb$fields)2 DomainConstraints (org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints)2 Columns (org.jooq.meta.postgres.information_schema.tables.Columns)2