Search in sources :

Example 1 with DBVEntityAttribute

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

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

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

the class DBUtils method injectAndFilterAttributeBindings.

public static DBDAttributeBinding[] injectAndFilterAttributeBindings(@NotNull DBPDataSource dataSource, @NotNull DBSDataContainer dataContainer, DBDAttributeBinding[] bindings, boolean filterAttributes) {
    // Add custom attributes
    DBVEntity vEntity = DBVUtils.getVirtualEntity(dataContainer, false);
    if (vEntity != null) {
        List<DBVEntityAttribute> customAttributes = DBVUtils.getCustomAttributes(vEntity);
        if (!CommonUtils.isEmpty(customAttributes)) {
            DBDAttributeBinding[] customBindings = new DBDAttributeBinding[customAttributes.size()];
            for (int i = 0; i < customAttributes.size(); i++) {
                customBindings[i] = new DBDAttributeBindingCustom(null, dataContainer, dataSource, customAttributes.get(i), bindings.length + i);
            }
            DBDAttributeBinding[] combinedAttrs = new DBDAttributeBinding[bindings.length + customBindings.length];
            System.arraycopy(bindings, 0, combinedAttrs, 0, bindings.length);
            System.arraycopy(customBindings, 0, combinedAttrs, bindings.length, customBindings.length);
            bindings = combinedAttrs;
        }
    }
    if (filterAttributes && dataContainer instanceof DBDAttributeFilter) {
        return ((DBDAttributeFilter) dataContainer).filterAttributeBindings(bindings);
    } else {
        return bindings;
    }
}
Also used : DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity) DBVEntityConstraint(org.jkiss.dbeaver.model.virtual.DBVEntityConstraint)

Example 3 with DBVEntityAttribute

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

the class VirtualAttributeAddAction method run.

@Override
public void run() {
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
    DBVEntityAttribute vAttr = new DBVEntityAttribute(vEntity, null, "vcolumn");
    if (new EditVirtualAttributePage(resultSetViewer, vAttr).edit(resultSetViewer.getControl().getShell())) {
        vAttr.setCustom(true);
        vEntity.addVirtualAttribute(vAttr);
        vEntity.persistConfiguration();
        resultSetViewer.refreshMetaData();
        DBDAttributeConstraint vAttrConstr = resultSetViewer.getModel().getDataFilter().getConstraint(vAttr, false);
        if (vAttrConstr != null) {
        }
    }
}
Also used : DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 4 with DBVEntityAttribute

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

the class VirtualAttributeEditAction method run.

@Override
public void run() {
    if (attr == null) {
        return;
    }
    DBVEntityAttribute vAttr = ((DBDAttributeBindingCustom) attr).getEntityAttribute();
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
    if (new EditVirtualAttributePage(resultSetViewer, vAttr).edit(resultSetViewer.getControl().getShell())) {
        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 5 with DBVEntityAttribute

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

Aggregations

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