Search in sources :

Example 11 with DBERegistry

use of org.jkiss.dbeaver.model.edit.DBERegistry in project dbeaver by dbeaver.

the class DBStructUtils method generateObjectDDL.

public static String generateObjectDDL(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object, Map<String, Object> options, boolean addComments) throws DBException {
    final DBERegistry editorsRegistry = object.getDataSource().getContainer().getPlatform().getEditorsRegistry();
    final SQLObjectEditor entityEditor = editorsRegistry.getObjectManager(object.getClass(), SQLObjectEditor.class);
    if (entityEditor != null) {
        SQLObjectEditor.ObjectCreateCommand createCommand = entityEditor.makeCreateCommand(object, options);
        DBEPersistAction[] ddlActions = createCommand.getPersistActions(monitor, DBUtils.getDefaultContext(object, true), options);
        return SQLUtils.generateScript(object.getDataSource(), ddlActions, addComments);
    }
    log.debug("Object editor not found for " + object.getClass().getName());
    return SQLUtils.generateCommentLine(object.getDataSource(), "Can't generate DDL: object editor not found for " + object.getClass().getName());
}
Also used : DBERegistry(org.jkiss.dbeaver.model.edit.DBERegistry) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) SQLObjectEditor(org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)

Aggregations

DBERegistry (org.jkiss.dbeaver.model.edit.DBERegistry)11 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)8 SQLObjectEditor (org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor)6 SQLTableManager (org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager)4 DBException (org.jkiss.dbeaver.DBException)3 DBSTableForeignKey (org.jkiss.dbeaver.model.struct.rdb.DBSTableForeignKey)3 DBSTableIndex (org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex)3 PostgreViewManager (org.jkiss.dbeaver.ext.postgresql.edit.PostgreViewManager)2 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)2 SQLDatabasePersistActionComment (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment)2 DBSTable (org.jkiss.dbeaver.model.struct.rdb.DBSTable)2 DBSTableConstraint (org.jkiss.dbeaver.model.struct.rdb.DBSTableConstraint)1