Search in sources :

Example 1 with DBVTransformSettings

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

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 2 with DBVTransformSettings

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

the class TransformerSettingsDialog method updateTransformItem.

private void updateTransformItem(TableItem attrItem) {
    DBDAttributeBinding attr = (DBDAttributeBinding) attrItem.getData();
    String transformStr = "";
    DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(attr, false);
    if (vAttr != null) {
        DBVTransformSettings settings = vAttr.getTransformSettings();
        if (settings != null) {
            if (!CommonUtils.isEmpty(settings.getIncludedTransformers())) {
                transformStr = String.join(",", settings.getIncludedTransformers());
            } else if (!CommonUtils.isEmpty(settings.getCustomTransformer())) {
                DBDAttributeTransformerDescriptor td = DBWorkbench.getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
                if (td != null) {
                    transformStr = td.getName();
                }
            }
        }
    }
    attrItem.setText(1, transformStr);
}
Also used : DBDAttributeTransformerDescriptor(org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding)

Example 3 with DBVTransformSettings

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

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 4 with DBVTransformSettings

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

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)

Example 5 with DBVTransformSettings

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

the class TransformerSettingsDialog method updateTransformItem.

private void updateTransformItem(TableItem attrItem) {
    DBDAttributeBinding attr = (DBDAttributeBinding) attrItem.getData();
    String transformStr = "";
    DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(attr, false);
    if (vAttr != null) {
        DBVTransformSettings settings = vAttr.getTransformSettings();
        if (settings != null) {
            if (!CommonUtils.isEmpty(settings.getIncludedTransformers())) {
                transformStr = String.join(",", settings.getIncludedTransformers());
            } else if (!CommonUtils.isEmpty(settings.getCustomTransformer())) {
                DBDAttributeTransformerDescriptor td = DBWorkbench.getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
                if (td != null) {
                    transformStr = td.getName();
                }
            }
        }
    }
    attrItem.setText(1, transformStr);
}
Also used : DBDAttributeTransformerDescriptor(org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding)

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