use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by dbeaver.
the class OracleSequenceManager method addObjectDeleteActions.
@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) {
String sql = "DROP SEQUENCE " + command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL);
DBEPersistAction action = new SQLDatabasePersistAction("Drop Sequence", sql);
actions.add(action);
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by dbeaver.
the class DB2SequenceManager method addObjectDeleteActions.
@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) {
String sql = String.format(SQL_DROP, command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL));
DBEPersistAction action = new SQLDatabasePersistAction("Drop Sequence", sql);
actions.add(action);
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by dbeaver.
the class DB2TableManager method addStructObjectCreateActions.
@Override
public void addStructObjectCreateActions(List<DBEPersistAction> actions, StructCreateCommand command, Map<String, Object> options) {
super.addStructObjectCreateActions(actions, command, options);
// 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 dbeaver.
the class DB2TableManager method addObjectModifyActions.
// ------
// Alter
// ------
@Override
public void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
DB2Table db2Table = command.getObject();
if (command.getProperties().size() > 1) {
StringBuilder sb = new StringBuilder(128);
sb.append(SQL_ALTER);
sb.append(db2Table.getFullyQualifiedName(DBPEvaluationContext.DDL));
sb.append(" ");
appendTableModifiers(command.getObject(), command, sb);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sb.toString()));
}
DBEPersistAction commentAction = buildCommentAction(db2Table);
if (commentAction != null) {
actionList.add(commentAction);
}
}
use of org.jkiss.dbeaver.model.edit.DBEPersistAction in project dbeaver by serge-rider.
the class NavigatorObjectsDeleter method appendScript.
private void appendScript(final DBRProgressMonitor monitor, final StringBuilder sql, final DBNDatabaseNode node) throws InvocationTargetException {
if (!(node.getParentNode() instanceof DBNContainer)) {
return;
}
final DBSObject object = node.getObject();
if (object == null) {
return;
}
final DBEObjectMaker objectMaker = DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(object.getClass(), DBEObjectMaker.class);
if (objectMaker == null) {
return;
}
final boolean supportsCascade = (objectMaker.getMakerOptions(object.getDataSource()) & DBEObjectMaker.FEATURE_DELETE_CASCADE) != 0;
final NavigatorHandlerObjectBase.CommandTarget commandTarget;
try {
commandTarget = NavigatorHandlerObjectBase.getCommandTarget(window, node.getParentNode(), object.getClass(), false);
} catch (DBException e) {
log.warn(e);
return;
}
if (commandContext == null) {
commandContext = commandTarget.getContext();
}
if (!object.isPersisted() || commandTarget.getEditor() != null) {
return;
}
final Map<String, Object> deleteOptions;
if (supportsCascade && deleteCascade) {
deleteOptions = OPTIONS_CASCADE;
} else {
deleteOptions = Collections.emptyMap();
}
try {
objectMaker.deleteObject(commandTarget.getContext(), node.getObject(), deleteOptions);
} catch (DBException e) {
log.warn(e);
return;
}
final StringBuilder script = new StringBuilder();
final DBECommandContext commandContext = commandTarget.getContext();
Collection<? extends DBECommand> commands = commandContext.getFinalCommands();
try {
for (DBECommand command : commands) {
final DBEPersistAction[] persistActions = command.getPersistActions(monitor, commandContext.getExecutionContext(), deleteOptions);
script.append(SQLUtils.generateScript(commandContext.getExecutionContext().getDataSource(), persistActions, false));
if (script.length() == 0) {
script.append(SQLUtils.generateComments(commandContext.getExecutionContext().getDataSource(), persistActions, false));
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
commandTarget.getContext().resetChanges(true);
if (sql.length() != 0) {
sql.append("\n");
}
sql.append(script);
}
Aggregations