use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class ResultSetUtils method getEntityFromMetaData.
private static DBSEntity getEntityFromMetaData(DBRProgressMonitor monitor, DBSObjectContainer objectContainer, DBCEntityMetaData entityMeta, boolean transformName) throws DBException {
final DBPDataSource dataSource = objectContainer.getDataSource();
String catalogName = entityMeta.getCatalogName();
String schemaName = entityMeta.getSchemaName();
String entityName = entityMeta.getEntityName();
if (transformName) {
catalogName = DBObjectNameCaseTransformer.transformName(dataSource, catalogName);
schemaName = DBObjectNameCaseTransformer.transformName(dataSource, schemaName);
entityName = DBObjectNameCaseTransformer.transformName(dataSource, entityName);
}
DBSObject entityObject = DBUtils.getObjectByPath(monitor, objectContainer, catalogName, schemaName, entityName);
if (entityObject == null) {
return null;
} else if (entityObject instanceof DBSEntity) {
return (DBSEntity) entityObject;
} else {
log.debug("Unsupported table class: " + entityObject.getClass().getName());
return null;
}
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class TransformerSettingsDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
final DBPDataSource dataSource = viewer.getDataContainer() == null ? null : viewer.getDataContainer().getDataSource();
Collection<? extends DBPPropertyDescriptor> properties = Collections.emptyList();
final DBDAttributeTransformerDescriptor transformer;
if (dataSource != null && !CommonUtils.isEmpty(settings.getCustomTransformer())) {
transformer = dataSource.getContainer().getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
if (transformer != null) {
properties = transformer.getProperties();
}
} else {
transformer = null;
}
if (transformer != null) {
final Composite placeholder = UIUtils.createControlGroup(composite, "Transformer", 2, GridData.FILL_HORIZONTAL, -1);
UIUtils.createLabelText(placeholder, "Name", transformer.getName(), SWT.READ_ONLY);
Label infoLabel = UIUtils.createControlLabel(placeholder, "Info");
infoLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
final Text infoText = new Text(placeholder, SWT.READ_ONLY | SWT.WRAP);
if (transformer.getDescription() != null) {
infoText.setText(transformer.getDescription());
}
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 300;
infoText.setLayoutData(gd);
}
Map<String, String> transformOptions = settings.getTransformOptions();
if (transformOptions == null) {
transformOptions = Collections.emptyMap();
}
propertiesEditor = new PropertyTreeViewer(composite, SWT.BORDER);
propertySource = new PropertySourceCustom(properties, transformOptions);
propertiesEditor.loadProperties(propertySource);
propertiesEditor.getControl().setFocus();
if (CommonUtils.isEmpty(properties)) {
DBeaverUI.asyncExec(this::okPressed);
}
return parent;
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class DatabaseConsumerPageMapping method showDDL.
private void showDDL(DatabaseMappingContainer mapping) {
final DatabaseConsumerSettings settings = getDatabaseConsumerSettings();
final DBSObjectContainer container = settings.getContainer();
if (container == null) {
return;
}
DBPDataSource dataSource = container.getDataSource();
try {
final String ddl = DatabaseTransferConsumer.generateTargetTableDDL(new VoidProgressMonitor(), dataSource, container, mapping);
ViewSQLDialog dialog = new ViewSQLDialog(DBeaverUI.getActiveWorkbenchWindow().getActivePage().getActivePart().getSite(), dataSource.getDefaultContext(true), "Target DDL", null, ddl);
dialog.open();
} catch (DBException e) {
DBUserInterface.getInstance().showError("Target DDL", "Error generatiung target DDL", e);
}
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class DBeaverUI method showDatabaseError.
private static UserResponse showDatabaseError(String message, DBException error) {
DBPDataSource dataSource = error.getDataSource();
DBPErrorAssistant.ErrorType errorType = dataSource == null ? DBPErrorAssistant.ErrorType.NORMAL : DBUtils.discoverErrorType(dataSource, error);
switch(errorType) {
case CONNECTION_LOST:
if (dataSource.getContainer().getDataSource() == null) {
// Error during datasource init
return null;
}
DataSourceInvalidateHandler.showConnectionLostDialog(null, message, error);
return UserResponse.OK;
case DRIVER_CLASS_MISSING:
DriverEditDialog.showBadConfigDialog(null, message, error);
return UserResponse.OK;
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSource in project dbeaver by dbeaver.
the class CompareObjectsExecutor method getDataSourceFilter.
private DataSourcePropertyFilter getDataSourceFilter(DBNDatabaseNode node) {
DBPDataSource dataSource = node.getDataSourceContainer().getDataSource();
if (dataSource == null) {
return null;
}
DataSourcePropertyFilter filter = dataSourceFilters.get(dataSource);
if (filter == null) {
filter = new DataSourcePropertyFilter(dataSource);
dataSourceFilters.put(dataSource, filter);
}
return filter;
}
Aggregations