Search in sources :

Example 1 with GenericView

use of org.jkiss.dbeaver.ext.generic.model.GenericView in project dbeaver by serge-rider.

the class GenericViewManager method createOrReplaceViewQuery.

private void createOrReplaceViewQuery(List<DBEPersistAction> actions, DBECommandComposite<GenericTableBase, PropertyHandler> command) {
    final GenericView view = (GenericView) command.getObject();
    actions.add(new SQLDatabasePersistAction("Create view", view.getDDL()));
}
Also used : GenericView(org.jkiss.dbeaver.ext.generic.model.GenericView) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 2 with GenericView

use of org.jkiss.dbeaver.ext.generic.model.GenericView in project dbeaver by serge-rider.

the class GenericViewManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
    final GenericView view = (GenericView) command.getObject();
    boolean hasComment = command.hasProperty(DBConstants.PROP_ID_DESCRIPTION);
    if (!hasComment || command.getProperties().size() > 1) {
        actionList.add(new SQLDatabasePersistAction("Create view", view.getDDL()));
    }
    if (hasComment) {
        actionList.add(new SQLDatabasePersistAction("Comment view", "COMMENT ON VIEW " + command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL) + " IS " + SQLUtils.quoteString(command.getObject(), CommonUtils.notEmpty(command.getObject().getDescription()))));
    }
}
Also used : GenericView(org.jkiss.dbeaver.ext.generic.model.GenericView) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 3 with GenericView

use of org.jkiss.dbeaver.ext.generic.model.GenericView in project dbeaver by serge-rider.

the class GenericViewManager method createDatabaseObject.

@Override
protected GenericTableBase createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, Object container, Object copyFrom, Map<String, Object> options) {
    GenericStructContainer structContainer = (GenericStructContainer) container;
    String tableName = getNewChildName(monitor, structContainer, SQLTableManager.BASE_VIEW_NAME);
    GenericTableBase viewImpl = structContainer.getDataSource().getMetaModel().createTableImpl(structContainer, tableName, GenericConstants.TABLE_TYPE_VIEW, null);
    if (viewImpl instanceof GenericView) {
        ((GenericView) viewImpl).setObjectDefinitionText("CREATE VIEW " + viewImpl.getFullyQualifiedName(DBPEvaluationContext.DDL) + " AS SELECT 1 as A\n");
    }
    return viewImpl;
}
Also used : GenericStructContainer(org.jkiss.dbeaver.ext.generic.model.GenericStructContainer) GenericView(org.jkiss.dbeaver.ext.generic.model.GenericView) GenericTableBase(org.jkiss.dbeaver.ext.generic.model.GenericTableBase)

Aggregations

GenericView (org.jkiss.dbeaver.ext.generic.model.GenericView)3 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 GenericStructContainer (org.jkiss.dbeaver.ext.generic.model.GenericStructContainer)1 GenericTableBase (org.jkiss.dbeaver.ext.generic.model.GenericTableBase)1