Search in sources :

Example 6 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project jOOQ by jOOQ.

the class FirebirdDatabase method loadForeignKeys.

@Override
protected void loadForeignKeys(DefaultRelations relations) throws SQLException {
    Rdb$relationConstraints pk = RDB$RELATION_CONSTRAINTS.as("pk");
    Rdb$relationConstraints fk = RDB$RELATION_CONSTRAINTS.as("fk");
    Rdb$refConstraints rc = RDB$REF_CONSTRAINTS.as("rc");
    Rdb$indexSegments isp = RDB$INDEX_SEGMENTS.as("isp");
    Rdb$indexSegments isf = RDB$INDEX_SEGMENTS.as("isf");
    for (Record record : create().selectDistinct(fk.RDB$CONSTRAINT_NAME.trim().as("fk"), fk.RDB$RELATION_NAME.trim().as("fkTable"), isf.RDB$FIELD_NAME.trim().as("fkField"), pk.RDB$CONSTRAINT_NAME.trim().as("pk"), pk.RDB$RELATION_NAME.trim().as("pkTable")).from(fk).join(rc).on(fk.RDB$CONSTRAINT_NAME.eq(rc.RDB$CONSTRAINT_NAME)).join(pk).on(pk.RDB$CONSTRAINT_NAME.eq(rc.RDB$CONST_NAME_UQ)).join(isp).on(isp.RDB$INDEX_NAME.eq(pk.RDB$INDEX_NAME)).join(isf).on(isf.RDB$INDEX_NAME.eq(fk.RDB$INDEX_NAME)).where(isp.RDB$FIELD_POSITION.eq(isf.RDB$FIELD_POSITION)).orderBy(fk.RDB$CONSTRAINT_NAME.asc(), isf.RDB$FIELD_POSITION.asc()).fetch()) {
        String pkName = record.get("pk", String.class);
        String pkTable = record.get("pkTable", String.class);
        String fkName = record.get("fk", String.class);
        String fkTable = record.get("fkTable", String.class);
        String fkField = record.get("fkField", String.class);
        TableDefinition foreignKeyTable = getTable(getSchemata().get(0), fkTable, true);
        TableDefinition primaryKeyTable = getTable(getSchemata().get(0), pkTable, true);
        if (primaryKeyTable != null && foreignKeyTable != null)
            relations.addForeignKey(fkName, foreignKeyTable, foreignKeyTable.getColumn(fkField), pkName, primaryKeyTable);
    }
}
Also used : TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) Rdb$relationConstraints(org.jooq.meta.firebird.rdb.tables.Rdb$relationConstraints) Rdb$indexSegments(org.jooq.meta.firebird.rdb.tables.Rdb$indexSegments) Rdb$refConstraints(org.jooq.meta.firebird.rdb.tables.Rdb$refConstraints)

Example 7 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project jOOQ by jOOQ.

the class FirebirdRoutineDefinition method init0.

@Override
protected void init0() throws SQLException {
    Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
    Rdb$functionArguments a = RDB$FUNCTION_ARGUMENTS.as("a");
    Rdb$fields f = RDB$FIELDS.as("f");
    int i = 0;
    for (Record record : returnValue == null ? create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_TYPE, p.RDB$PARAMETER_NAME.trim().as(p.RDB$PARAMETER_NAME), FIELD_TYPE(f).as("FIELD_TYPE"), CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).orderBy(p.RDB$PARAMETER_TYPE.desc(), p.RDB$PARAMETER_NUMBER.asc()) : create().select(a.RDB$ARGUMENT_POSITION.as(p.RDB$PARAMETER_NUMBER), inline(0).as(p.RDB$PARAMETER_TYPE), a.RDB$ARGUMENT_NAME.trim().as(p.RDB$PARAMETER_NAME), FIELD_TYPE(f).as("FIELD_TYPE"), CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), DSL.bitOr(a.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), a.RDB$DEFAULT_SOURCE).from(a).leftOuterJoin(f).on(a.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(a.RDB$FUNCTION_NAME.eq(getName())).and(a.RDB$ARGUMENT_POSITION.gt(inline((short) 0))).orderBy(a.RDB$ARGUMENT_POSITION)) {
        DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), 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(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
        ParameterDefinition parameter = new DefaultParameterDefinition(this, record.get(p.RDB$PARAMETER_NAME), i++, type);
        addParameter(record.get(p.RDB$PARAMETER_TYPE, int.class).equals(0) ? InOutDefinition.IN : InOutDefinition.OUT, parameter);
    }
}
Also used : Rdb$functionArguments(org.jooq.meta.firebird.rdb.tables.Rdb$functionArguments) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) Rdb$fields(org.jooq.meta.firebird.rdb.tables.Rdb$fields) Record(org.jooq.Record) DefaultParameterDefinition(org.jooq.meta.DefaultParameterDefinition) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) Rdb$procedureParameters(org.jooq.meta.firebird.rdb.tables.Rdb$procedureParameters) ParameterDefinition(org.jooq.meta.ParameterDefinition) DefaultParameterDefinition(org.jooq.meta.DefaultParameterDefinition)

