Search in sources :

Example 6 with PostgreProcedure

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by dbeaver.

the class PostgreResolver method resolveContext.

@Override
public Map<String, Object> resolveContext(DBSObject databaseObject) {
    HashMap<String, Object> context = new HashMap<String, Object>();
    if (databaseObject instanceof PostgreProcedure) {
        PostgreProcedure procedure = (PostgreProcedure) databaseObject;
        context.put(DBGController.PROCEDURE_OID, procedure.getObjectId());
        context.put(DBGController.PROCEDURE_NAME, procedure.getName());
        PostgreSchema schema = procedure.getContainer();
        if (schema != null) {
            context.put(DBGController.SCHEMA_NAME, schema.getName());
        }
        PostgreDatabase database = procedure.getDatabase();
        if (database != null) {
            context.put(DBGController.DATABASE_NAME, database.getName());
        }
    }
    return context;
}
Also used : HashMap(java.util.HashMap) PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Example 7 with PostgreProcedure

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.

the class PostgreProcedureManager method addObjectRenameActions.

@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
    PostgreProcedure procedure = command.getObject();
    actions.add(new SQLDatabasePersistAction("Rename function", "ALTER " + command.getObject().getProcedureTypeName() + " " + DBUtils.getQuotedIdentifier(procedure.getSchema()) + "." + PostgreProcedure.makeOverloadedName(procedure.getSchema(), command.getOldName(), procedure.getParameters(monitor), true, false) + " RENAME TO " + DBUtils.getQuotedIdentifier(procedure.getDataSource(), command.getNewName())));
}
Also used : PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 8 with PostgreProcedure

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.

the class PostgreDebugSession method attach.

/**
 * This method attach debug session to debug object (procedure) and wait
 * forever while target or any (depend on targetPID) session will run target
 * procedure
 */
public void attach(DBRProgressMonitor monitor, Map<String, Object> configuration) throws DBException {
    if (!checkDebugPlagin(monitor)) {
        throw new DBGException("PostgreSQL debug plugin is not installed on the server.\n" + "Refer to this WIKI article for installation instructions:\n" + "https://github.com/dbeaver/dbeaver/wiki/PGDebugger#installation");
    }
    log.debug("Attaching...");
    functionOid = CommonUtils.toInt(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
    log.debug(String.format("Function OID %d", functionOid));
    boolean global = isGlobalSession(configuration);
    if (global) {
        int processId = CommonUtils.toInt(configuration.get(PostgreDebugConstants.ATTR_ATTACH_PROCESS));
        attachKind = PostgreDebugAttachKind.GLOBAL;
        attachGlobal(monitor, functionOid, processId);
        log.debug("Global attached");
    } else {
        attachKind = PostgreDebugAttachKind.LOCAL;
        PostgreProcedure function = PostgreSqlDebugCore.resolveFunction(monitor, controllerConnection.getDataSource().getContainer(), configuration);
        List<String> parameterValues = (List<String>) configuration.get(PostgreDebugConstants.ATTR_FUNCTION_PARAMETERS);
        attachLocal(monitor, function, parameterValues);
        log.debug("Local attached");
    }
}
Also used : PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with PostgreProcedure

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.

the class PostgreSqlDebugCore method resolveFunction.

public static PostgreProcedure resolveFunction(DBRProgressMonitor monitor, DBPDataSourceContainer dsContainer, Map<String, Object> configuration) throws DBException {
    if (!dsContainer.isConnected()) {
        dsContainer.connect(monitor, true, true);
    }
    long functionId = CommonUtils.toLong(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
    String databaseName = (String) configuration.get(PostgreDebugConstants.ATTR_DATABASE_NAME);
    String schemaName = (String) configuration.get(PostgreDebugConstants.ATTR_SCHEMA_NAME);
    PostgreDataSource ds = (PostgreDataSource) dsContainer.getDataSource();
    PostgreDatabase database = ds.getDatabase(databaseName);
    if (database != null) {
        PostgreSchema schema = database.getSchema(monitor, schemaName);
        if (schema != null) {
            PostgreProcedure function = schema.getProcedure(monitor, functionId);
            if (function != null) {
                return function;
            }
            throw new DBException("Function " + functionId + " not found in schema " + schemaName);
        } else {
            throw new DBException("Schema '" + schemaName + "' not found in database " + databaseName);
        }
    } else {
        throw new DBException("Database '" + databaseName + "' not found");
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Example 10 with PostgreProcedure

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by dbeaver.

the class PostgreSqlDebugCore method resolveFunction.

public static PostgreProcedure resolveFunction(DBRProgressMonitor monitor, DBPDataSourceContainer dsContainer, Map<String, Object> configuration) throws DBException {
    if (!dsContainer.isConnected()) {
        dsContainer.connect(monitor, true, true);
    }
    long functionId = CommonUtils.toLong(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
    String databaseName = (String) configuration.get(PostgreDebugConstants.ATTR_DATABASE_NAME);
    String schemaName = (String) configuration.get(PostgreDebugConstants.ATTR_SCHEMA_NAME);
    PostgreDataSource ds = (PostgreDataSource) dsContainer.getDataSource();
    PostgreDatabase database = ds.getDatabase(databaseName);
    if (database != null) {
        PostgreSchema schema = database.getSchema(monitor, schemaName);
        if (schema != null) {
            PostgreProcedure function = schema.getProcedure(monitor, functionId);
            if (function != null) {
                return function;
            }
            throw new DBException("Function " + functionId + " not found in schema " + schemaName);
        } else {
            throw new DBException("Schema '" + schemaName + "' not found in database " + databaseName);
        }
    } else {
        throw new DBException("Database '" + databaseName + "' not found");
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Aggregations

PostgreProcedure (org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure)11 PostgreDatabase (org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase)5 PostgreSchema (org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)5 DBException (org.jkiss.dbeaver.DBException)3 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)3 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)3 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 GridData (org.eclipse.swt.layout.GridData)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)2 DBSInstance (org.jkiss.dbeaver.model.struct.DBSInstance)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)2 HashMap (java.util.HashMap)1 IContainer (org.eclipse.core.resources.IContainer)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1