Search in sources :

Example 1 with OracleTableBase

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableBase in project dbeaver by serge-rider.

the class OracleSourceDeclarationEditor method contributeEditorCommands.

@Override
protected void contributeEditorCommands(IContributionManager toolBarManager) {
    super.contributeEditorCommands(toolBarManager);
    if (getSourceObject() instanceof OracleTableBase) {
        OracleTableBase sourceObject = (OracleTableBase) getSourceObject();
        OracleEditorUtils.addDDLControl(toolBarManager, sourceObject, this);
    }
}
Also used : OracleTableBase(org.jkiss.dbeaver.ext.oracle.model.OracleTableBase)

Example 2 with OracleTableBase

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableBase in project dbeaver by serge-rider.

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 3 with OracleTableBase

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableBase in project dbeaver by serge-rider.

the class OracleConstraintManager method addObjectCreateActions.

@Override
protected void addObjectCreateActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectCreateCommand command, Map<String, Object> options) {
    OracleTableConstraint constraint = command.getObject();
    boolean isView = constraint.getTable().isView();
    String tableType = isView ? "VIEW" : "TABLE";
    OracleTableBase table = constraint.getTable();
    actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_constraint, "ALTER " + tableType + " " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) + "\nADD " + getNestedDeclaration(monitor, table, command, options) + "\n" + (!isView && constraint.getStatus() == OracleObjectStatus.ENABLED ? "ENABLE" : "DISABLE") + (isView ? " NOVALIDATE" : "")));
}
Also used : OracleTableConstraint(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint) OracleTableBase(org.jkiss.dbeaver.ext.oracle.model.OracleTableBase) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 4 with OracleTableBase

use of org.jkiss.dbeaver.ext.oracle.model.OracleTableBase 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 5 with OracleTableBase

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

the class OracleConstraintManager method addObjectCreateActions.

@Override
protected void addObjectCreateActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectCreateCommand command, Map<String, Object> options) {
    OracleTableConstraint constraint = command.getObject();
    boolean isView = constraint.getTable().isView();
    String tableType = isView ? "VIEW" : "TABLE";
    OracleTableBase table = constraint.getTable();
    actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_constraint, "ALTER " + tableType + " " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) + "\nADD " + getNestedDeclaration(monitor, table, command, options) + "\n" + (!isView && constraint.getStatus() == OracleObjectStatus.ENABLED ? "ENABLE" : "DISABLE") + (isView ? " NOVALIDATE" : "")));
}
Also used : OracleTableConstraint(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint) OracleTableBase(org.jkiss.dbeaver.ext.oracle.model.OracleTableBase) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Aggregations

OracleTableBase (org.jkiss.dbeaver.ext.oracle.model.OracleTableBase)6 OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)2 OracleTableConstraint (org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 DBSDataType (org.jkiss.dbeaver.model.struct.DBSDataType)2