use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by serge-rider.
the class OracleTableColumnManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final OracleTableColumn column = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn 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;
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by serge-rider.
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);
}
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn 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;
});
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn in project dbeaver by serge-rider.
the class OracleIndexConfigurator method configureObject.
@Override
public OracleTableIndex configureObject(DBRProgressMonitor monitor, Object container, OracleTableIndex index) {
return UITask.run(() -> {
EditIndexPage editPage = new EditIndexPage(OracleUIMessages.edit_oracle_index_manager_dialog_title, index, Collections.singletonList(DBSIndexType.OTHER));
if (!editPage.edit()) {
return null;
}
StringBuilder idxName = new StringBuilder(64);
// $NON-NLS-1$
idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName())).append("_").append(CommonUtils.escapeIdentifier(editPage.getSelectedAttributes().iterator().next().getName())).append(// $NON-NLS-1$
"_IDX");
index.setName(DBObjectNameCaseTransformer.transformName(index.getDataSource(), idxName.toString()));
index.setUnique(editPage.isUnique());
index.setIndexType(editPage.getIndexType());
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
index.addColumn(new OracleTableIndexColumn(index, (OracleTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC)), null));
}
return index;
});
}
Aggregations