use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.
the class StreamConsumerPageOutput method determinePageCompletion.
@Override
protected boolean determinePageCompletion() {
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
if (settings == null) {
return false;
}
if (settings.isOutputClipboard()) {
return true;
}
boolean valid = true;
if (CommonUtils.isEmpty(settings.getOutputFolder())) {
valid = false;
}
if (CommonUtils.isEmpty(settings.getOutputFilePattern())) {
valid = false;
}
if (settings.isExecuteProcessOnFinish() && CommonUtils.isEmpty(settings.getFinishProcessCommand())) {
return false;
}
return valid;
}
use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.
the class StreamConsumerPageOutput method activatePage.
@Override
public void activatePage() {
boolean isBinary = getWizard().getSettings().getProcessor().isBinaryFormat();
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
clipboardCheck.setSelection(settings.isOutputClipboard());
singleFileCheck.setSelection(settings.isUseSingleFile());
directoryText.setText(CommonUtils.toString(settings.getOutputFolder()));
fileNameText.setText(CommonUtils.toString(settings.getOutputFilePattern()));
compressCheckbox.setSelection(settings.isCompressResults());
splitFilesCheckbox.setSelection(settings.isSplitOutFiles());
maximumFileSizeText.setText(String.valueOf(settings.getMaxOutFileSize()));
encodingCombo.setText(CommonUtils.toString(settings.getOutputEncoding()));
timestampPattern.setText(settings.getOutputTimestampPattern());
encodingBOMCheckbox.setSelection(settings.isOutputEncodingBOM());
showFolderCheckbox.setSelection(settings.isOpenFolderOnFinish());
execProcessCheckbox.setSelection(settings.isExecuteProcessOnFinish());
execProcessText.setText(CommonUtils.toString(settings.getFinishProcessCommand()));
if (isBinary) {
clipboardCheck.setSelection(false);
encodingBOMCheckbox.setSelection(false);
settings.setOutputClipboard(false);
}
showFinalMessageCheckbox.setSelection(getWizard().getSettings().isShowFinalMessage());
updatePageCompletion();
updateControlsEnablement();
}
use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.
the class StreamConsumerPageSettings method activatePage.
@Override
public void activatePage() {
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
propertySource = new PropertySourceCustom(processor.getProperties(), getWizard().getSettings().getProcessorProperties());
propsEditor.loadProperties(propertySource);
switch(settings.getLobExtractType()) {
case SKIP:
lobExtractType.select(EXTRACT_LOB_SKIP);
break;
case FILES:
lobExtractType.select(EXTRACT_LOB_FILES);
break;
case INLINE:
lobExtractType.select(EXTRACT_LOB_INLINE);
break;
}
switch(settings.getLobEncoding()) {
case BASE64:
lobEncodingCombo.select(LOB_ENCODING_BASE64);
break;
case HEX:
lobEncodingCombo.select(LOB_ENCODING_HEX);
break;
case BINARY:
lobEncodingCombo.select(LOB_ENCODING_BINARY);
break;
case NATIVE:
lobEncodingCombo.select(LOB_ENCODING_NATIVE);
break;
}
updatePageCompletion();
}
use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.
the class StreamConsumerPageSettings method reloadFormatProfiles.
private void reloadFormatProfiles() {
DBPDataFormatterRegistry registry = DBWorkbench.getPlatform().getDataFormatterRegistry();
formatProfilesCombo.removeAll();
formatProfilesCombo.add(DTMessages.data_transfer_wizard_settings_listbox_formatting_item_default);
for (DBDDataFormatterProfile profile : registry.getCustomProfiles()) {
formatProfilesCombo.add(profile.getProfileName());
}
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
DBDDataFormatterProfile formatterProfile = settings.getFormatterProfile();
if (formatterProfile != null) {
if (!UIUtils.setComboSelection(formatProfilesCombo, formatterProfile.getProfileName())) {
formatProfilesCombo.select(0);
}
} else {
formatProfilesCombo.select(0);
}
}
use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.
the class ResultSetHandlerCopyAs method openResultsWith.
private static void openResultsWith(IResultSetController resultSet, DataTransferProcessorDescriptor processor) {
ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
IResultSetSelection rsSelection = resultSet.getSelection();
List<ResultSetRow> rsSelectedRows = rsSelection.getSelectedRows();
List<DBDAttributeBinding> rsSelectedAttributes = rsSelection.getSelectedAttributes();
if (rsSelectedRows.size() > 1 || rsSelectedAttributes.size() > 1) {
List<Long> selectedRows = new ArrayList<>();
for (ResultSetRow selectedRow : rsSelectedRows) {
selectedRows.add((long) selectedRow.getRowNumber());
}
List<String> selectedAttributes = new ArrayList<>();
for (DBDAttributeBinding attributeBinding : rsSelectedAttributes) {
selectedAttributes.add(attributeBinding.getName());
}
options.setSelectedRows(selectedRows);
options.setSelectedColumns(selectedAttributes);
}
ResultSetDataContainer dataContainer = new ResultSetDataContainer(resultSet, options);
if (dataContainer.getDataSource() == null) {
DBWorkbench.getPlatformUI().showError("Copy as " + processor.getName(), ModelMessages.error_not_connected_to_database);
return;
}
AbstractJob exportJob = new AbstractJob("Copy as " + processor.getName()) {
{
setUser(true);
setSystem(false);
}
@Override
protected IStatus run(DBRProgressMonitor monitor) {
monitor.beginTask("Copy data as", 3);
try {
monitor.subTask("Init");
IDataTransferProcessor processorInstance = processor.getInstance();
if (!(processorInstance instanceof IStreamDataExporter)) {
return Status.CANCEL_STATUS;
}
IStreamDataExporter exporter = (IStreamDataExporter) processorInstance;
StreamTransferConsumer consumer = new StreamTransferConsumer();
StreamConsumerSettings settings = new StreamConsumerSettings();
settings.setOutputClipboard(true);
settings.setOutputEncodingBOM(false);
settings.setOpenFolderOnFinish(false);
Map<String, Object> properties = new HashMap<>();
for (DBPPropertyDescriptor prop : processor.getProperties()) {
properties.put(prop.getId(), prop.getDefaultValue());
}
consumer.initTransfer(dataContainer, settings, new IDataTransferConsumer.TransferParameters(processor.isBinaryFormat(), processor.isHTMLFormat()), exporter, properties);
DBDDataFilter dataFilter = resultSet.getModel().getDataFilter();
DatabaseTransferProducer producer = new DatabaseTransferProducer(dataContainer, dataFilter);
DatabaseProducerSettings producerSettings = new DatabaseProducerSettings();
producerSettings.setOpenNewConnections(false);
if (resultSet.isHasMoreData()) {
// For long resultsets we may need to open new connection
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
if (serviceSQL != null) {
producerSettings.setOpenNewConnections(serviceSQL.useIsolatedConnections(resultSet));
}
}
producerSettings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
producerSettings.setQueryRowCount(false);
producerSettings.setSelectedRowsOnly(!CommonUtils.isEmpty(options.getSelectedRows()));
producerSettings.setSelectedColumnsOnly(!CommonUtils.isEmpty(options.getSelectedColumns()));
monitor.worked(1);
monitor.subTask("Export data");
producer.transferData(monitor, consumer, null, producerSettings, null);
monitor.worked(1);
monitor.subTask("Finalize export");
consumer.finishTransfer(monitor, false);
consumer.finishTransfer(monitor, true);
monitor.worked(1);
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Error opening in " + processor.getAppName(), null, e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
exportJob.schedule();
}
Aggregations