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);
}
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();
}
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();
}
}
}
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());
}
}
}
}
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);
}
Aggregations