Search in sources :

Example 16 with OracleTableColumn

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by dbeaver.

the class OracleTableColumnManager method createDatabaseObject.

@Override
protected OracleTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, Object container, Object copyFrom, Map<String, Object> options) {
    OracleTableBase table = (OracleTableBase) container;
    // $NON-NLS-1$
    DBSDataType columnType = findBestDataType(table.getDataSource(), "varchar2");
    final OracleTableColumn column = new OracleTableColumn(table);
    column.setName(getNewColumnName(monitor, context, table));
    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) OracleTableBase(org.jkiss.dbeaver.ext.oracle.model.OracleTableBase)

Example 17 with OracleTableColumn

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by dbeaver.

the class OracleTableColumnManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
    final OracleTableColumn column = command.getObject();
    boolean hasComment = command.getProperty("comment") != null;
    if (!hasComment || command.getProperties().size() > 1) {
        actionList.add(new SQLDatabasePersistAction("Modify column", // $NON-NLS-1$
        "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " MODIFY " + // $NON-NLS-1$
        getNestedDeclaration(monitor, column.getTable(), command, options)));
    }
    if (hasComment) {
        addColumnCommentAction(actionList, column);
    }
}
Also used : OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 18 with OracleTableColumn

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by dbeaver.

the class OracleConstraintConfigurator method configureObject.

@Override
public OracleTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, OracleTableConstraint constraint) {
    return UITask.run(() -> {
        EditConstraintPage editPage = new EditConstraintPage(OracleUIMessages.edit_oracle_constraint_manager_dialog_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
        if (!editPage.edit()) {
            return null;
        }
        constraint.setName(editPage.getConstraintName());
        constraint.setConstraintType(editPage.getConstraintType());
        constraint.setSearchCondition(editPage.getConstraintExpression());
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            constraint.addColumn(new OracleTableConstraintColumn(constraint, (OracleTableColumn) tableColumn, colIndex++));
        }
        return constraint;
    });
}
Also used : DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) OracleTableConstraintColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraintColumn) EditConstraintPage(org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage) OracleTableConstraint(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)

Aggregations

OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)18 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)8 OracleTableConstraint (org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)4 DBSDataType (org.jkiss.dbeaver.model.struct.DBSDataType)4 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)4 OracleTableBase (org.jkiss.dbeaver.ext.oracle.model.OracleTableBase)2 OracleTableConstraintColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraintColumn)2 OracleTableForeignKeyColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableForeignKeyColumn)2 OracleTableIndexColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableIndexColumn)2 EditConstraintPage (org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage)2 EditForeignKeyPage (org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage)2 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)2 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)1