Search in sources :

Example 1 with Fields

use of io.atlasmap.v2.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$fields f = RDB$FIELDS.as("f");
    int i = 0;
    for (Record record : 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("CHARACTER_LENGTH"), 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())) {
        DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", 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 : DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) Rdb$fields(org.jooq.util.firebird.rdb.tables.Rdb$fields) Record(org.jooq.Record) DefaultParameterDefinition(org.jooq.util.DefaultParameterDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) Rdb$procedureParameters(org.jooq.util.firebird.rdb.tables.Rdb$procedureParameters) DefaultParameterDefinition(org.jooq.util.DefaultParameterDefinition) ParameterDefinition(org.jooq.util.ParameterDefinition)

Example 2 with Fields

use of io.atlasmap.v2.Fields in project jOOQ by jOOQ.

the class FirebirdTableDefinition method getElements0.

@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
    List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
    Rdb$relationFields r = RDB$RELATION_FIELDS.as("r");
    Rdb$fields f = RDB$FIELDS.as("f");
    // DatabaseMetaData implementation
    for (Record record : create().select(r.RDB$FIELD_NAME.trim(), r.RDB$DESCRIPTION, r.RDB$DEFAULT_VALUE, DSL.bitOr(r.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(r.RDB$NULL_FLAG), r.RDB$DEFAULT_SOURCE, r.RDB$FIELD_POSITION, // [#3342] FIELD_LENGTH should be ignored for LOBs
    CHARACTER_LENGTH(f).as("CHARACTER_LENGTH"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), f.RDB$FIELD_SUB_TYPE).from(r).leftOuterJoin(f).on(r.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(r.RDB$RELATION_NAME.eq(getName())).orderBy(r.RDB$FIELD_POSITION).fetch()) {
        DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(r.RDB$NULL_FLAG) == 0, record.get(r.RDB$DEFAULT_SOURCE));
        ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(r.RDB$FIELD_NAME.trim()), record.get(r.RDB$FIELD_POSITION), type, false, null);
        result.add(column);
    }
    return result;
}
Also used : Rdb$relationFields(org.jooq.util.firebird.rdb.tables.Rdb$relationFields) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition) Rdb$fields(org.jooq.util.firebird.rdb.tables.Rdb$fields) ArrayList(java.util.ArrayList) Record(org.jooq.Record) ColumnDefinition(org.jooq.util.ColumnDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition)

Example 3 with Fields

use of io.atlasmap.v2.Fields in project jOOQ by jOOQ.

the class FirebirdTableValuedFunction method getElements0.

@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
    List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
    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("CHARACTER_LENGTH"), 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("CHARACTER_LENGTH", 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));
        ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(p.RDB$PARAMETER_NAME.trim()), record.get(p.RDB$PARAMETER_NUMBER), type, false, null);
        result.add(column);
    }
    return result;
}
Also used : DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition) Rdb$fields(org.jooq.util.firebird.rdb.tables.Rdb$fields) ArrayList(java.util.ArrayList) Record(org.jooq.Record) Rdb$procedureParameters(org.jooq.util.firebird.rdb.tables.Rdb$procedureParameters) ColumnDefinition(org.jooq.util.ColumnDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition)

Example 4 with Fields

use of io.atlasmap.v2.Fields in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method processDataShapeIntoFields.

private List<Field> processDataShapeIntoFields(String stepSpecification, DataShapeKinds dsKind) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
    List<Field> fields = null;
    log.debug(stepSpecification);
    if (dsKind.equals(DataShapeKinds.JAVA)) {
        try {
            JavaClass jClass = mapper.readValue(stepSpecification, JavaClass.class);
            jClass = mapper.readValue(stepSpecification, JavaClass.class);
            List<JavaField> jfields = getJavaFields(jClass);
            fields = jfields.stream().map(f -> (Field) f).collect(Collectors.toList());
        } catch (IOException e) {
            log.error("error: {}" + e);
        }
    } else if (dsKind.equals(DataShapeKinds.JSON_SCHEMA) || dsKind.equals(DataShapeKinds.JSON_INSTANCE)) {
        JsonInspectionResponse inspectionResponse = atlasmapEndpoint.inspectJson(generateJsonInspectionRequest(stepSpecification));
        try {
            String mapperString = mapper.writeValueAsString(inspectionResponse);
            log.debug(mapperString);
            fields = inspectionResponse.getJsonDocument().getFields().getField();
        } catch (JsonProcessingException e) {
            log.error("error: {}" + e);
        }
    } else if (dsKind.equals(DataShapeKinds.XML_SCHEMA) || dsKind.equals(DataShapeKinds.XML_INSTANCE)) {
        // TODO(tplevko)
        throw new UnsupportedOperationException("XML support is not implemented yet");
    }
    return fields;
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) JavaField(io.atlasmap.java.v2.JavaField) JavaClass(io.atlasmap.java.v2.JavaClass) JsonInspectionResponse(io.atlasmap.json.v2.JsonInspectionResponse) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with Fields

use of io.atlasmap.v2.Fields in project atlasmap by atlasmap.

the class AtlasXmlModelFactory method createXmlDocument.

public static XmlDocument createXmlDocument() {
    XmlDocument xmlDocument = new XmlDocument();
    xmlDocument.setFields(new Fields());
    return xmlDocument;
}
Also used : Fields(io.atlasmap.v2.Fields)

Aggregations

Field (io.atlasmap.v2.Field)10 Test (org.junit.Test)6 JsonDocument (io.atlasmap.json.v2.JsonDocument)5 JsonField (io.atlasmap.json.v2.JsonField)5 Fields (io.atlasmap.v2.Fields)4 XmlComplexType (io.atlasmap.xml.v2.XmlComplexType)3 XmlDocument (io.atlasmap.xml.v2.XmlDocument)3 XmlField (io.atlasmap.xml.v2.XmlField)3 File (java.io.File)3 Record (org.jooq.Record)3 DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)3 Rdb$fields (org.jooq.util.firebird.rdb.tables.Rdb$fields)3 JavaField (io.atlasmap.java.v2.JavaField)2 AtlasMapping (io.atlasmap.v2.AtlasMapping)2 BaseMapping (io.atlasmap.v2.BaseMapping)2 Mapping (io.atlasmap.v2.Mapping)2 XmlFields (io.atlasmap.xml.v2.XmlFields)2 XmlNamespace (io.atlasmap.xml.v2.XmlNamespace)2 ArrayList (java.util.ArrayList)2 ColumnDefinition (org.jooq.util.ColumnDefinition)2