Search in sources :

Example 16 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

the class PrefPageDataFormat method reloadFormatter.

private void reloadFormatter() {
    DataFormatterDescriptor formatterDescriptor = getCurrentFormatter();
    if (formatterDescriptor == null) {
        return;
    }
    Map<Object, Object> formatterProps = profileProperties.get(formatterDescriptor.getId());
    Map<Object, Object> defaultProps = formatterDescriptor.getSample().getDefaultProperties(localeSelector.getSelectedLocale());
    propertySource = new PropertySourceCustom(formatterDescriptor.getProperties(), formatterProps);
    propertySource.setDefaultValues(defaultProps);
    propertiesControl.loadProperties(propertySource);
    reloadSample();
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DataFormatterDescriptor(org.jkiss.dbeaver.registry.formatter.DataFormatterDescriptor)

Example 17 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.

the class StreamConsumerPageSettings method activatePage.

@Override
public void activatePage() {
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
    propertySource = new PropertySourceCustom(processor.getProperties(), getWizard().getSettings().getProcessorProperties());
    propsEditor.loadProperties(propertySource);
    switch(settings.getLobExtractType()) {
        case SKIP:
            lobExtractType.select(EXTRACT_LOB_SKIP);
            break;
        case FILES:
            lobExtractType.select(EXTRACT_LOB_FILES);
            break;
        case INLINE:
            lobExtractType.select(EXTRACT_LOB_INLINE);
            break;
    }
    switch(settings.getLobEncoding()) {
        case BASE64:
            lobEncodingCombo.select(LOB_ENCODING_BASE64);
            break;
        case HEX:
            lobEncodingCombo.select(LOB_ENCODING_HEX);
            break;
        case BINARY:
            lobEncodingCombo.select(LOB_ENCODING_BINARY);
            break;
        case NATIVE:
            lobEncodingCombo.select(LOB_ENCODING_NATIVE);
            break;
    }
    updatePageCompletion();
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 18 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.

the class PostgreFDWConfigWizard method generateScript.

List<DBEPersistAction> generateScript(DBRProgressMonitor monitor) throws DBException {
    PostgreDatabase database = getDatabase();
    PostgreDataSource curDataSource = database.getDataSource();
    List<DBEPersistAction> actions = new ArrayList<>();
    PostgreFDWConfigWizard.FDWInfo selectedFDW = getSelectedFDW();
    PropertySourceCustom propertySource = getFdwPropertySource();
    Map<String, Object> propValues = propertySource.getPropertiesWithDefaults();
    String serverId = getFdwServerId();
    actions.add(new SQLDatabasePersistActionComment(curDataSource, "CREATE EXTENSION " + selectedFDW.getId()));
    {
        StringBuilder script = new StringBuilder();
        script.append("CREATE SERVER ").append(serverId).append("\n\tFOREIGN DATA WRAPPER ").append(selectedFDW.getId()).append("\n\tOPTIONS(");
        boolean firstProp = true;
        for (Map.Entry<String, Object> pe : propValues.entrySet()) {
            String propName = CommonUtils.toString(pe.getKey());
            String propValue = CommonUtils.toString(pe.getValue());
            if (CommonUtils.isEmpty(propName) || CommonUtils.isEmpty(propValue)) {
                continue;
            }
            if (!firstProp)
                script.append(", ");
            script.append(propName).append(" '").append(propValue).append("'");
            firstProp = false;
        }
        script.append(")");
        actions.add(new SQLDatabasePersistAction("Create extension", script.toString()));
    }
    actions.add(new SQLDatabasePersistAction("CREATE USER MAPPING FOR CURRENT_USER SERVER " + serverId));
    // Now tables
    DBECommandContext commandContext = new SimpleCommandContext(getExecutionContext(), false);
    try {
        PostgreFDWConfigWizard.FDWInfo fdwInfo = getSelectedFDW();
        Map<String, Object> options = new HashMap<>();
        options.put(SQLObjectEditor.OPTION_SKIP_CONFIGURATION, true);
        PostgreForeignTableManager tableManager = new PostgreForeignTableManager();
        PostgreTableColumnManager columnManager = new PostgreTableColumnManager();
        for (DBNDatabaseNode tableNode : getSelectedEntities()) {
            DBSEntity entity = (DBSEntity) tableNode.getObject();
            PostgreTableForeign pgTable = (PostgreTableForeign) tableManager.createNewObject(monitor, commandContext, getSelectedSchema(), null, options);
            if (pgTable == null) {
                log.error("Internal error while creating new table");
                continue;
            }
            pgTable.setName(entity.getName());
            pgTable.setForeignServerName(serverId);
            pgTable.setForeignOptions(new String[0]);
            for (DBSEntityAttribute attr : CommonUtils.safeCollection(entity.getAttributes(monitor))) {
                // Cache data types
                PostgreSchema catalogSchema = database.getCatalogSchema(monitor);
                if (catalogSchema != null) {
                    catalogSchema.getDataTypes(monitor);
                }
                String defTypeName = DBStructUtils.mapTargetDataType(database, attr, true);
                String plainTargetTypeName = SQLUtils.stripColumnTypeModifiers(defTypeName);
                PostgreDataType dataType = database.getDataType(monitor, plainTargetTypeName);
                if (dataType == null) {
                    log.error("Data type '" + plainTargetTypeName + "' not found. Skip column mapping.");
                    continue;
                }
                PostgreTableColumn newColumn = columnManager.createNewObject(monitor, commandContext, pgTable, null, options);
                assert newColumn != null;
                newColumn.setName(attr.getName());
                newColumn.setDataType(dataType);
            }
            DBEPersistAction[] tableDDL = tableManager.getTableDDL(monitor, pgTable, options);
            Collections.addAll(actions, tableDDL);
        }
    } finally {
        commandContext.resetChanges(true);
    }
    // CREATE SERVER clickhouse_svr FOREIGN DATA WRAPPER clickhousedb_fdw OPTIONS(dbname 'default', driver '/usr/local/lib/odbc/libclickhouseodbc.so', host '46.101.202.143');
    return actions;
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction) DBECommandContext(org.jkiss.dbeaver.model.edit.DBECommandContext) PostgreForeignTableManager(org.jkiss.dbeaver.ext.postgresql.edit.PostgreForeignTableManager) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) SQLDatabasePersistActionComment(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment) PostgreTableColumnManager(org.jkiss.dbeaver.ext.postgresql.edit.PostgreTableColumnManager) PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) SimpleCommandContext(org.jkiss.dbeaver.ui.editors.SimpleCommandContext) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity)

