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