Search in sources :

Example 21 with RDB$FIELDS

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

the class AtlasUtilTest method testExcludeNotRequestedFieldsShouldIncludeOneLevel.

@Test
public void testExcludeNotRequestedFieldsShouldIncludeOneLevel() {
    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/"));
    assertEquals("/A{/A/A{}, /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)

Example 22 with RDB$FIELDS

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

the class AtlasUtilTest method testExcludeNotRequestedFieldsShouldIncludeRootLevel.

@Test
public void testExcludeNotRequestedFieldsShouldIncludeRootLevel() {
    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("/"));
    assertEquals("/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 23 with RDB$FIELDS

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

the class FirebirdDatabase method getIndexes0.

@Override
protected List<IndexDefinition> getIndexes0() throws SQLException {
    final List<IndexDefinition> result = new ArrayList<>();
    final Rdb$relationConstraints c = RDB$RELATION_CONSTRAINTS.as("c");
    final Rdb$indices i = RDB$INDICES.as("i");
    final Rdb$indexSegments s = RDB$INDEX_SEGMENTS.as("s");
    Map<Record, Result<Record>> indexes = create().select(s.rdb$indices().RDB$RELATION_NAME.trim().as(i.RDB$RELATION_NAME), s.rdb$indices().RDB$INDEX_NAME.trim().as(i.RDB$INDEX_NAME), s.rdb$indices().RDB$UNIQUE_FLAG, s.RDB$FIELD_NAME.trim().as(s.RDB$FIELD_NAME), s.RDB$FIELD_POSITION).from(s).where(s.rdb$indices().RDB$INDEX_NAME.notIn(select(c.RDB$CONSTRAINT_NAME).from(c))).orderBy(s.rdb$indices().RDB$RELATION_NAME, s.rdb$indices().RDB$INDEX_NAME, s.RDB$FIELD_POSITION).fetchGroups(new Field[] { i.RDB$RELATION_NAME, i.RDB$INDEX_NAME, i.RDB$UNIQUE_FLAG }, new Field[] { s.RDB$FIELD_NAME, s.RDB$FIELD_POSITION });
    indexLoop: for (Entry<Record, Result<Record>> entry : indexes.entrySet()) {
        final Record index = entry.getKey();
        final Result<Record> columns = entry.getValue();
        final SchemaDefinition schema = getSchemata().get(0);
        final String indexName = index.get(i.RDB$INDEX_NAME);
        final String tableName = index.get(i.RDB$RELATION_NAME);
        final TableDefinition table = getTable(schema, tableName);
        if (table == null)
            continue indexLoop;
        final boolean unique = index.get(i.RDB$UNIQUE_FLAG, boolean.class);
        // [#6310] [#6620] Function-based indexes are not yet supported
        for (Record column : columns) if (table.getColumn(column.get(s.RDB$FIELD_NAME)) == null)
            continue indexLoop;
        result.add(new AbstractIndexDefinition(schema, indexName, table, unique) {

            List<IndexColumnDefinition> indexColumns = new ArrayList<>();

            {
                for (Record column : columns) {
                    indexColumns.add(new DefaultIndexColumnDefinition(this, table.getColumn(column.get(s.RDB$FIELD_NAME)), SortOrder.ASC, column.get(s.RDB$FIELD_POSITION, int.class)));
                }
            }

            @Override
            protected List<IndexColumnDefinition> getIndexColumns0() {
                return indexColumns;
            }
        });
    }
    return result;
}
Also used : SchemaDefinition(org.jooq.meta.SchemaDefinition) ArrayList(java.util.ArrayList) Rdb$indexSegments(org.jooq.meta.firebird.rdb.tables.Rdb$indexSegments) Result(org.jooq.Result) DefaultIndexColumnDefinition(org.jooq.meta.DefaultIndexColumnDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) Entry(java.util.Map.Entry) AbstractIndexDefinition(org.jooq.meta.AbstractIndexDefinition) IndexDefinition(org.jooq.meta.IndexDefinition) AbstractIndexDefinition(org.jooq.meta.AbstractIndexDefinition) DefaultIndexColumnDefinition(org.jooq.meta.DefaultIndexColumnDefinition) Rdb$indices(org.jooq.meta.firebird.rdb.tables.Rdb$indices) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) Rdb$relationConstraints(org.jooq.meta.firebird.rdb.tables.Rdb$relationConstraints)

Example 24 with RDB$FIELDS

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

the class FirebirdDatabase method loadCheckConstraints.

@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
    Rdb$relationConstraints r = RDB$RELATION_CONSTRAINTS.as("r");
    Rdb$checkConstraints c = RDB$CHECK_CONSTRAINTS.as("c");
    Rdb$triggers t = RDB$TRIGGERS.as("t");
    // for RDB$TRIGGER_TYPE 1 (before insert) and 3 (before update)
    for (Record record : create().select(r.RDB$RELATION_NAME.trim().as(r.RDB$RELATION_NAME), r.RDB$CONSTRAINT_NAME.trim().as(r.RDB$CONSTRAINT_NAME), max(t.RDB$TRIGGER_SOURCE.trim()).as(t.RDB$TRIGGER_SOURCE)).from(r).join(c).on(r.RDB$CONSTRAINT_NAME.eq(c.RDB$CONSTRAINT_NAME)).join(t).on(c.RDB$TRIGGER_NAME.eq(t.RDB$TRIGGER_NAME)).where(r.RDB$CONSTRAINT_TYPE.eq(inline("CHECK"))).groupBy(r.RDB$RELATION_NAME, r.RDB$CONSTRAINT_NAME).orderBy(r.RDB$RELATION_NAME, r.RDB$CONSTRAINT_NAME)) {
        SchemaDefinition schema = getSchemata().get(0);
        TableDefinition table = getTable(schema, record.get(r.RDB$RELATION_NAME));
        if (table != null) {
            relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, record.get(r.RDB$CONSTRAINT_NAME), record.get(t.RDB$TRIGGER_SOURCE)));
        }
    }
}
Also used : SchemaDefinition(org.jooq.meta.SchemaDefinition) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) Rdb$relationConstraints(org.jooq.meta.firebird.rdb.tables.Rdb$relationConstraints) Rdb$checkConstraints(org.jooq.meta.firebird.rdb.tables.Rdb$checkConstraints) DefaultCheckConstraintDefinition(org.jooq.meta.DefaultCheckConstraintDefinition) Rdb$triggers(org.jooq.meta.firebird.rdb.tables.Rdb$triggers)

Example 25 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS 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)

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