use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class TransformerSettingsDialog method loadTransformerSettings.
private void loadTransformerSettings(Collection<? extends DBPPropertyDescriptor> properties) {
DBVTransformSettings settings = currentAttribute == null ? null : DBVUtils.getTransformSettings(currentAttribute, false);
Map<String, Object> transformOptions = settings == null ? null : settings.getTransformOptions();
if (transformOptions == null) {
transformOptions = Collections.emptyMap();
}
propertySource = new PropertySourceCustom(properties, transformOptions);
propertiesEditor.loadProperties(propertySource);
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class PostgreFDWConfigWizardPageConfig method refreshFDWProperties.
private void refreshFDWProperties() {
{
// Fill options
DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
PostgreFDWConfigWizard.FDWInfo selectedFDW = getWizard().getSelectedFDW();
PropertySourceCustom propertySource = getWizard().getFdwPropertySource();
propertySource.setDefValueResolver(targetDataSource.getVariablesResolver(false));
propertySource.removeAll();
if (selectedFDW != null && selectedFDW.fdwDescriptor != null) {
propertySource.addProperties(selectedFDW.fdwDescriptor.getProperties());
} else if (selectedFDW != null) {
// Add some default props
propertySource.addProperty(new PropertyDescriptor(null, "host", "host", "Remote database host", false, String.class, "${host}", null));
propertySource.addProperty(new PropertyDescriptor(null, "port", "port", "Remote database port", false, String.class, "${port}", null));
propertySource.addProperty(new PropertyDescriptor(null, "dbname", "dbname", "Remote database name", false, String.class, "${database}", null));
}
propsEditor.loadProperties(propertySource);
}
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.
the class StreamProducerPageSettings method activatePage.
@Override
public void activatePage() {
// Initialize property editor
DataTransferProcessorDescriptor processor = getProducerProcessor();
DBPPropertyDescriptor[] properties = processor == null ? new DBPPropertyDescriptor[0] : processor.getProperties();
propertySource = new PropertySourceCustom(properties, getWizard().getSettings().getProcessorProperties());
propsEditor.loadProperties(propertySource);
// Init pipes
reloadPipes();
updatePageCompletion();
UIUtils.asyncExec(() -> UIUtils.packColumns(filesTable, true));
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.
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();
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.
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;
}
Aggregations