use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class DB2SchemaManager method addObjectDeleteActions.
@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command) {
String schemaName = command.getObject().getName();
DBEPersistAction action = new SQLDatabasePersistAction("Drop schema (SQL)", String.format(SQL_DROP_SCHEMA, DBUtils.getQuotedIdentifier(command.getObject())));
actions.add(action);
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class ExasolTableManager method addStructObjectCreateActions.
@Override
public void addStructObjectCreateActions(List<DBEPersistAction> actions, StructCreateCommand command) {
super.addStructObjectCreateActions(actions, command);
// Eventually add Comment
DBEPersistAction commentAction = buildCommentAction(command.getObject());
if (commentAction != null) {
actions.add(commentAction);
}
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class ExasolTableManager method addObjectModifyActions.
// ------
// Alter
// ------
@Override
public void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
ExasolTable exasolTable = command.getObject();
if (command.getProperties().size() > 1) {
StringBuilder sb = new StringBuilder(128);
sb.append(SQL_ALTER);
sb.append(exasolTable.getFullyQualifiedName(DBPEvaluationContext.DDL));
sb.append(" ");
appendTableModifiers(command.getObject(), command, sb);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sb.toString()));
}
DBEPersistAction commentAction = buildCommentAction(exasolTable);
if (commentAction != null) {
actionList.add(commentAction);
}
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class JDBCUtils method generateTableDDL.
public static String generateTableDDL(@NotNull DBRProgressMonitor monitor, @NotNull JDBCTable table, boolean addComments) throws DBException {
final DBERegistry editorsRegistry = table.getDataSource().getContainer().getPlatform().getEditorsRegistry();
final SQLObjectEditor entityEditor = editorsRegistry.getObjectManager(table.getClass(), SQLObjectEditor.class);
if (entityEditor instanceof SQLTableManager) {
DBEPersistAction[] ddlActions = ((SQLTableManager) entityEditor).getTableDDL(monitor, table);
return SQLUtils.generateScript(table.getDataSource(), ddlActions, addComments);
}
log.debug("Table editor not found for " + table.getClass().getName());
return SQLUtils.generateCommentLine(table.getDataSource(), "Can't generate DDL: table editor not found for " + table.getClass().getName());
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class SQLTableManager method addStructObjectCreateActions.
@Override
protected void addStructObjectCreateActions(List<DBEPersistAction> actions, StructCreateCommand command) {
final OBJECT_TYPE table = command.getObject();
final NestedObjectCommand tableProps = command.getObjectCommands().get(table);
if (tableProps == null) {
//$NON-NLS-1$
log.warn("Object change command not found");
return;
}
final String tableName = table.getFullyQualifiedName(DBPEvaluationContext.DDL);
final String lineSeparator = GeneralUtils.getDefaultLineSeparator();
StringBuilder createQuery = new StringBuilder(100);
//$NON-NLS-1$ //$NON-NLS-2$
createQuery.append("CREATE TABLE ").append(tableName).append(" (").append(lineSeparator);
boolean hasNestedDeclarations = false;
final Collection<NestedObjectCommand> orderedCommands = getNestedOrderedCommands(command);
for (NestedObjectCommand nestedCommand : orderedCommands) {
if (nestedCommand.getObject() == table) {
continue;
}
if (excludeFromDDL(nestedCommand, orderedCommands)) {
continue;
}
final String nestedDeclaration = nestedCommand.getNestedDeclaration(table);
if (!CommonUtils.isEmpty(nestedDeclaration)) {
// Insert nested declaration
if (hasNestedDeclarations) {
//$NON-NLS-1$
createQuery.append(",").append(lineSeparator);
}
//$NON-NLS-1$
createQuery.append("\t").append(nestedDeclaration);
hasNestedDeclarations = true;
} else {
// This command should be executed separately
final DBEPersistAction[] nestedActions = nestedCommand.getPersistActions();
if (nestedActions != null) {
Collections.addAll(actions, nestedActions);
}
}
}
//$NON-NLS-1$
createQuery.append(lineSeparator).append(")");
appendTableModifiers(table, tableProps, createQuery);
actions.add(0, new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_table, createQuery.toString()));
}
Aggregations