Search in sources :

Example 6 with DBVTransformSettings

use of org.jkiss.dbeaver.model.virtual.DBVTransformSettings 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);
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings)

Example 7 with DBVTransformSettings

use of org.jkiss.dbeaver.model.virtual.DBVTransformSettings in project dbeaver by serge-rider.

the class TransformerSettingsDialog method saveTransformerSettings.

private void saveTransformerSettings() {
    if (currentAttribute == null) {
        // Nothign to save - just ignore
        return;
    }
    DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(currentAttribute, true);
    if (vAttr == null) {
        log.error("Can't get attribute settings for " + currentAttribute.getName());
        return;
    }
    DBVTransformSettings settings = DBVUtils.getTransformSettings(vAttr, true);
    if (settings == null) {
        log.error("Can't get transform settings for " + currentAttribute.getName());
        return;
    }
    if (selector) {
        settings.setCustomTransformer(transformer == null ? null : transformer.getId());
    }
    if (transformer == null) {
        settings.setTransformOptions(new LinkedHashMap<>());
    } else {
        final Map<String, Object> properties = propertySource.getPropertiesWithDefaults();
        for (Map.Entry<String, Object> prop : properties.entrySet()) {
            if (prop.getValue() != null) {
                settings.setTransformOption(prop.getKey().toString(), prop.getValue().toString());
            }
        }
    }
}
Also used : DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings)

Example 8 with DBVTransformSettings

use of org.jkiss.dbeaver.model.virtual.DBVTransformSettings in project dbeaver by dbeaver.

the class TransformerSettingsDialog method detectTransformers.

private void detectTransformers() {
    final DBPDataSource dataSource = viewer.getDataSource();
    DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(currentAttribute, false);
    DBVTransformSettings settings = vAttr == null ? null : DBVUtils.getTransformSettings(vAttr, false);
    if (dataSource != null && settings != null && !CommonUtils.isEmpty(settings.getCustomTransformer())) {
        transformer = dataSource.getContainer().getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
    } else {
        transformer = null;
    }
    transformerList = DBWorkbench.getPlatform().getValueHandlerRegistry().findTransformers(currentAttribute.getDataSource(), currentAttribute, null);
}
Also used : DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource)

Aggregations

DBVTransformSettings (org.jkiss.dbeaver.model.virtual.DBVTransformSettings)8 DBVEntityAttribute (org.jkiss.dbeaver.model.virtual.DBVEntityAttribute)6 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)2 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)2 DBDAttributeTransformerDescriptor (org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)2 PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)2