use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.
the class DataTransferWizard method saveConfiguration.
private Map<String, Object> saveConfiguration(Map<String, Object> config) {
config.put("maxJobCount", settings.getMaxJobCount());
config.put("showFinalMessage", settings.isShowFinalMessage());
// Save nodes' settings
boolean isTask = getCurrentTask() != null;
for (Map.Entry<Class, NodePageSettings> entry : nodeSettings.entrySet()) {
NodePageSettings nodePageSettings = entry.getValue();
if (isTask) {
// Do not save settings for nodes not involved in this task
if (nodePageSettings.sourceNode.getNodeType() == DataTransferNodeDescriptor.NodeType.PRODUCER && settings.getProducer() != null && !settings.getProducer().getId().equals(nodePageSettings.sourceNode.getId())) {
continue;
}
if (nodePageSettings.sourceNode.getNodeType() == DataTransferNodeDescriptor.NodeType.CONSUMER && settings.getConsumer() != null && !settings.getConsumer().getId().equals(nodePageSettings.sourceNode.getId())) {
continue;
}
}
Map<String, Object> nodeSection = new LinkedHashMap<>();
IDataTransferSettings settings = this.settings.getNodeSettings(nodePageSettings.sourceNode);
if (settings != null) {
settings.saveSettings(nodeSection);
}
// Note: do it in the end because of limitation of IDialogSettings wrapper
config.put(entry.getKey().getSimpleName(), nodeSection);
}
if (settings.getProducer() != null) {
config.put("producer", settings.getProducer().getId());
}
if (settings.getConsumer() != null) {
config.put("consumer", settings.getConsumer().getId());
}
if (settings.getProcessor() != null) {
config.put("processor", settings.getProcessor().getId());
}
// Save processors' properties
Map<String, Object> processorsSection = new LinkedHashMap<>();
for (DataTransferProcessorDescriptor procDescriptor : settings.getProcessorPropsHistory().keySet()) {
if (isTask) {
// Do not save settings for nodes not involved in this task
if (settings.getProcessor() == null || !settings.getProcessor().getId().equals(procDescriptor.getId())) {
continue;
}
}
Map<String, Object> procSettings = new LinkedHashMap<>();
Map<String, Object> props = settings.getProcessorPropsHistory().get(procDescriptor);
if (!CommonUtils.isEmpty(props)) {
StringBuilder propNames = new StringBuilder();
for (Map.Entry<String, Object> prop : props.entrySet()) {
propNames.append(prop.getKey()).append(',');
}
procSettings.put("@propNames", propNames.toString());
for (Map.Entry<String, Object> prop : props.entrySet()) {
procSettings.put(CommonUtils.toString(prop.getKey()), CommonUtils.toString(prop.getValue()));
}
}
processorsSection.put(procDescriptor.getFullId(), procSettings);
}
config.put("processors", processorsSection);
return config;
}
use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.
the class ResultSetHandlerCopyAs method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
// Put processor name in command label
DataTransferProcessorDescriptor processor = getActiveProcessor((String) parameters.get(PARAM_PROCESSOR_ID));
if (processor != null) {
String commandName = ActionUtils.findCommandName(CMD_COPY_AS);
element.setText(commandName + " " + processor.getName());
if (!CommonUtils.isEmpty(processor.getDescription())) {
element.setTooltip(processor.getDescription());
}
if (processor.getIcon() != null) {
element.setIcon(DBeaverIcons.getImageDescriptor(processor.getIcon()));
}
}
}
use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.
the class ResultSetHandlerOpenWith method getDefaultAppProcessor.
private static DataTransferProcessorDescriptor getDefaultAppProcessor() {
List<DataTransferProcessorDescriptor> processors = new ArrayList<>();
for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getNodes(DataTransferNodeDescriptor.NodeType.CONSUMER)) {
for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
if (processor.getAppFileExtension() != null) {
processors.add(processor);
}
}
}
processors.sort(Comparator.comparingInt(DataTransferProcessorDescriptor::getOrder));
return processors.isEmpty() ? null : processors.get(0);
}
use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.
the class ResultSetHandlerOpenWith method fillOpenWithMenu.
public static void fillOpenWithMenu(ResultSetViewer viewer, IContributionManager openWithMenu) {
ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
ResultSetDataContainer dataContainer = new ResultSetDataContainer(viewer, options);
List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
if (processor.getAppFileExtension() != null) {
appProcessors.add(processor);
}
}
}
appProcessors.sort(Comparator.comparingInt(DataTransferProcessorDescriptor::getOrder));
for (DataTransferProcessorDescriptor processor : appProcessors) {
CommandContributionItemParameter params = new CommandContributionItemParameter(viewer.getSite(), processor.getId(), ResultSetHandlerOpenWith.CMD_OPEN_WITH, CommandContributionItem.STYLE_RADIO);
params.label = processor.getAppName();
if (processor.getIcon() != null) {
params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
}
Map<String, Object> parameters = new HashMap<>();
parameters.put(ResultSetHandlerOpenWith.PARAM_PROCESSOR_ID, processor.getFullId());
params.parameters = parameters;
openWithMenu.add(new CommandContributionItem(params));
}
}
use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.
the class DataImportHandler method getProcessorByFile.
private DataTransferProcessorDescriptor getProcessorByFile(IFile file) {
String extension = file.getFileExtension();
if (CommonUtils.isEmpty(extension)) {
return null;
}
extension = extension.toLowerCase(Locale.ENGLISH);
DataTransferNodeDescriptor producerDesc = DataTransferRegistry.getInstance().getNodeById(StreamTransferProducer.NODE_ID);
if (producerDesc != null) {
for (DataTransferProcessorDescriptor processor : producerDesc.getProcessors()) {
DBPPropertyDescriptor extList = processor.getProperty("extension");
if (extList == null) {
continue;
}
String[] defExtensions = CommonUtils.split(CommonUtils.toString(extList.getDefaultValue()), ",");
if (ArrayUtils.contains(defExtensions, extension)) {
return processor;
}
}
}
return null;
}
Aggregations