Search in sources :

Example 6 with DBVEntityAttribute

use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute 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)

Example 7 with DBVEntityAttribute

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

the class VirtualAttributeDeleteAction method run.

@Override
public void run() {
    if (!(attr instanceof DBDAttributeBindingCustom)) {
        return;
    }
    DBVEntityAttribute vAttr = ((DBDAttributeBindingCustom) attr).getEntityAttribute();
    if (!UIUtils.confirmAction(resultSetViewer.getControl().getShell(), "Delete column '" + vAttr.getName() + "'", "Are you sure you want to delete virtual column '" + vAttr.getName() + "'?")) {
        return;
    }
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
    vEntity.removeVirtualAttribute(vAttr);
    vEntity.persistConfiguration();
    resultSetViewer.refreshMetaData();
}
Also used : DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBDAttributeBindingCustom(org.jkiss.dbeaver.model.data.DBDAttributeBindingCustom) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 8 with DBVEntityAttribute

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

the class GISLeafletViewer method saveAttributeSettings.

private void saveAttributeSettings() {
    if (valueController instanceof IAttributeController) {
        DBDAttributeBinding binding = ((IAttributeController) valueController).getBinding();
        if (binding.getEntityAttribute() != null) {
            DBVEntity vEntity = DBVUtils.getVirtualEntity(binding, true);
            DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(binding, true);
            if (vAttr != null) {
                vAttr.setProperty(PROP_FLIP_COORDINATES, String.valueOf(flipCoordinates));
                vAttr.setProperty(PROP_SRID, String.valueOf(getValueSRID()));
            }
            valueController.getExecutionContext().getDataSource().getContainer().getRegistry().flushConfig();
        }
    }
}
Also used : DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) IAttributeController(org.jkiss.dbeaver.ui.data.IAttributeController) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 9 with DBVEntityAttribute

use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute 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 10 with DBVEntityAttribute

use of org.jkiss.dbeaver.model.virtual.DBVEntityAttribute 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)

Aggregations

DBVEntityAttribute (org.jkiss.dbeaver.model.virtual.DBVEntityAttribute)22 DBVEntity (org.jkiss.dbeaver.model.virtual.DBVEntity)10 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)6 DBVTransformSettings (org.jkiss.dbeaver.model.virtual.DBVTransformSettings)6 GridData (org.eclipse.swt.layout.GridData)4 Composite (org.eclipse.swt.widgets.Composite)4 DBDAttributeBindingCustom (org.jkiss.dbeaver.model.data.DBDAttributeBindingCustom)4 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 List (java.util.List)2 JexlExpression (org.apache.commons.jexl3.JexlExpression)2 ComboContentAdapter (org.eclipse.jface.fieldassist.ComboContentAdapter)2 SWT (org.eclipse.swt.SWT)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Combo (org.eclipse.swt.widgets.Combo)2 Control (org.eclipse.swt.widgets.Control)2