use of org.jkiss.dbeaver.model.struct.DBSObjectSelector in project dbeaver by serge-rider.
the class SQLEntityResolver method resolveTables.
static void resolveTables(DBRProgressMonitor monitor, DBCExecutionContext executionContext, TemplateContext context, List<DBSEntity> entities) throws DBException {
TemplateVariable schemaVariable = ((SQLContext) context).getTemplateVariable(SQLContainerResolver.VAR_NAME_SCHEMA);
TemplateVariable catalogVariable = ((SQLContext) context).getTemplateVariable(SQLContainerResolver.VAR_NAME_CATALOG);
String catalogName = catalogVariable == null ? null : catalogVariable.getDefaultValue();
String schemaName = schemaVariable == null ? null : schemaVariable.getDefaultValue();
DBSObjectContainer objectContainer = DBUtils.getAdapter(DBSObjectContainer.class, executionContext.getDataSource());
if (objectContainer == null) {
return;
}
if (!CommonUtils.isEmpty(catalogName) || !CommonUtils.isEmpty(schemaName)) {
// Find container for specified schema/catalog
objectContainer = (DBSObjectContainer) DBUtils.getObjectByPath(monitor, objectContainer, catalogName, schemaName, null);
} else {
DBSObjectSelector objectSelector = DBUtils.getAdapter(DBSObjectSelector.class, executionContext.getDataSource());
if (objectSelector != null) {
objectContainer = DBUtils.getAdapter(DBSObjectContainer.class, objectSelector.getDefaultObject());
}
}
if (objectContainer != null) {
makeProposalsFromChildren(monitor, objectContainer, entities);
}
}
use of org.jkiss.dbeaver.model.struct.DBSObjectSelector in project dbeaver by serge-rider.
the class SQLEditor method runPostExecuteActions.
private void runPostExecuteActions(@Nullable SQLQueryResult result) {
final DBCExecutionContext executionContext = getExecutionContext();
if (executionContext != null) {
final DBPDataSource dataSource = executionContext.getDataSource();
// Dump server output
DBCServerOutputReader outputReader = DBUtils.getAdapter(DBCServerOutputReader.class, dataSource);
if (outputReader == null && result != null) {
outputReader = new DefaultServerOutputReader(result);
}
if (outputReader != null && outputReader.isServerOutputEnabled()) {
dumpServerOutput(executionContext, outputReader);
}
// Refresh active object
if (result == null || !result.hasError() && getActivePreferenceStore().getBoolean(SQLPreferenceConstants.REFRESH_DEFAULTS_AFTER_EXECUTE)) {
final DBSObjectSelector objectSelector = DBUtils.getAdapter(DBSObjectSelector.class, dataSource);
if (objectSelector != null) {
new AbstractJob("Refresh default object") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
try (DBCSession session = executionContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Refresh default object")) {
objectSelector.refreshDefaultObject(session);
} catch (Exception e) {
log.error(e);
}
return Status.OK_STATUS;
}
}.schedule();
}
}
}
}
Aggregations