Search in sources :

Example 1 with OracleTableConstraint

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

the class OracleForeignKeyConfigurator method configureObject.

@Override
public OracleTableForeignKey configureObject(DBRProgressMonitor monitor, Object table, OracleTableForeignKey foreignKey) {
    return UITask.run(() -> {
        EditForeignKeyPage editPage = new EditForeignKeyPage(OracleUIMessages.edit_oracle_foreign_key_manager_dialog_title, foreignKey, new DBSForeignKeyModifyRule[] { DBSForeignKeyModifyRule.NO_ACTION, DBSForeignKeyModifyRule.CASCADE, DBSForeignKeyModifyRule.RESTRICT, DBSForeignKeyModifyRule.SET_NULL, DBSForeignKeyModifyRule.SET_DEFAULT });
        editPage.setSupportsCustomName(true);
        if (!editPage.edit()) {
            return null;
        }
        foreignKey.setReferencedConstraint((OracleTableConstraint) editPage.getUniqueConstraint());
        foreignKey.setName(editPage.getName());
        foreignKey.setDeleteRule(editPage.getOnDeleteRule());
        int colIndex = 1;
        for (EditForeignKeyPage.FKColumnInfo tableColumn : editPage.getColumns()) {
            foreignKey.addColumn(new OracleTableForeignKeyColumn(foreignKey, (OracleTableColumn) tableColumn.getOwnColumn(), colIndex++));
        }
        return foreignKey;
    });
}
Also used : OracleTableForeignKeyColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableForeignKeyColumn) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) EditForeignKeyPage(org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage) OracleTableConstraint(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)

Example 2 with OracleTableConstraint

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

the class OracleForeignKeyConfigurator method configureObject.

@Override
public OracleTableForeignKey configureObject(DBRProgressMonitor monitor, Object table, OracleTableForeignKey foreignKey) {
    return UITask.run(() -> {
        EditForeignKeyPage editPage = new EditForeignKeyPage(OracleUIMessages.edit_oracle_foreign_key_manager_dialog_title, foreignKey, new DBSForeignKeyModifyRule[] { DBSForeignKeyModifyRule.NO_ACTION, DBSForeignKeyModifyRule.CASCADE, DBSForeignKeyModifyRule.RESTRICT, DBSForeignKeyModifyRule.SET_NULL, DBSForeignKeyModifyRule.SET_DEFAULT });
        editPage.setSupportsCustomName(true);
        if (!editPage.edit()) {
            return null;
        }
        foreignKey.setReferencedConstraint((OracleTableConstraint) editPage.getUniqueConstraint());
        foreignKey.setName(editPage.getName());
        foreignKey.setDeleteRule(editPage.getOnDeleteRule());
        int colIndex = 1;
        for (EditForeignKeyPage.FKColumnInfo tableColumn : editPage.getColumns()) {
            foreignKey.addColumn(new OracleTableForeignKeyColumn(foreignKey, (OracleTableColumn) tableColumn.getOwnColumn(), colIndex++));
        }
        return foreignKey;
    });
}
Also used : OracleTableForeignKeyColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableForeignKeyColumn) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) EditForeignKeyPage(org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage) OracleTableConstraint(org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)

Example 3 with OracleTableConstraint

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

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)

Example 4 with OracleTableConstraint

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

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

OracleTableConstraint (org.jkiss.dbeaver.ext.oracle.model.OracleTableConstraint)6 OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)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 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 EditConstraintPage (org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage)2 EditForeignKeyPage (org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage)2