Search in sources :

Example 1 with DataTransferPipe

use of org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe in project dbeaver by serge-rider.

the class DatabaseConsumerPageMapping method activatePage.

@Override
public void activatePage() {
    final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class);
    settings.loadNode(getContainer());
    DBNDatabaseNode containerNode = settings.getContainerNode();
    if (containerNode != null) {
        containerIcon.setImage(DBeaverIcons.getImage(containerNode.getNodeIconDefault()));
        containerName.setText(containerNode.getNodeFullName());
    }
    if (mappingViewer.getInput() == null) {
        Map<DBSDataContainer, DatabaseMappingContainer> dataMappings = settings.getDataMappings();
        for (DataTransferPipe pipe : getWizard().getSettings().getDataPipes()) {
            if (pipe.getProducer() == null) {
                continue;
            }
            DBSDataContainer sourceObject = (DBSDataContainer) pipe.getProducer().getSourceObject();
            if (!dataMappings.containsKey(sourceObject)) {
                DatabaseMappingContainer mapping;
                if (pipe.getConsumer() instanceof DatabaseTransferConsumer && ((DatabaseTransferConsumer) pipe.getConsumer()).getTargetObject() != null) {
                    try {
                        mapping = new DatabaseMappingContainer(getContainer(), sourceObject, ((DatabaseTransferConsumer) pipe.getConsumer()).getTargetObject());
                    } catch (DBException e) {
                        setMessage(e.getMessage(), IMessageProvider.ERROR);
                        mapping = new DatabaseMappingContainer(sourceObject);
                    }
                } else {
                    mapping = new DatabaseMappingContainer(sourceObject);
                }
                dataMappings.put(sourceObject, mapping);
            }
        }
        List<DatabaseMappingContainer> model = new ArrayList<>(dataMappings.values());
        mappingViewer.setInput(model);
        Tree table = mappingViewer.getTree();
        int totalWidth = table.getClientArea().width;
        TreeColumn[] columns = table.getColumns();
        columns[0].setWidth(totalWidth * 40 / 100);
        columns[1].setWidth(totalWidth * 40 / 100);
        columns[2].setWidth(totalWidth * 20 / 100);
    }
    updatePageCompletion();
}
Also used : DBException(org.jkiss.dbeaver.DBException) ArrayList(java.util.ArrayList) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Example 2 with DataTransferPipe

use of org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe in project dbeaver by serge-rider.

the class DatabaseConsumerSettings method isCompleted.

public boolean isCompleted(Collection<DataTransferPipe> pipes) {
    for (DataTransferPipe pipe : pipes) {
        if (pipe.getProducer() != null) {
            DBSDataContainer sourceObject = (DBSDataContainer) pipe.getProducer().getSourceObject();
            DatabaseMappingContainer containerMapping = dataMappings.get(sourceObject);
            if (containerMapping == null || containerMapping.getMappingType() == DatabaseMappingType.unspecified || !containerMapping.isCompleted()) {
                return false;
            }
        }
    }
    return true;
}
Also used : DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe)

Aggregations

DataTransferPipe (org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe)2 ArrayList (java.util.ArrayList)1 DBException (org.jkiss.dbeaver.DBException)1 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)1 DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)1