use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class JDBCCallableStatementImpl method findProcedure.
private static DBSProcedure findProcedure(DBCSession session, String queryString) throws DBException {
DBPDataSource dataSource = session.getDataSource();
if (!CommonUtils.isEmpty(queryString)) {
Matcher matcher = EXEC_PATTERN.matcher(queryString);
if (matcher.find()) {
String procName = matcher.group(1);
char divChar = dataSource.getSQLDialect().getStructSeparator();
if (procName.indexOf(divChar) != -1) {
return findProcedureByNames(session, procName.split("\\" + divChar));
} else {
return findProcedureByNames(session, procName);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class AbstractObjectReference method getFullyQualifiedName.
@NotNull
@Override
public String getFullyQualifiedName(DBPEvaluationContext context) {
if (extraInfo != null) {
return extraInfo;
}
String fqName;
DBPDataSource dataSource = container.getDataSource();
if (container == dataSource) {
// In case if there are no schemas/catalogs supported
// and data source is a root container
fqName = DBUtils.getQuotedIdentifier(dataSource, name);
} else {
fqName = DBUtils.getFullQualifiedName(dataSource, container, this);
}
return fqName;
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class CoreApplicationActivator method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
// Set notifications handler
DBeaverNotifications.setHandler(new DBeaverNotifications.NotificationHandler() {
@Override
public void sendNotification(DBPDataSource dataSource, String id, String text, DBPMessageType messageType, Runnable feedback) {
NotificationUtils.sendNotification(dataSource, id, text, messageType, feedback);
}
@Override
public void sendNotification(String id, String title, String text, DBPMessageType messageType, Runnable feedback) {
NotificationUtils.sendNotification(id, title, text, messageType, feedback);
}
});
// Add bundle load logger
if (!Log.isQuietMode()) {
context.registerService(EventHook.class, (event, contexts) -> {
String message = null;
Bundle bundle = event.getBundle();
if (event.getType() == BundleEvent.STARTED) {
if (bundle.getState() == Bundle.ACTIVE) {
message = "> Start " + getBundleName(bundle) + " [" + bundle.getSymbolicName() + " " + bundle.getVersion() + "]";
}
} else if (event.getType() == BundleEvent.STOPPING) {
if (bundle.getState() != BundleEvent.STOPPING && bundle.getState() != BundleEvent.UNINSTALLED) {
message = "< Stop " + getBundleName(bundle) + " [" + bundle.getSymbolicName() + " " + bundle.getVersion() + "]";
}
}
if (message != null) {
System.err.println(message);
}
}, null);
// context.addBundleListener(new BundleLoadListener());
}
plugin = this;
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class DashboardUpdater method updateDashboards.
private void updateDashboards(DBRProgressMonitor monitor, List<DashboardContainer> dashboards) {
monitor.beginTask("Update dashboards", dashboards.size());
// Get all map queries used by dashboards
for (DashboardContainer dashboard : dashboards) {
DashboardMapQuery mapQuery = dashboard.getMapQuery();
if (mapQuery != null) {
List<MapQueryInfo> queryList = mapQueries.computeIfAbsent(dashboard.getDataSourceContainer(), k -> new ArrayList<>());
boolean found = false;
for (MapQueryInfo mqi : queryList) {
if (mqi.mapQuery == mapQuery) {
found = true;
break;
}
}
if (!found) {
queryList.add(new MapQueryInfo(dashboard.getGroup().getView(), mapQuery));
}
}
}
for (Map.Entry<DBPDataSourceContainer, List<MapQueryInfo>> mqEntry : mapQueries.entrySet()) {
monitor.subTask("Read dashboard data");
DBPDataSourceContainer dsContainer = mqEntry.getKey();
DBPDataSource dataSource = dsContainer.getDataSource();
if (dataSource == null) {
continue;
}
try {
DBExecUtils.tryExecuteRecover(dashboards, dataSource, param -> {
try {
for (MapQueryInfo mqi : mqEntry.getValue()) {
readMapQueryData(monitor, mqi);
}
} catch (Throwable e) {
throw new InvocationTargetException(e);
}
});
} catch (DBException e) {
log.debug("Error reading map query data for '" + dsContainer.getName() + "'", e);
}
}
for (DashboardContainer dashboard : dashboards) {
DBPDataSource dataSource = dashboard.getDataSourceContainer().getDataSource();
if (dataSource == null) {
continue;
}
try {
DBExecUtils.tryExecuteRecover(dashboards, dataSource, param -> {
try {
updateDashboard(monitor, dashboard);
} catch (Throwable e) {
throw new InvocationTargetException(e);
}
});
} catch (DBException e) {
log.debug("Error reading dashboard '" + dashboard.getDashboardId() + "' data: " + GeneralUtils.getRootCause(e).getMessage());
}
monitor.worked(1);
}
monitor.done();
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class NavigatorHandlerFilterConfig method configureFilters.
public static void configureFilters(Shell shell, DBNNode node) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
DBSObjectFilter objectFilter = folder.getNodeFilter(itemsMeta, true);
if (objectFilter == null) {
objectFilter = new DBSObjectFilter();
}
final DBPDataSourceRegistry dsRegistry = folder.getOwnerProject().getDataSourceRegistry();
final boolean globalFilter = folder.getValueObject() instanceof DBPDataSource;
String parentName = "?";
if (folder.getValueObject() instanceof DBSObject) {
parentName = ((DBSObject) folder.getValueObject()).getName();
}
EditObjectFilterDialog dialog = new EditObjectFilterDialog(shell, dsRegistry, globalFilter ? "All " + node.getNodeType() : node.getNodeType() + " of " + parentName, objectFilter, globalFilter);
switch(dialog.open()) {
case IDialogConstants.OK_ID:
folder.setNodeFilter(itemsMeta, dialog.getFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
break;
case EditObjectFilterDialog.SHOW_GLOBAL_FILTERS_ID:
objectFilter = folder.getDataSource().getContainer().getObjectFilter(folder.getChildrenClass(), null, true);
dialog = new EditObjectFilterDialog(shell, dsRegistry, "All " + node.getNodeType(), objectFilter != null ? objectFilter : new DBSObjectFilter(), true);
if (dialog.open() == IDialogConstants.OK_ID) {
// Set global filter
folder.getDataSource().getContainer().setObjectFilter(folder.getChildrenClass(), null, dialog.getFilter());
folder.getDataSource().getContainer().persistConfiguration();
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
}
break;
}
}
}
Aggregations