Search in sources :

Example 1 with SQLTableManager

use of org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager in project dbeaver by serge-rider.

the class DBStructUtils method generateTableDDL.

public static String generateTableDDL(@NotNull DBRProgressMonitor monitor, @NotNull DBSEntity table, Map<String, Object> options, 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, options);
        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());
}
Also used : SQLTableManager(org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager) DBERegistry(org.jkiss.dbeaver.model.edit.DBERegistry) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) SQLObjectEditor(org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)

Example 2 with SQLTableManager

use of org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager 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());
}
Also used : SQLTableManager(org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager) DBERegistry(org.jkiss.dbeaver.model.edit.DBERegistry) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) SQLObjectEditor(org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)

Example 3 with SQLTableManager

use of org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager in project dbeaver by dbeaver.

the class JDBCUtils method generateTableDDL.

public static String generateTableDDL(@NotNull DBRProgressMonitor monitor, @NotNull JDBCTable table, Map<String, Object> options, 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, options);
        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());
}
Also used : SQLTableManager(org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager) DBERegistry(org.jkiss.dbeaver.model.edit.DBERegistry) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) SQLObjectEditor(org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)

Aggregations

DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)3 DBERegistry (org.jkiss.dbeaver.model.edit.DBERegistry)3 SQLObjectEditor (org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)3 SQLTableManager (org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager)3