Example 19 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.

the class PrefPageDataFormat method reloadFormatter.

private void reloadFormatter() {
    DataFormatterDescriptor formatterDescriptor = getCurrentFormatter();
    if (formatterDescriptor == null) {
        return;
    }
    Map<String, Object> formatterProps = profileProperties.get(formatterDescriptor.getId());
    Map<String, Object> defaultProps = formatterDescriptor.getSample().getDefaultProperties(localeSelector.getSelectedLocale());
    propertySource = new PropertySourceCustom(formatterDescriptor.getProperties(), formatterProps);
    propertySource.setDefaultValues(defaultProps);
    propertiesControl.loadProperties(propertySource);
    reloadSample();
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DataFormatterDescriptor(org.jkiss.dbeaver.registry.formatter.DataFormatterDescriptor)

Example 20 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.

the class DriverEditDialog method createParametersTab.

private void createParametersTab(TabFolder group) {
    Composite paramsGroup = new Composite(group, SWT.NONE);
    paramsGroup.setLayout(new GridLayout(1, false));
    parametersEditor = new PropertyTreeViewer(paramsGroup, SWT.BORDER);
    driverPropertySource = new PropertySourceCustom(driver.getProviderDescriptor().getDriverProperties(), driver.getDriverParameters());
    driverPropertySource.addDefaultValues(driver.getDefaultDriverParameters());
    parametersEditor.loadProperties(driverPropertySource);
    TabItem paramsTab = new TabItem(group, SWT.NONE);
    paramsTab.setText(UIConnectionMessages.dialog_edit_driver_tab_name_advanced_parameters);
    paramsTab.setToolTipText(UIConnectionMessages.dialog_edit_driver_tab_tooltip_advanced_parameters);
    paramsTab.setControl(paramsGroup);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer)

Aggregations

PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)22 DataFormatterDescriptor (org.jkiss.dbeaver.registry.formatter.DataFormatterDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor)3 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)3 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 PostgreForeignTableManager (org.jkiss.dbeaver.ext.postgresql.edit.PostgreForeignTableManager)2 PostgreTableColumnManager (org.jkiss.dbeaver.ext.postgresql.edit.PostgreTableColumnManager)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBECommandContext (org.jkiss.dbeaver.model.edit.DBECommandContext)2 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)2 PropertyDescriptor (org.jkiss.dbeaver.model.impl.PropertyDescriptor)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 SQLDatabasePersistActionComment (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)2 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 DBVTransformSettings (org.jkiss.dbeaver.model.virtual.DBVTransformSettings)2