Example 8 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project jOOQ by jOOQ.

the class FirebirdTableValuedFunction method getElements0.

@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
    List<ColumnDefinition> result = new ArrayList<>();
    Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
    Rdb$fields f = RDB$FIELDS.as("f");
    // DatabaseMetaData implementation
    for (Record record : create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_NAME.trim(), p.RDB$DESCRIPTION, p.RDB$DEFAULT_VALUE, DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE, // [#3342] FIELD_LENGTH should be ignored for LOBs
    CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), f.RDB$FIELD_SUB_TYPE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).and(p.RDB$PARAMETER_TYPE.eq((short) 1)).orderBy(p.RDB$PARAMETER_NUMBER)) {
        DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), 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(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
        result.add(new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(p.RDB$PARAMETER_NAME.trim()), result.size() + 1, type, false, null));
    }
    return result;
}
Also used : DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.meta.DefaultColumnDefinition) Rdb$fields(org.jooq.meta.firebird.rdb.tables.Rdb$fields) ArrayList(java.util.ArrayList) Record(org.jooq.Record) Rdb$procedureParameters(org.jooq.meta.firebird.rdb.tables.Rdb$procedureParameters) DefaultColumnDefinition(org.jooq.meta.DefaultColumnDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition)

Example 9 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project atlasmap by atlasmap.

the class AtlasUtilTest method testExcludeNotRequestedFieldsShouldIncludeAllIfIncludePathsNull.

@Test
public void testExcludeNotRequestedFieldsShouldIncludeAllIfIncludePathsNull() {
    Document document = new Document();
    Fields fields = new Fields();
    fields.getField().add(newField("/A", newField("/A/A", newField("/A/A/A"), newField("/A/A/B")), newField("/A/B", newField("/A/B/A", newField("/A/B/A/A")))));
    document.setFields(fields);
    AtlasUtil.excludeNotRequestedFields(document, null);
    assertEquals("/A{/A/A{/A/A/A{}, /A/A/B{}, }, /A/B{/A/B/A{/A/B/A/A{}, }, }, }, ", fields.getField().get(0).toString());
}
Also used : Fields(io.atlasmap.v2.Fields) Document(io.atlasmap.v2.Document) Test(org.junit.jupiter.api.Test)

Example 10 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project atlasmap by atlasmap.

the class AtlasUtilTest method testExcludeNotRequestedFieldsShouldIncludeAllIntermediateLevels.

@Test
public void testExcludeNotRequestedFieldsShouldIncludeAllIntermediateLevels() {
    Document document = new Document();
    Fields fields = new Fields();
    fields.getField().add(newField("/A", newField("/A/A", newField("/A/A/A"), newField("/A/A/B")), newField("/A/B", newField("/A/B/A", newField("/A/B/A/A")))));
    document.setFields(fields);
    AtlasUtil.excludeNotRequestedFields(document, Arrays.asList("/A/A/B"));
    assertEquals("/A{/A/A{/A/A/A{}, /A/A/B{}, }, /A/B{}, }, ", fields.getField().get(0).toString());
}
Also used : Fields(io.atlasmap.v2.Fields) Document(io.atlasmap.v2.Document) Test(org.junit.jupiter.api.Test)

Aggregations

Fields (io.atlasmap.v2.Fields)15 Record (org.jooq.Record)11 Document (io.atlasmap.v2.Document)8 ArrayList (java.util.ArrayList)8 Test (org.junit.jupiter.api.Test)7 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)5 Rdb$fields (org.jooq.meta.firebird.rdb.tables.Rdb$fields)5 XmlFields (io.atlasmap.xml.v2.XmlFields)4 TableDefinition (org.jooq.meta.TableDefinition)4 Rdb$relationConstraints (org.jooq.meta.firebird.rdb.tables.Rdb$relationConstraints)4 DataTypeDefinition (org.jooq.meta.DataTypeDefinition)3 SchemaDefinition (org.jooq.meta.SchemaDefinition)3 DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)3 Rdb$fields (org.jooq.util.firebird.rdb.tables.Rdb$fields)3 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Result (org.jooq.Result)2 Rdb$functionArguments (org.jooq.meta.firebird.rdb.tables.Rdb$functionArguments)2