Search in sources :

Example 21 with DBSDataType

use of org.jkiss.dbeaver.model.struct.DBSDataType in project dbeaver by serge-rider.

the class OracleTableColumnManager method createDatabaseObject.

@Override
protected OracleTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, OracleTableBase parent, Object copyFrom) {
    //$NON-NLS-1$
    DBSDataType columnType = findBestDataType(parent.getDataSource(), "varchar2");
    final OracleTableColumn column = new OracleTableColumn(parent);
    column.setName(getNewColumnName(monitor, context, parent));
    column.setDataType((OracleDataType) columnType);
    //$NON-NLS-1$
    column.setTypeName(columnType == null ? "INTEGER" : columnType.getName());
    column.setMaxLength(columnType != null && columnType.getDataKind() == DBPDataKind.STRING ? 100 : 0);
    column.setValueType(columnType == null ? Types.INTEGER : columnType.getTypeID());
    column.setOrdinalPosition(-1);
    return column;
}
Also used : DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)

Example 22 with DBSDataType

use of org.jkiss.dbeaver.model.struct.DBSDataType in project dbeaver by serge-rider.

the class ArrayAttributeTransformer method transformAttribute.

@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, String> options) throws DBException {
    DBSDataType collectionType;
    if (attribute.getAttribute() instanceof DBSTypedObjectEx) {
        collectionType = ((DBSTypedObjectEx) attribute.getAttribute()).getDataType();
    } else {
        collectionType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), attribute.getTypeName());
    }
    if (collectionType != null) {
        DBSDataType componentType = collectionType.getComponentType(session.getProgressMonitor());
        if (componentType instanceof DBSEntity) {
            ComplexTypeAttributeTransformer.createNestedTypeBindings(session, attribute, rows, (DBSEntity) componentType);
            return;
        }
    }
    // No component type found.
    // Array items should be resolved in a lazy mode
    MapAttributeTransformer.resolveMapsFromData(session, attribute, rows);
}
Also used : DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) DBSTypedObjectEx(org.jkiss.dbeaver.model.struct.DBSTypedObjectEx) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity)

Example 23 with DBSDataType

use of org.jkiss.dbeaver.model.struct.DBSDataType in project dbeaver by serge-rider.

the class GenericTableColumnManager method createDatabaseObject.

@Override
protected GenericTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, GenericTable parent, Object copyFrom) {
    DBSDataType columnType = findBestDataType(parent.getDataSource(), DBConstants.DEFAULT_DATATYPE_NAMES);
    final GenericTableColumn column = new GenericTableColumn(parent);
    column.setName(getNewColumnName(monitor, context, parent));
    column.setTypeName(columnType == null ? "INTEGER" : columnType.getName());
    column.setMaxLength(columnType != null && columnType.getDataKind() == DBPDataKind.STRING ? 100 : 0);
    column.setValueType(columnType == null ? Types.INTEGER : columnType.getTypeID());
    column.setOrdinalPosition(-1);
    return column;
}
Also used : DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) GenericTableColumn(org.jkiss.dbeaver.ext.generic.model.GenericTableColumn)

Example 24 with DBSDataType

use of org.jkiss.dbeaver.model.struct.DBSDataType in project dbeaver by serge-rider.

the class JDBCBasicDataTypeCache method fillStandardTypes.

// SQL-92 standard types
// plus a few de-facto standard types
@SuppressWarnings("unchecked")
public void fillStandardTypes(DBSObject owner) {
    List<DBSDataType> standardTypes = new ArrayList<>();
    Collections.addAll(standardTypes, new JDBCDataType(owner, Types.INTEGER, "INTEGER", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.FLOAT, "FLOAT", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.REAL, "REAL", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.DOUBLE, "DOUBLE PRECISION", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.NUMERIC, "NUMBER", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.DECIMAL, "DECIMAL", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.SMALLINT, "SMALLINT", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.BIGINT, "BIGINT", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.BIT, "BIT", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.VARCHAR, "VARCHAR", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.VARBINARY, "VARBINARY", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.DATE, "DATE", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.TIME, "TIME", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.TIMESTAMP, "TIMESTAMP", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.BLOB, "BLOB", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.CLOB, "CLOB", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.BOOLEAN, "BOOLEAN", null, false, true, 0, 0, 0), new JDBCDataType(owner, Types.OTHER, "OBJECT", null, false, true, 0, 0, 0));
    setCache(standardTypes);
}
Also used : JDBCDataType(org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCDataType) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType)

Example 25 with DBSDataType

use of org.jkiss.dbeaver.model.struct.DBSDataType in project dbeaver by dbeaver.

the class OracleTableColumnManager method createDatabaseObject.

@Override
protected OracleTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, OracleTableBase parent, Object copyFrom) {
    // $NON-NLS-1$
    DBSDataType columnType = findBestDataType(parent.getDataSource(), "varchar2");
    final OracleTableColumn column = new OracleTableColumn(parent);
    column.setName(getNewColumnName(monitor, context, parent));
    column.setDataType((OracleDataType) columnType);
    // $NON-NLS-1$
    column.setTypeName(columnType == null ? "INTEGER" : columnType.getName());
    column.setMaxLength(columnType != null && columnType.getDataKind() == DBPDataKind.STRING ? 100 : 0);
    column.setValueType(columnType == null ? Types.INTEGER : columnType.getTypeID());
    column.setOrdinalPosition(-1);
    return column;
}
Also used : DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)

Aggregations

DBSDataType (org.jkiss.dbeaver.model.struct.DBSDataType)46 DBException (org.jkiss.dbeaver.DBException)10 DBCException (org.jkiss.dbeaver.model.exec.DBCException)8 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)8 DBSTypedObjectEx (org.jkiss.dbeaver.model.struct.DBSTypedObjectEx)8 ArrayList (java.util.ArrayList)7 SQLException (java.sql.SQLException)6 GridData (org.eclipse.swt.layout.GridData)6 Composite (org.eclipse.swt.widgets.Composite)6 DBPDataTypeProvider (org.jkiss.dbeaver.model.DBPDataTypeProvider)6 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)6 Text (org.eclipse.swt.widgets.Text)4 GenericTableColumn (org.jkiss.dbeaver.ext.generic.model.GenericTableColumn)4 OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)4 PostgreDataType (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataType)4 DBSTypedObject (org.jkiss.dbeaver.model.struct.DBSTypedObject)4 KeyAdapter (org.eclipse.swt.events.KeyAdapter)3 KeyEvent (org.eclipse.swt.events.KeyEvent)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 TableItem (org.eclipse.swt.widgets.TableItem)3